如何在vim中的shell中执行yanked多行命令
我在一个文件中有以下如何在vim中的shell中执行yanked多行命令,shell,vim,Shell,Vim,我在一个文件中有以下curl命令 curl \ --request POST \ https://oauth2.googleapis.com/tokeninfo?id_token=eyJhbGci 如何在vim中的bash/zsh shell中执行命令? 我试着做:!“(然后按Ctrl+r键)但它说 zsh:1: no match found: https://oauth2.googleapis.com/tokeninfo?id_token=eyJhbGci shell return
curl
命令
curl \
--request POST \
https://oauth2.googleapis.com/tokeninfo?id_token=eyJhbGci
如何在vim
中的bash/zsh shell中执行命令?
我试着做:!“
(然后按Ctrl+r键)但它说
zsh:1: no match found: https://oauth2.googleapis.com/tokeninfo?id_token=eyJhbGci
shell returned 1
?
是全局字符,zsh正在查找名为http://oauth2.googleapis.com/tokeninfo
+单个字符+id\u token=eyJhbGci
并报告没有匹配项
转义或引用它,任何一个
https://oauth2.googleapis.com/tokeninfo\?id_token=eyJhbGci
'https://oauth2.googleapis.com/tokeninfo?id_token=eyJhbGci'
"https://oauth2.googleapis.com/tokeninfo?id_token=eyJhbGci"
或者使用setopt+o nomatch
使zsh的行为与其他shell中的默认行为类似(如果没有匹配项,则继续使用未触及的参数)
最好只引用它。或者,您可以使用
:help:w_c
将任意行传递给外部命令
选择三行并通过sh
执行:
vjj
:'<,'>w !sh
执行整个缓冲区:
:%w !sh
执行给定范围:
:12,34w !sh
请参见
:help:range
尝试引用URL;?
使两个shell都将URL视为模式,但只有zsh
将失败的匹配视为错误bash
简单地按字面意思处理字符串并将其传递给curl
。从3开始,最后2个字符串完全相同。如果URL前面没有缩进,那么它们都不起作用(IDK why,但就是这样)。也许你可以更新答案,将其包括在内。你以单引号开始,以双引号结束-quote@s1n7ax打字错误,我打算写一行单引号和一行双引号,但替换了错误的一对。
:12,34w !sh