How do I search across files with lvimgrep and keep results in a window-local location list?
Answer
:lvimgrep /pattern/j **/* | lopen
Explanation
Quickfix is great, but it is global. In split-heavy sessions you often want per-window search results so one task does not overwrite another. :lvimgrep gives you that by populating the location list for the current window, and :lopen shows it immediately. This is a strong pattern when you run parallel investigations in different windows.
How it works
:lvimgrep /pattern/j **/*searches files recursively and stores matches in the current window's location list- The
jflag includes multiple matches per file instead of only the first | lopenopens the location list window right away- Navigation uses location-list commands (
:lnext,:lprev,:lfirst,:llast) without touching global quickfix state
Example
From your project root, run:
:lvimgrep /TODO\\|FIXME/j **/*.lua | lopen
Your location list fills with matching lines in Lua files:
lua/server/init.lua:42: TODO: split router setup
lua/ui/panel.lua:10: FIXME: debounce redraw
You can inspect these with :lnext and keep your main quickfix list intact for a different task.
Tips
- Prefer
:lgrep/:lvimgrepwhen context is local to one window - Use
:lwindowinstead of:lopenif you only want the window when there are entries - If your glob is expensive, narrow it (
**/*.go,src/**/*.ts) to keep searches fast