阻止vim grep打开第一个匹配的文件

时间:2011-04-19 23:14:36

标签: vim grep

所以,摆弄EasyGrep.vim插件,尝试让它进入适合我的状态。 我正在使用它来递归搜索Rails项目。我几乎得到了我想要的东西,这是我修改过的EasyGrep执行的grep命令的一个例子:

:grep -R -i  --include=*.rb --include=*.rbw --include=*.gem --include=*.gemspec --include=[rR]akefile --include=*.erb --include=*.rhtml SEARCH_WORD .

在光标下找到该单词,并在快速列表中打开搜索结果。

唯一的问题是,:grep似乎会自动将包含第一个匹配的文件打开到当前缓冲区中,我希望它做什么,因为那时我丢失了我刚看的文件在

任何人都知道如何防止这种行为?或者,至少是一个重新打开我正在搜索的文件的hacky解决方法?

:vimgrep不是一个选项 - 它太慢了。

2 个答案:

答案 0 :(得分:19)

来自:help :grep

  

Just like ":make", but use 'grepprg' instead of 'makeprg' and 'grepformat' instead of 'errorformat'.

来自:help :make

  

If [!] is not given the first error is jumped to.

所以::grep!

答案 1 :(得分:0)

将此添加到.vimrc:

    let g:EasyGrepOpenWindowOnMatch=0

EasyGrep有许多选项可以控制它的行为方式。输入:GrepOptions作为所有这些的列表。