In Vim or vi text editor, you can search for a word in the following ways:
- Normal mode search:
- Press the
/
key to initiate a forward search. - Type the word you want to search for.
- Press
Enter
to initiate the search. - Press
n
to move to the next match, orN
to move to the previous match.
- Visual mode search:
- Highlight the text you want to search for in visual mode.
- Press
*
to initiate a forward search for the selected text. - Press
#
to initiate a backward search for the selected text. - Press
n
to move to the next match, orN
to move to the previous match.
Note: In both cases, you can use ?
instead of /
to initiate a backward search.