Chapter 7. Advanced Editing

This chapter introduces you to some of the more advanced capabilities of vi and Vim and the ex editor underlying them. You should be reasonably familiar with the material presented in the earlier chapters of this book before you start working with the concepts presented here.

As we did in earlier chapters, this chapter presents facilities common to all versions of vi, but in the context of Vim. When you see “vi” by itself here, you can generally read it as “vi and Vim.”

We have divided this chapter into five parts. The first part discusses a number of ways to set options that allow you to customize your editing environment. You’ll learn how to use the set command and how to create a number of different editing environments using .exrc files.

The second part discusses how you can execute Unix commands from within the editor, and how you can use the editor to filter text through Unix commands.

The third part discusses various ways to save long sequences of commands by reducing them to abbreviations, or even to commands that use only one keystroke (this is called mapping keys). It also includes a section on @-functions, which allow you to store command sequences in a register.

The fourth part discusses the use of ex scripts from the Unix command line or from within shell scripts. Scripting provides a powerful way to make repetitive edits.

The fifth part discusses some features that are especially useful to programmers. There are options that control line ...

Get Learning the vi and Vim Editors, 8th Edition 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.