:vimgrep
can take multiple file globs. In simple cases that means you can potentially search only places you want instead of excluding (think white-listing vs black-listing)
:vimgrep /foo/ bar/** baz/**
Often :vimgrep
isn't up to the task from performance and/or complex searching perspective. Instead you can use Vim's :grep
command to use an external command like grep
, ag
, rg
, ack
, or git-grep
by setting 'grepprg'
and 'grepformat'
.
An example of using ripgrep to exclude zxy
and only search in c
files for pattern, pat
:
$ rg -g '!zyx' -t c 'pat'
With a few vimrc
settings you use :grep
:
:set grepprg=rg\ --vimgrep
:set grepformat^=%f:%l:%c:%m
Inside Vim you can now use ripgrep and :grep
together:
:grep -g '!zyx' -t c 'pat'
Of course as D. Ben Knoble said above, you can always use :Cfilter
to filter/exclude from the quickfix after the fact