Basics
save and quit
:wq or :x
quit
:q
force quit
:q!
back file
ctrl + o
insert mode
i
visual mode
v
undo
u
Search
search for pattern
/pattern
search pattern (regex)
\vpattern
replace all old with new throughout file
:%s/old/new/g
replace all old with new throughout file with confirmations
:%s/old/new/gc
Search in multiple files
:vim[grep] /pattern/ {{file}
} - search for pattern in multiple files
e.g. :vim[grep] /foo/ */
Window
split window
Ctrl + ws
quit a window
Ctrl + wq
switch windows
Ctrl + ww
Indent text
indent (move right) line one shiftwidth
">>"
de-indent (move left) line one shiftwidth
"<<"
indent a block with () or {} (cursor on brace)
">%"
indent inner block with ()
">ib"
indent a block with <> tags
">at"