How do I fill quickfix from ripgrep output without leaving Vim?
Answer
:cexpr system('rg --vimgrep "TODO"')
Explanation
When you already know you want an external search tool, :cexpr lets you import results directly into quickfix without opening a terminal buffer or shelling out manually. Pairing it with rg --vimgrep gives fast, structured matches (file, line, column, text) that quickfix can navigate immediately. This is especially useful in large repositories where built-in :vimgrep is slower or when you want ripgrep's ignore-file behavior.
How it works
:cexprevaluates an expression and treats the result as quickfix inputsystem('...')runs a shell command and returns its stdout as a stringrg --vimgrep "TODO"emits lines in a Vim-friendly format (file:line:col:text)
After running it, use :copen to inspect results, :cnext/:cprev to move, or :cdo for batch edits.
Example
src/app.js:42:7:// TODO: split this function
src/db/query.sql:8:1:-- TODO optimize index usage
Then inside Vim:
:copen
:cnext
You jump through actionable TODOs without context switching.
Tips
- If your
errorformatwas customized, ensure it still matches ripgrep vimgrep output - Swap
"TODO"for any pattern, e.g."FIXME|HACK"with-eflags - Add path scopes (like
src/) in the ripgrep command to reduce noise