How do I build a location list of TODO matches across a project?
Answer
:lvimgrep /\<TODO\>/gj **/* | lopen
Explanation
If you want project-wide search results without polluting the global quickfix list, use a location list. :lvimgrep gives each window its own result set, which is ideal when you are investigating TODOs in one split while keeping build errors or other quickfix data untouched. This keeps multi-window workflows predictable and avoids context switching.
How it works
:lvimgrep /\<TODO\>/gj **/*searches recursively for whole-wordTODO\<and\>enforce word boundaries so you do not match longer tokens accidentallygfinds all matches per file, not just the firstjsuppresses "pattern not found" noise for cleaner runs**/*expands recursively through files under the current working directory| lopenopens the location-list window for the current window
The key distinction is scope: location lists are window-local, quickfix is global. That means you can run multiple focused searches in different windows without overwriting each other's result context.
Example
Given files containing:
TODO: refactor parser
TODO: add retry logic
Run:
:lvimgrep /\<TODO\>/gj **/* | lopen
You get a navigable list of TODO hits for that window, and can jump through them with location-list motions like :lnext and :lprev.
Tips
- Use
:lclosewhen you want to hide the list but keep results - Use
:lcdper window before:lvimgrepwhen each split targets a different subtree