3 years ago
Frequently I want to find or move between usages of a particular word or term across all the files I'm working with.
This lets you grep/vimgrep across all the open/saved buffers, which populates the quickfix list. The first mapping lets you type the search, the second executes the search for the word under the cursor.
How does this work?
bufdo does the command iteratively over each buffer.
bufdo, we need to incrementally build up the quickfix list, which is why we use
vimgrepadd instead of
vimgrep (this also works with
Because we are appending, we need to clear the quickfix list - this is
nnoremap <leader>s :cex <CR> :silent bufdo vimgrepadd // % <Left><Left><Left> nnoremap <leader>a :cex <CR> :silent bufdo vimgrepadd /<C-r><C-w>/ %<CR>