TEXT MODE |
|
|
a |
Append after letter |
|
A |
Append after line |
|
i |
Insert before letter |
|
I |
Insert before line |
|
o |
Open line below (insert mode) |
|
O |
Open line above (insert mode) |
TEXT MODE ERASING |
|
|
<Backspace> |
Erase one character |
|
<Ctl>h |
Erase one character |
|
<Ctl>w |
Erase one word |
|
@ |
Erase one line |
EXITING TEXT MODE |
|
|
<Esc> |
Exiting text mode |
MOVING AROUND |
|
|
h |
Left |
|
l |
Right |
|
j |
Down |
|
k |
Up |
|
<Return> |
Advance one line |
|
b |
Beginning of the current word |
|
e |
End of current word |
|
0 |
Beginning of current line |
|
^ |
Beginning of current line |
|
$ |
End of current line |
|
1G |
Beginning of current file |
|
:1 |
Beginning of current file |
|
G$ |
End of current file |
|
#G |
Go to line # |
|
:# |
Go to line # |
|
<Ctl>f |
Page up |
|
<Ctl>b |
Page down |
|
<Ctl>d |
Forward ½ page |
|
<Ctl>u |
Backward ½ page |
EDITING |
|
|
r |
Replace one character |
|
R |
Replace to end (insert mode) |
|
x |
Erase one character |
|
dd |
Delete one line |
|
dw |
Delete one word |
|
c |
Change text here to end of line |
|
cw |
Change one word |
|
yy |
Yank one line |
|
p |
Put line below |
|
P |
Put line above |
|
u |
Undo command |
|
U |
Undo all commands on that line |
|
. |
Repeat last command |
|
J |
Join two lines |
SEARCHING |
|
|
/name |
Search for next occur of name |
|
?name |
Search for previous occur of name |
|
n |
Go to the next occurrence in search |
|
% |
Find matching }, ] or ) |
SEARCH AND REPLACE |
|
|
:g |
Global |
|
:g/pt/ |
Global search for all lines with pt |
|
:s/pt/rp |
Sub first occur pt with rp (1 line) |
|
:s/pt/rp/g |
Sub pt with rp for all occur(1 line) |
|
:g/pt/s//rp/g |
Global sub of pt with rp (all in file) |
SAVING AND EXITING |
|
|
:r |
Read in another file |
|
:w |
Write file |
|
:w file |
Write file to another file |
|
:wq |
Write and quit |
|
ZZ |
Same as :wq |
|
:q |
Quit |
|
:q! |
Quit and abandon changes |
SHELL INTERFACE |
|
|
:!cmd |
Go to shell and execute command |
|
!sh |
Fo to shell for several commands |
|
:r!cmd |
Execute command and put output in vi |
|
:r!file |
Execute the file |