寻求解释|的统一理论<;Bar>;,在Vim中
下面是一些实验,以演示在Vim命令的不同场景中,寻求解释|的统一理论<;Bar>;,在Vim中,vim,Vim,下面是一些实验,以演示在Vim命令的不同场景中,\、和\\\的行为 *:!cmd* *:!* *E34* :!{cmd} Execute {cmd} with the shell. See also the 'shell' and 'shelltype' option.
\
、
和\\\
的行为
*:!cmd* *:!* *E34*
:!{cmd} Execute {cmd} with the shell. See also the 'shell'
and 'shelltype' option.
...
A '|' in {cmd} is passed to the shell, you cannot use
it to append a Vim command. See |:bar|.
下面的代码块显示了几个Vim命令,每个命令(或一组命令)后面都有一个关于命令行为的快速注释
案例1:Shell命令
结论:
和|
的行为类似(作为
传递给shell)|
\\\\\\\\\\\\\\\\\\\\\\\/code>的行为不同(作为文本
\\\\\\\\\\/code>传递给shell)
的行为不同(作为命令分隔符)|
和\\\124;
的行为类似(作为文字参数)
的行为不同(在本例中,|
和另一个Vim命令之间的命令分隔符为:map
)new
和
的行为类似(当执行映射rhs时,它们变成\\\\\
)
:map
将按键笔划重新映射到命令行模式命令
*:!cmd* *:!* *E34*
:!{cmd} Execute {cmd} with the shell. See also the 'shell'
and 'shelltype' option.
...
A '|' in {cmd} is passed to the shell, you cannot use
it to append a Vim command. See |:bar|.
案例7:不接受参数的Vim命令
结论:
-|
和
的行为类似(在命令运行时作为命令分隔符)。
-\\\\\\\
的行为就好像\\\\\\\\
在bn\\\\\\\
中被字面上用作\\\\\\\\\
一样,这会产生前一案例中所示的混乱行为
这种行为与案例2和案例5一致
案例9:不接受参数的Vim命令的映射。
:map,a:bn | bn
A.
执行`:map`命令时切换到下一个缓冲区。
在命令行模式下输入“:bn”。
:地图,a:bn
A.
在命令行模式下输入“:bn | bn”。
:map,a:bn\|bn
A.
在命令行模式下输入“:bn | bn”
这与上文案例3和案例6一致
我的问题
关于假定Vim的默认设置(默认
cpoptions
、普通:map
和\\code>命令等),在各种命令中如何解释
、\
和\
命令的明确规则(根据权威Vim文档或参考)是什么?发布此问题后,我一直在研究Vim的:help
,以收集尽可能多的线索。这是一个似乎几乎可行的理论。我包括Vim的:help
中的相关文档,我可以找到这些文档来支持每一点
用:
、\
、
和\\\\
按字面意思传递给shell命令
*:!cmd* *:!* *E34*
:!{cmd} Execute {cmd} with the shell. See also the 'shell'
and 'shelltype' option.
...
A '|' in {cmd} is passed to the shell, you cannot use
it to append a Vim command. See |:bar|.
许多命令行模式命令(例如map
但不是:command
或:!
)在遇到|
时结束,因为这是命令分隔符
*:bar* *:\bar*
'|' can be used to separate commands, so you can give multiple commands in one
line. If you want to use '|' in an argument, precede it with '\'.
These commands see the '|' as their argument, and can therefore not be
followed by another Vim command:
:argdo
:autocmd
:bufdo
:cdo
:cfdo
:command
...
:make
:normal
...
:[range]!
请务必注意,在上面的列表中,while:command
和:
使用|
作为参数,:map
不使用。这在下面的第4点中很重要
除非文档中对某些命令行模式命令的
和\\\\\
记录了一些特殊行为,否则这些命令会被逐字使用。这可以解释上文第1点中
和\\\\\
的行为。但是它没有解释下面第4点中
的行为
使用:command
,|
和
在运行时执行用户定义的命令时,其行为类似于替换命令文本中的命令分隔符
*:bar* *:\bar*
...
These commands see the '|' as their argument, and can therefore not be
followed by another Vim command:
:argdo
:autocmd
:bufdo
:cdo
:cfdo
:command
...
:make
:normal
...
:[range]!
*:bar* *:\bar*
'|' can be used to separate commands, so you can give multiple commands in one
line. If you want to use '|' in an argument, precede it with '\'.
不清楚为什么
的行为与本文档中:command
中的|
类似
使用:command
,执行用户定义的命令时,\\\\\\\\\\\\\\\\\
在运行时作为替换命令文本中的文本\\\\\\\
参数传递
*:bar* *:\bar*
...
These commands see the '|' as their argument, and can therefore not be
followed by another Vim command:
:argdo
:autocmd
:bufdo
:cdo
:cfdo
:command
...
:make
:normal
...
:[range]!
*:bar* *:\bar*
'|' can be used to separate commands, so you can give multiple commands in one
line. If you want to use '|' in an argument, precede it with '\'.
对于:map
,|
是map
命令和第二个Vim命令之间的命令分隔符。执行map
命令并定义用户定义的命令后,立即执行第二个Vim命令。执行用户定义的命令时不执行该命令。这直接源自上文第2点引用的Vim文档
使用:map
,
和\\\\
在用户定义的命令运行时的行为类似于命令分隔符
*map_bar* *map-bar*
Since the '|' character is used to separate a map command from the next
command, you will have to do something special to include a '|' in {rhs}.
There are three methods:
use works when example ~
<Bar> '<' is not in 'cpoptions' :map _l :!ls <Bar> more^M
\| 'b' is not in 'cpoptions' :map _l :!ls \| more^M
^V| always, in Vim and Vi :map _l :!ls ^V| more^M
(here ^V stands for CTRL-V; to get one CTRL-V you have to type it twice; you
cannot use the <> notation "<C-V>" here).
All three work when you use the default setting for 'cpoptions'.
*地图栏**地图栏*
因为“|”字符用于将一个映射命令与下一个映射命令分开
命令,则必须执行一些特殊操作,以便在{rhs}中包含一个“|”。
有三种方法:
举例说明时使用~
'在案例1中,
不是作为|
传递给shell,而是作为
传递给shell。这将尝试从名为Bar
的文件中重定向stdin,该文件不存在。@l3via如果您是对的。谢谢你叫我出来。在我的问题中,我已经确定了这个案例的“结论”。对于投票认为这个问题离题的亲密选民:关于Vim的问题一直都是关于堆栈溢出的话题。看哪句话:“……如果你的问题通常涉及……程序员常用的软件工具……那么你就在正确的地方提出你的问题了!”。另见。
*:!cmd* *:!* *E34*
:!{cmd} Execute {cmd} with the shell. See also the 'shell'
and 'shelltype' option.
...
A '|' in {cmd} is passed to the shell, you cannot use
it to append a Vim command. See |:bar|.
*:bar* *:\bar*
'|' can be used to separate commands, so you can give multiple commands in one
line. If you want to use '|' in an argument, precede it with '\'.
These commands see the '|' as their argument, and can therefore not be
followed by another Vim command:
:argdo
:autocmd
:bufdo
:cdo
:cfdo
:command
...
:make
:normal
...
:[range]!
*:bar* *:\bar*
...
These commands see the '|' as their argument, and can therefore not be
followed by another Vim command:
:argdo
:autocmd
:bufdo
:cdo
:cfdo
:command
...
:make
:normal
...
:[range]!
*:bar* *:\bar*
'|' can be used to separate commands, so you can give multiple commands in one
line. If you want to use '|' in an argument, precede it with '\'.
*map_bar* *map-bar*
Since the '|' character is used to separate a map command from the next
command, you will have to do something special to include a '|' in {rhs}.
There are three methods:
use works when example ~
<Bar> '<' is not in 'cpoptions' :map _l :!ls <Bar> more^M
\| 'b' is not in 'cpoptions' :map _l :!ls \| more^M
^V| always, in Vim and Vi :map _l :!ls ^V| more^M
(here ^V stands for CTRL-V; to get one CTRL-V you have to type it twice; you
cannot use the <> notation "<C-V>" here).
All three work when you use the default setting for 'cpoptions'.
*key-notation* *key-codes* *keycodes*
These names for keys are used in the documentation. ...
...
<Bslash> backslash \ 92 *backslash* *<Bslash>*
<Bar> vertical bar | 124 *<Bar>*
<Del> delete 127
...
For mapping, abbreviation and menu commands you can then copy-paste the
examples and use them directly. Or type them literally, including the '<' and
'>' characters. This does NOT work for other commands, like ":set" and
":autocmd"!
SPECIAL CHARACTERS
The ":map" command can be followed by another command. A | character
separates the two commands. This also means that a | character can't be used
inside a map command. To include one, use <Bar> (five characters). Example:
:map <F8> :write <Bar> !checkin %:S<CR>