2.6. Review of Basic vi Commands
Table 2.1
presents a few of the commands you can perform by combining the
commands c, d, and y with various text objects.
The last two rows show additional commands for editing.
Table 2.2 and Table 2.3
list some other basic commands. Table 2.4
summarizes the rest of the commands described in this chapter.
Table 2.1. Edit Commands
Text Object |
Change |
Delete |
Copy |
1 word |
cw |
dw |
yw |
2 words, not counting punctuation |
2cW or c2W |
2dW or d2W |
2yW or y2W |
3 words back |
3cb or c3b |
3db or d3b |
3yb or y3b |
1 line |
cc |
dd |
yy or Y |
To end of line |
c$ or C |
d$ or D |
y$ |
To beginning of line |
c0 |
d0 |
y0 |
Single character |
r |
x or X |
yl or yh |
Five characters |
5s |
5x |
5yl |
Table 2.2. Movement
Table 2.3. Other Operations
Operations |
Commands |
Place text from buffer |
P or p |
Start vi, open file if specified |
vi file |
Save edits, quit file |
ZZ |
No saving of edits, quit file |
:q! |
Table 2.4. Text Creation and Manipulation Commands
Editing Action |
Command |
Insert text at current position |
i |
Insert text at beginning of line |
I |
Append text at current position |
a |
Append text at beginning of line |
A |
Open new line below cursor for new text |
o |
Open new line above cursor for new text |
O |
Delete line and substitute text |
S |
Overstrike existing characters with new text |
R |
Join current and next line |
J |
Toggle case |
~ |
Repeat last action |
. |
Undo last change |
u |
Restore line to original state |
U |
You can get by in vi using only the commands
listed in these tables.
However, in order to harness the real power of
vi (and increase your
own productivity), you will need more tools.
The following chapters describe those tools.
| | | 2.5. Joining Two Lines with J | | 3. Moving Around
in a Hurry |
Copyright © 2003 O'Reilly & Associates. All rights reserved.
|
|