Reputation: 29421
I can search word in vim with /word
. How can I search only for word
, excluding searches for word1
and word2
?
Upvotes: 214
Views: 273370
Reputation: 742
Basic search (once you have opened the file in vim
) using vim
:
-Hit ESC
on your computer keyboard
-Hit the forward slash symbol on your keyboard /
-Type the word or symbol you intend to search; for example, to search for the term "rbmq" type /rbmq
-Hit Enter
-Hit n to search forward (moving towards the end of the file) and N to search backward (moving towards the beginning of the file)
Upvotes: 3
Reputation: 1585
For basic searching:
Some variables you might want to set:
Upvotes: 36
Reputation: 511
If you are working in Ubuntu,follow the steps:
/
and type word to search*
key#
key Upvotes: 37
Reputation: 1349
Upvotes: 99
Reputation: 127608
like this:
/\<word\>
\<
means beginning of a word, and \>
means the end of a word,
Adding @Roe's comment:
VIM provides a shortcut for this. If you already have word on screen and you want to find other instances of it, you can put the cursor on the word and press '*'
to search forward in the file or '#'
to search backwards.
Upvotes: 286