% 和 ! 在 Vim 命令中是什么意思?

vic*_*ico 16 vim

在 Vim 中,

 :%!ls 
Run Code Online (Sandbox Code Playgroud)

执行ls命令并将其输出打印到当前可编辑文件。

但是分别是什么意思%和什么!意思vim

是否可以执行ls而不将其输出写入文档?

mur*_*uru 17

在 Vim 中,运行:h :!:h :%了解每个函数的作用。

现在,:%用于使用 shell 命令运行的输出替换文件的内容:!。如果您不想接触文件的内容,请不要使用%. 做就是了:

:!ls
Run Code Online (Sandbox Code Playgroud)


Mit*_*tch 6

根据VIM 教程

%

Move cursor to the matching bracket.
Place cursor on {}[]() and type "%".
Run Code Online (Sandbox Code Playgroud)

filter through external command 
Any UNIX command can be executed from the vi command line by typing an "!" before the UNIX command.
Autowrite can be intentionally avoided by using "!" to avoid the save when switching files.
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅Vim 命令备忘单VIM 教程


小智 5

我有同样的问题,并在 中找到了这个:h cmdline-special,这就是我要找的意思:

%   Is replaced with the current file name.       *:_%* *c_%*
Run Code Online (Sandbox Code Playgroud)