vi
CAUTION: This chart is not guaranteed to be accurate. Use at your own risk.
Don't know what "vi" is? Consider yourself lucky and return to my main page. :-)
Abbreviations:
- c.c. = current character
- c.l. = current line
- ^ = [Ctrl]
- n = a number
- c = a character
Use set smd (or :set showmode on some systems) to activate the append/input/command mode signal.
For most Command Mode commands, prefixing the command with a number (n) will execute that command n times.
Entering Insert Mode ([Esc] exits) |
---|
i insert @ c.c. |
a append right of c.c. |
o new line following c.l. |
I insert @ beginning of c.l. |
A append @ end of c.l. |
O new line before c.l. |
|
Cursor Movement |
---|
^B scroll up 1 page (Back) |
^U scroll up ½ page (Up) |
^D scroll down ½ page (Down) |
^F scroll down 1 page (Forward) |
0 cursor to beginning of c.l. |
$ cursor to end of c.l. |
w cursor to beginning of next word |
nl cursor to beginning of col. n |
nG cursor to beginning of line n |
G cursor to last line in file |
[Enter] cursor to beginning of next line |
|
Copying Text |
---|
y copy c.c. |
yn copy n characters¹ |
yw copy current word |
yy copy c.l. |
y$ copy to end of c.l. |
y) copy to end of sentence |
y} copy to end of paragraph |
Y copy c.l. |
|
¹Note that "yanking" text works weird. If you type y5, then [down arrow], it yanks 6 lines.
Use [right arrow] after the command to be fairly safe.
|
Pasting/Deleting Text |
---|
p paste to right of cursor |
x delete character under cursor |
dd delete c.l. |
D delete to end of c.l. |
:D delete c.l. (same as dd) |
:D$ delete to end of c.l. (same as D) |
:u undo delete |
|
Searching & Replacing |
---|
/string search forward for string |
?string search backward for string |
:%s/old/new/g global replace |
/ repeat forward find |
? repeat find backward |
n repeat find (same direction) |
N repeat find (reverse direction) |
:g/string/d delete lines containing string |
rc replace c.c. with c |
~ reverse upper/lower case |
:s/old/new/n replace n times |
|
Quitting & Saving |
---|
:q quit |
:q! quit without saving |
:w save |
:w filename save as filename |
:x save and quit |
ZZ save and quit |
:wq save and quit |
|
Copyright ©2001 Cheryl M. Sharpe (1/7/01)
In case you're wondering, this page was created mostly with Microsoft's "Notepad," but some touch-ups were done with vi.
...well, sorta. :-)