防止vim grep打开第一个匹配文件 [英] prevent vim grep from opening first matching file

查看:111
本文介绍了防止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不是一个选项 - 它太慢了。

解决方案 blockquote>

就像:make,但是使用'grepprg'而不是'makeprg'和'grepformat'而不是'errorformat'。


:help:make


如果没有给出[!],那么第一个错误会跳到。

blockquote>

所以::grep!


So, fiddling with the EasyGrep.vim plugin, trying to get it into a state that suits me. I am using it for recursive searching of a Rails project. Ive almost got it how I want it, this is an example of the grep command my modified EasyGrep executes:

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

Which finds the word under the cursor, and opens the search results in quicklist.

Only problem is, :grep seems to automatically open the file containing the first match into the current buffer, which I do not want it to do, because then I lose the file I was just looking at.

Anyone know how I can prevent this behavior? Or, at least a hacky workaround that reopens the file I was searching from?

:vimgrep is not an option - its far too slow.

解决方案

From :help :grep:

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

From :help :make:

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

So: :grep!

这篇关于防止vim grep打开第一个匹配文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆