Chapter 11. The vi Editor
vi is the classic screen-editing program for Unix. A number of enhanced versions exist, including nvi, vim, vile, and elvis. On Linux, the vi command is usually a link to one of these programs.
vi is based on an older line editor called ex. Powerful editing capabilities can be invoked within vi by pressing the colon (:), entering an ex command, and pressing the Return key. Furthermore, you can place ex commands in a startup file called ~/.exrc, which vi reads at the beginning of your editing session. Because ex commands are still an important part of vi, they also are described in this chapter. On Linux, ex is sometimes called hex.
This chapter, which essentially covers standard vi but reflects nvi extensions, presents the following topics:
Review of vi operations
vi command-line options
ex command-line options
Movement commands
Edit commands
Saving and exiting
Accessing multiple files
Interacting with the shell
Macros
Miscellaneous commands
Alphabetical list of keys in command mode
Syntax of ex commands
Alphabetical summary of ex commands
vi configuration (setting options at startup)
For more information, see the O’Reilly book Learning the vi Editor by Linda Lamb and Arnold Robbins.
Review of vi Operations
This section provides a review of the following:
Command-line options
vi modes
Syntax of vi commands
Status-line commands
Command Mode
Once the file is opened, you are in command mode. From command mode, you can:
Invoke insert mode
Issue editing commands
Move the cursor ...
Get Linux in a Nutshell, Third 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.