Review of vi Operations
This section provides a review of the following:
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 to a different position in the file
Invoke ex commands
Invoke a Unix shell
Save the current version of the file
Exit vi
Insert Mode
In insert mode, you can enter new text in the file. You normally enter
insert mode with the i
command.
Press the ESC key to exit insert
mode and return to command mode. The full list of commands that
enter insert mode is provided later in the section Insert Commands.
Syntax of vi Commands
In vi, editing commands have the following general form:
[n
]operator
[m
]motion
The basic editing operators are:
| Begin a change. |
| Begin a deletion. |
| Begin a yank (or copy). |
If the current line is the object of the operation, the
motion is the same as the operator: cc
, dd
,
yy
. Otherwise, the editing
operators act on objects specified by cursor-movement commands or
pattern-matching commands. (For example, cf.
changes up to the next period.)
n and m are the number of
times the operation is performed, or the number of objects the
operation is performed on. If both n and
m are specified, the effect is
n ×
m.
An object of operation can be any of the following text blocks:
- word
Includes characters up to a whitespace character (space or tab) or punctuation mark. A capitalized object is a variant form that recognizes only ...
Get Learning the vi and Vim Editors, 7th 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.