How do I use the location list for per-window navigation?
Answer
:lnext and :lprev
Explanation
The location list is a per-window alternative to the quickfix list. Each window can have its own location list, making it ideal for window-specific search results.
How it works
:lnext(or:lne) moves to the next location list entry:lprev(or:lp) moves to the previous entry:lopenopens the location list window:lvimgreppopulates it with search results
Example
:lvimgrep /TODO/ %
:lopen
:lnext
:lnext
This searches the current file for TODO comments and navigates through them.
Tips
- Each window has its own location list; the quickfix list is global
:lfirstand:llastjump to the first and last entries:llistshows all entries- Useful when you want different search results in different splits