Searching and replacing in vi

One of vi's better features is that it allows you to search and replace throughout entire files. As shown in the next sections, you can just find a specific string of text (a regular expression, in UNIX lingo) or you can find the text and replace it with other text, as in Figure 4.13.

Figure 4.13. Searching for and replacing text in vi is quick and reliable.

To find a string of text in vi:

1.
vi hairyspiders
For starters, access vi and a specific file.
2.
							/spider
Enter command mode, then type / followed by the ...

Get Unix: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.