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 whitespace. |
|
sentence |
Up to |
|
paragraph |
Up to the next blank line or
paragraph macro defined by the |
|
section |
Up to the next nroff/troff section heading defined by
the |
|
motion |
Up to the character or other text object as specified by a motion specifier, including pattern searches. |
Examples
|
|
Change the next two words. |
|
|
Delete up to next paragraph. |
|
|
Delete back to beginning of line. |
|
|
Copy the next five lines. |
|
|
Copy up to the next section. |
|
|
Change to the end of the edit buffer. |
More commands and examples may be found in the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access