How to do whole-word search similar to "grep -w" in Vim
\<bar\>
matches bar
but neither foobar
nor barbaz
nor foobarbaz
.
Use it like this in a substitution:
:s/\<bar\>/baz
Use it like this to list all the lines containing the whole word bar
:
:g/\<bar\>
:h pattern
is a good read.
You want /\<yourword\>
.
If your cursor is on a word, then you can press *
and it will do a word-only search for the word under the cursor.