How do I recursively search files and load matches into quickfix in one command?
Answer
:vimgrep /\<TODO\>/gj **/*.lua | copen
Explanation
When you want a project-wide TODO pass without leaving Vim, :vimgrep plus quickfix is a strong built-in workflow. It gives you a navigable result list you can jump through with :cnext and :cprev, and you can batch-edit from that list later with :cdo. This is especially useful during refactors where you need a scoped review across a language subset.
How it works
:vimgrep /\<TODO\>/gj **/*.luasearches recursively in*.luafiles\<and\>anchor a whole-word match so partial tokens are skippedgcollects all matches per file instead of stopping at the firstjavoids jumping immediately to the first hit, preserving cursor context| copenopens quickfix so results are visible right away
Example
Before running:
lua/app/init.lua -- TODO: split setup logic
lua/ui/panel.lua -- TODO: cache state
lua/core/router.lua -- TODO: handle retry path
After running, quickfix contains each match location and you can iterate quickly:
:cnext
:cnext
:cprev
Tips
- Replace
**/*.luawith the subset you actually want to inspect to keep results actionable. - Use
:vimgrepaddwhen you want to append another pattern without clearing the current quickfix list.