我喜欢:lgrep
在 Vim 中使用该命令为当前缓冲区创建位置列表。例如,我可以通过执行以下操作将其与 Perl 正则表达式一起使用:
:lgrep -P 'pattern' %
但是,我不喜欢在 grep 完成后显示 grep 的结果,掩盖了我的 Vim 会话这一事实。我希望将结果放入位置列表窗口,但要抑制 grep(到屏幕)的输出。通常,grep 完成后,Vim 会隐藏所有窗口并在我的终端中显示 grep 的结果。然后我必须Press ENTER or type command to continue
回到 Vim 会话。
这很烦人。
我通常会立即打开一个位置列表窗口并使用该窗口浏览结果。我想禁止显示 grep 结果,然后提示我按 ENTER 继续。
这可能吗?
是的,只需:silent
在命令前加上:
:silent lgrep -P 'pattern' %
Run Code Online (Sandbox Code Playgroud)
摘自:help :silent
:
Run Code Online (Sandbox Code Playgroud)":silent" will also avoid the hit-enter prompt. When using this for an external command, this may cause the screen to be messed up. Use |CTRL-L| to clean it up then.