How do I search forward for text in Vim?
Answer
/{pattern}
Explanation
The / command initiates a forward search in the file. Type your search term and press Enter to find the first match after the cursor.
How it works
- Press
/to open the search prompt at the bottom - Type your search pattern
- Press
<CR>(Enter) to execute the search - The cursor jumps to the first match
Example
The quick brown fox jumps over the lazy dog
Typing /fox<CR> moves the cursor to fox.
Tips
nfinds the next match in the same directionNfinds the next match in the opposite direction/wraps around the end of the file by default:set nowrapscandisables wrap-around searching