Vim Cheatsheet — Most Used
Commands
Modes
| Normal |
Esc |
Navigate, run commands |
| Insert |
i |
Type text |
| Visual |
v |
Select text |
Open & Exit
vim filename.txt # open file
:w |
Save |
:q |
Quit |
:wq |
Save and quit |
:q! |
Quit without saving |
Navigation (Normal Mode)
h j k l |
Left, down, up, right |
gg |
Go to top of file |
G |
Go to bottom of file |
0 |
Start of line |
$ |
End of line |
Ctrl+d |
Scroll down half page |
Ctrl+u |
Scroll up half page |
Editing
i |
Insert before cursor |
a |
Insert after cursor |
o |
New line below |
O |
New line above |
dd |
Delete line |
yy |
Copy line |
p |
Paste |
u |
Undo |
Ctrl+r |
Redo |
Search & Replace
/word |
Search forward |
n |
Next result |
N |
Previous result |
:%s/old/new/g |
Replace all occurrences |
Visual Mode (Select Text)
v |
Select characters |
V |
Select whole lines |
d |
Delete selected |
y |
Copy selected |
Tip: Press Esc whenever you’re lost —
it always takes you back to Normal mode.