Prevent vim grep from opening the first matching file

So, messing with the EasyGrep.vim plugin, trying to bring it into a state that suits me. I use it to recursively search for a Rails project. Ive almost got this, as I want it, this is an example grep command that my modified EasyGrep executed:

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

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

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

Does anyone know how I can prevent this behavior? Or at least a hacky workaround that opens the file I was looking for?

: vimgrep is not an option - its too slow.

+6
source share
2 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!

+17
source

Add this to your .vimrc:

  let g:EasyGrepOpenWindowOnMatch=0 

EasyGrep has many options that can control how they behave. Type :GrepOptions to list all of these.

0
source

Source: https://habr.com/ru/post/886279/


All Articles