Vimgrep and immediately open quickfix in split mode

Not sure if this was asked, so I cannot find it.

I want to run vimgrep to search for a template. I'm doing it. And when he finds a match, he immediately opens the first file.

This is not what I want. I want the quickfix window to be open in the horizontal panel so that I can navigate the matches. This is my team invimrc

command! -nargs=1 Ngrep vimgrep "<args>" **/*.md

+4
source share
1 answer

Add this piece to his vimrcto tell Vim to automatically discover the location / quickfix window after the :make, :grep, :lvimgrepand friends, if there is a valid location / error:

augroup myvimrc
    autocmd!
    autocmd QuickFixCmdPost [^l]* cwindow
    autocmd QuickFixCmdPost l*    lwindow
augroup END

If you do not want Vim to go to the first match, use the flag j:

:vimgrep /foo/j **/*.md

:help :vimgrep.

+11

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


All Articles