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
To find a character string, type / followed by the string you want to search for, and then press Return. vi positions the cursor at the next occurrence of the string. For example, to find the string “meta,” type /meta followed by Return.
Text Search Another way to find an exact word is to place the cursor on a word, enter command mode, and type an asterisk to find more occurrences of that word. Again, use n and N to repeat the search.
Perform a basic search in Vim If you are in insert mode, simply press the 'ESC' key. To perform a basic search of the string or text that you want, move to the beginning of the file and simply press the forward-slash ( / ) key. Then type the search string and press ENTER on the keyboard to start searching.
Go to search mode i.e. type '/' and then type \v followed by the words you want to search separated by '|' (pipe). Go to search mode and type the words you want to search separated by '\|'.
Try instead:
/\<word\>
the \<
and \>
match word boundaries.
/\<sachin\>
\<
is the beginning of word, and \>
is the end of word marker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With