search under cursor in vim
here’s a vim tip i’ve learned recently
let’s say you want to search other occurences of a keyword
in that case, just press *
and then n to move forward and N (that’s capital N) to move backwards
keep in mind vim’s definition of keyword, ie spider-man is considered 2 words
in that (and other more advanced) cases, you may want to use visual selection
unfortunately it’s not as straightforward as we would want, but here’s how it is done:
- press
vto enter visual mode, - select the desired text
yto copy to register"/to enter searchCtrl + r+"to paste from register"
keep in mind the query search is considered a string
so let’s say you have a file with
| |
searching for spider-.* will naturally highlight all lines

source
:help *:help iskeyword- How to search for selected text in Vim? - Super User