vimtricks.wiki Concise Vim tricks, one at a time.

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
  • grepprg defines which external command Vim executes for :grep
  • rg --vimgrep emits file:line:column:text, which quickfix parses cleanly
  • --smart-case makes searches case-insensitive unless uppercase appears in the pattern
  • --hidden includes dotfiles and hidden directories in results
  • --glob !.git excludes 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 vimrc or init.vim for persistence
  • Pair with :set grepformat=%f:%l:%c:%m if your environment overrides defaults

Next

How do I zero-pad every number in a line using a Vim substitute expression?