This is a cheatcode|cheatsheet of some commands or tricks of vim/vi.
Command | Description | Similar commands |
---|---|---|
i |
Insert mode | |
Esc |
Command mode | |
:w |
Write or save | |
:q |
Exit | |
:q! |
Exit with discard changes | |
:wq |
Save and Exit | :x , ZZ |
Command | Description | Similar commands |
---|---|---|
h |
Move cursor to left | left arrow key |
j |
Move cursor to down | down arrow key |
k |
Move cursor to up | up arrow key |
l |
Move cursor to right | right arrow key |
$ |
Move cursor to end of line | |
0 |
Move cursor to first of line | |
w |
Forward cursor word by word | W |
b |
Backward cursor word by word | B |
:<num> |
Move cursor to line | |
G |
Move cursor to last line of document | |
Ctrl+f |
Page Down | |
Ctrl+b |
Page up |
Command | Description | Similar commands |
---|---|---|
x |
Delete char under cursor like as delete | |
X |
Delete char before cursor like as backspace | |
dw |
Delete word | |
D |
Clean line content | |
dd |
Delete line | |
<num>dd |
Delete lines | |
dG |
Delete entire line below |
Command | Description | Similar commands |
---|---|---|
r |
Replace char with new char | |
R |
Replace mode ( Replace inserted chars until ESC pressed ) |
Command | Description | Similar commands |
---|---|---|
:undo |
Undo | u |
:redo |
Redo | Ctrl+r |
U |
Undo all changes |
Command | Description | Similar commands |
---|---|---|
yy |
Copy line | |
p |
Paste below line | |
P |
Paste after line | |
<num>yy |
Copy lines | |
v |
Visual mode ( You can select and Copy with y or Cut d ) |
Command | Description | Similar commands |
---|---|---|
/<string> |
Forward Search about | |
?<string> |
Backward Search about | |
:s/<lookup>/<replacement> |
Search & Replacement on nearest line just one time | |
:%s/<lookup>/<replacement> |
Search & Replacement on multi lines just one time | |
:s/<lookup>/<replacement>/g |
Search & Replacement on nearest line | |
:%s/<lookup>/<replacement>/g |
Search & Replacement entire of document |