Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent vim grep from opening first matching file

Tags:

grep

vim

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.

like image 752
dalyons Avatar asked Apr 19 '11 23:04

dalyons


1 Answers

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!

like image 153
Rein Henrichs Avatar answered Sep 28 '22 03:09

Rein Henrichs