有没有办法在 NERDTree(vim) 中编辑文件时执行 cli 命令?

Is there a way to perform a cli command while editing a file in NERDTree(vim)?

我想在 vim 里面做一个 grep -r -l "index.php"。我也在使用 NERDTree 插件。我已经尝试了命令 :! 但在此之后它声明

Press ENTER or type command to continue

我尝试输入命令,它立即恢复为 vim。

没有插件:

:vimgrep \cindex.php **

(\c 强制 ignorecase; ** 是 "all files in this directory and below")

ack and Ack.vim:

:Ack -i index.php

the_silver_searcher and Ag.vim:

:Ag -i index.php

您还可以使用 NERDTree-Ack and NERDTree-Ag 添加 NERDTree 集成。

为了运行一个外部命令,你可以在它前面加上:!

在你的情况下,

:!grep -r -l "index.php"

也就是说,当你在 vim 本身时,你应该在 :! 之后键入命令。

使用vimgrep,你可以做到

:vimgrep /\cindex\.php/ **

请检查 vim-tips-working-with-external-commands

中给出的示例

but after this it states "Press ENTER or type command to continue"

这是预期的结果。对于 grep 命令,您可以在这一行的顶部看到结果。

检查 vimgrepSilver Searcher 等以获得更好的工作流程。一些熟悉它们的链接

Faster Grepping in Vim
Search multiple files with :vimgrep