Search for word under cursor

Instead of pressing * to fill the search pattern copy the word directly to command line using CTRL-R CTRL-W. I.e.:

:.,+5s/<C-R><C-W>/bar/g

Is there a way to search for the current word without having the cursor moving away?

The whole point of *, #, and friends is made pretty clear in the documentation: "search forward" or "search backward". Your problem seems to be that you use those commands not for their intended purpose but for a side effect, presumably highlighting all occurrences of the word under the cursor.

Since there's no built-in command for that you will need to map it yourself:

nnoremap <key> *``
nnoremap <anotherkey> #``
...

Tags:

Vim