Vim cheat sheet
Vim has modes. Press Esc to return to normal mode, where these keys work.
Modes
i- Insert before the cursor
a- Insert after the cursor
o- Open a new line below and insert
v- Visual mode: select text
Esc- Back to normal mode
Save and exit
:w- Save
:q- Quit
:wq or ZZ- Save and quit
:q!- Quit without saving
Move
h j k l- Left, down, up, right
w b- Next word, previous word
0 $- Start and end of the line
gg G- Top and bottom of the file
:42- Go to line 42
Ctrl+f Ctrl+b- Page down, page up
Edit
x- Delete the character under the cursor
dd- Delete (cut) the line
yy- Copy the line
p- Paste after the cursor
dw- Delete a word
u- Undo
Ctrl+r- Redo
.- Repeat the last change
Search and replace
/text- Search forward (n next, N previous)
:%s/old/new/g- Replace all in the file
:%s/old/new/gc- Replace all, asking each time
:set number- Show line numbers
Learn it properly