How to search the current word in all opened tabs in Vim?
It's actually the default behaviour although it may be hard to notice: try *
then change to another tab and use n
ans N
in command mode to jump forward and backward between search hits.
This may make more sense if first you turn highlighting on for all hits:
:set hlsearch
:bufdo vimgrepadd yoursearchterm % | copen
I don't have an exact solution for your problem, hopefully a better answer than mine will come up. But this is how I tackled the problem of finding a word in all buffers.
" enables to search in all open buffers with :Search <pattern>
command! -nargs=1 Search call setqflist([]) | silent bufdo grepadd! <args> %
nnoremap <left> :cprev<cr>zvzz
nnoremap <right> :cnext<cr>zvzz
The first line creates a command Search
with the search pattern as argument, which writes the results in a quickfix list. The two other lines map the (at least for me) useless arrow keys to something useful; they are mapped to jump to the next/previous Search or to the next/previous compile error, etc., they simply step throu the quickfix list. You can use this as follows:
:Search foobar
<right>
<right>
…