From the course: Learning vi
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Searching text
Like any text editor, VI gives you the ability to search for text. The basic search command is slash. You type a slash in command mode, and you'll see a slash prompt at the bottom of the screen. You type some text to search for and hit Return. It then searches forward in the file for the next occurrence of the text that you searched for. Alternatively, you can begin a search with a question mark, in which case, it searches backward for the text that you specify. Once you've performed a search, you can use the N command to search for the same text again in the same direction. Or you can use the command Shift+N to repeat the same search in the opposite direction. So if you begin a search with a slash, then hitting N will show you the next one and the next one and so on. Whereas, hitting Shift+N goes backwards. But if you began the search with a question mark, hitting N continues to search backwards, whereas Shift+N actually searches forward. I'll demonstrate these. We'll use our Duke of…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.