简体   繁体   English

在NERDTree(vim)中编辑文件时,是否可以执行cli命令?

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

I'd like to do a grep -r -l "index.php" while inside vim. 我想在vim里面做一个grep -r -l "index.php" I am using the NERDTree plugin too. 我也使用NERDTree插件。 I've tried the command :! 我已经尝试了命令:! but after this it states 但在此之后它指出

Press ENTER or type command to continue 按ENTER或键入命令以继续

I try to type a command in and it immediately reverts back to vim. 我尝试输入命令,它立即恢复为vim。

Without plugins: 没有插件:

:vimgrep \cindex.php **

( \\c forces ignorecase ; ** is "all files in this directory and below") \\c强制ignorecase**是“此目录及以下目录中的所有文件”)

With ack and Ack.vim : 使用ackAck.vim

:Ack -i index.php

With the_silver_searcher and Ag.vim : 使用the_silver_searcherAg.vim

:Ag -i index.php

You can also add in NERDTree integration using NERDTree-Ack and NERDTree-Ag . 您还可以使用NERDTree-AckNERDTree-Ag添加NERDTree集成。

Inorder to run an external command, you can prefix it with :! 为了运行外部命令,您可以在其前面加上:!

In your case, 就你而言

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

ie, your supposed to type the command(s) after :! 即,您应该在:!之后键入命令:! while you're in vim itself. 在vim本身中。

Using vimgrep , you can do 使用vimgrep ,您可以执行

:vimgrep /\cindex\.php/ **

Do check the examples given in vim-tips-working-with-external-commands 检查一下vim-tips-working-with-external-commands中给出的示例

but after this it states "Press ENTER or type command to continue" 但是在此之后它会显示“按ENTER或键入命令以继续”

This is the expected result. 这是预期的结果。 For grep command, you can see the results on top of this line. 对于grep命令,您可以在此行顶部看到结果。

Do checkout vimgrep , Silver Searcher etc for a better workflow. 请签出vimgrepSilver Searcher等以获得更好的工作流程。 Some links to familiarize them 一些使他们熟悉的链接

Faster Grepping in Vim 在Vim中更快地掌握
Search multiple files with :vimgrep :vimgrep搜索多个文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM