How do I configure :grep to use ripgrep with quickfix output and include hidden files?
Answer
:set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --glob\ !.git
Explanation
Vim's :grep becomes much more useful when grepprg is tuned for ripgrep and quickfix-compatible output. This configuration makes searches faster on large repos, respects case smartly, and includes hidden files while still skipping .git. It keeps your search workflow inside Vim instead of shelling out manually for every query.
How it works
:set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --glob\ !.git
grepprgdefines which external command Vim executes for:greprg --vimgrepemitsfile:line:column:text, which quickfix parses cleanly--smart-casemakes searches case-insensitive unless uppercase appears in the pattern--hiddenincludes dotfiles and hidden directories in results--glob !.gitexcludes the Git metadata directory so results stay relevant and fast
Once set, a command like :grep TODO fills quickfix using this ripgrep profile. You can then navigate matches with :copen, :cnext, and :cprev without leaving your editor flow.
Example
Set the option once:
:set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --glob\ !.git
Then run:
:grep userId
:copen
You get a jumpable quickfix list including hidden config files, but not noisy .git internals.
Tips
- Put the same value in your
vimrcorinit.vimfor persistence - Pair with
:set grepformat=%f:%l:%c:%mif your environment overrides defaults