8

Please tell me how to search for a specifig word if the file is opened in VI Editor. I know we can do it by using /word_to_be_search but it will not do the exact search for the word.

Example
/sachin will searches for sachin_server, sachin_client and not only sachin

3 Answers 3

20

Try instead:

/\<word\>

the \< and \> match word boundaries.

1
  • 1
    ...and in Vim, you can ":set iskeyword" to define the characters considered part of a "word"
    – Nick Dixon
    Commented Dec 16, 2009 at 12:50
4
/\<sachin\>

\< is the beginning of word, and \> is the end of word marker.

-1

do this:

/\

1
  • It wont work as it will only search for words starting with the pattern to be searched
    – Sachin
    Commented Dec 16, 2009 at 13:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.