Searching Within Vi

- - posted in Uncategorized

To search for the next occurence of the text ‘maybe’ from the current cursor position, type:

/maybe<br />

Search backward from the current position by using ? instead of / in the command.

Once you have searched for something, you can find the next occurrence by pressing nor the previous occurrence with N.

Searching in vi/vim is enhanced with regular expressions. For example, to find the next occurence of the text ‘Total’ that occurs at the beginning of a line, use:

/^Total

Thanks to this source.