How do I search a project without overwriting the global quickfix list?
Answer
:lvimgrep /pattern/gj **/*.js | lopen
Explanation
When you already rely on the global quickfix list for compiler errors or another search, running :vimgrep can wipe that context. :lvimgrep solves this by writing results to a window-local location list instead, so each window can keep its own independent search set. This is especially useful during parallel refactors where one window tracks diagnostics and another tracks ad-hoc matches.
How it works
:lvimgrep /pattern/gj **/*.jsruns a recursive grep and stores matches in the current window's location listgfinds all matches per line (not only the first)jprevents jumping to the first hit immediately, preserving your current cursor location| lopenopens the location list so you can review hits before changing anything
Example
Suppose quickfix still contains test failures and you need a focused search for deprecated API calls.
:lvimgrep /oldApiCall/gj **/*.js | lopen
Now navigate with :lnext and :lprev without touching global quickfix entries.
Tips
- Use
:lwindowinstead of:lopenif you only want the list window when matches exist :ldoapplies commands per location entry, similar to:cdofor quickfix- Keep one split for quickfix (
:copen) and another for location-list workflows to separate tasks cleanly