Global and Partial Text Substitution

vi has a built-in colon command g to globally search for and replace all occurrences of one pattern with another. You learned how to use sed and awk in the previous chapters; however, this next section shows you how to use other UNIX commands to modify your whole file or any part of your file. After you learn this technique, you can do much more than the global g command can do.

Substituting Regular Expressions Patterns Throughout the File

How to globally replace a pattern in your document

Why Not Use the Built-in vi Replacement Commands?

vi supports two built-in colon commands: g (global) and s (substitution, which aren’t covered in this book because calling the external sed command fills the same function ...

Get Practical UNIX now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.