Emacs has a feature named “occur” that lists the lines in the current buffer that match a given regexp. I’ve created the equivalent feature in Vim:
nmap g/ :vimgrep /<C-R>//j %<CR>\|:cw<CR>
With this mapped, here’s how you’d use it:
- Search for you’re looking for with
g/to open the quickfix list containing the matched lines.
- Navigate to the line you’re interested in and press
You could create a function to combine the steps; taking the query as input, running the search, and opening the quickfix list. But I prefer having them separate.