Using * when the cursor is on a word theWord
, vim directly jumps to the next appearance of exactly that word, i.e. performes /\<theWord\>
.
Questions:
Is there a way to add another word otherWord
to the search, when the cursor is on this other word, such that one performes /\<theWord\>\|\<otherWord\>
?
Try something like:
:let @/=@/.'\|\<'.expand("<cword>").'\>'
this appends to the previous search pattern the current word under the cursor) with some delimiters (\|
and the word boundaries...)nnoremap <F4> :let @/.='\\|\<'.expand("<cword>").'\>'<CR>