Searching with Vim
Using the search functionality in your text editor is often the fastest way to get where you want — especially if the document you’re working in is large.
Vim has an extremely powerful search function that also supports a rich regular expression language. In this lesson, we’re going to explore how to actually perform searches. We’re going to leave the regular expression stuff for a later lesson, because there’s a lot to cover!
There are two ways that you can start a search in Vim: using either the / or ? key in normal mode. Both of these keys enter the search prompt, where you can type in a regular expression or a literal string — the difference is that / starts searching forward and ? starts searching backwards.
In both cases, when you’re done, hit the enter key to initiate your search and return to normal mode.
Work through the checklist below. The editor is pre-populated with 100,000 lines containing the word HAYSTACK — far too many to scroll through, so you have to search to find the only line containing the word NEEDLE. Once you’ve found it, search backwards to hop to the nearest HAYSTACK above you.