vimtricks.wiki Concise Vim tricks, one at a time.

How do I search a project but keep results window-local using the location list instead of quickfix?

Answer

:lvimgrep /TODO/j **/* | lopen\<CR>

Explanation

When you are working in multiple windows, quickfix can become noisy because it is shared globally across the editor session. :lvimgrep gives you a window-local alternative: the location list. This is a strong fit for focused refactors where each window tracks a different task, such as one list for TODO cleanup and another for API deprecations.

How it works

:lvimgrep /TODO/j **/* | lopen
  • :lvimgrep runs vimgrep but stores matches in the location list for the current window
  • /TODO/ is the search pattern (replace with your own regex)
  • j keeps searching even if a file has no match
  • **/* expands recursively through files (subject to your shell and Vim settings)
  • | lopen opens the location-list window immediately so you can jump through results

Example

Suppose your project contains TODO markers spread across services and tests. Running :lvimgrep /TODO/j **/* | lopen in one window creates a local result set there. In another window, you can run a different :lvimgrep query without overwriting the first list.

window A loclist: TODO cleanup
window B loclist: deprecated API calls

Tips

  • Use :lnext, :lprev, and :ll to navigate location-list results quickly
  • Use :lwindow instead of :lopen if you only want the list window when there are matches
  • For very large repos, narrow the file glob to a subtree (for example src/**/*) to keep searches fast

Next

How do I make Ctrl-A increment 007 as decimal instead of octal?