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.
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 ...