This is a cheat sheet for the Vim As Your Editor series by ThePrimeagen
j
and k
- move down and up
h
and l
- move left and right
w
- move to the start of the next word
b
- move to the start of the current/last word
yy
- yank (copy) line
p
- paste line under
dd
- delete line
u
- undo
SHIFT+V
- enter visual line mode (aka highlight line)
y
- copy highlighted text
d
- delete highlighted text
v
- enter visual mode (aka highlight current character)
i
- enter insert mode (to insert text like in a normal text editor)
ESC
- exit insert/visual mode
CTRL+C
- ditto
CTRL+[
- ditto
dw
- delete word
dj
- delete current line and line below it
yw
- yank word
yj
- yank current line and line below it
:w
- save file
o
- insert line below
SHIFT+O
- insert line above
SHIFT+P
- paste line above
a
- enter insert mode after current character
SHIFT+I
- enter insert mode before current line
SHIFT+A
- enter insert mode after current line
/
- start searching
n
- jump to next search result
SHIFT+N
- jump to previous search result
*
- search for next occurrence of current word
#
- search for previous occurrence of current word
f<char>
- move forwards to character specified
t<char>
- move forwards to one character before one specified
SHIFT+F<char>
- move backwards to character specified
SHIFT+T<char>
- move backwards to one character after one specified
;
- repeat movement
x
- delete character
s
- replace character
cw
- replace word
dt<char>
- delete until one character before one specified
ct<char>
- replace until one character before one specified
SHIFT+D
- delete rest of line
SHIFT+C
- replace rest of line
SHIFT+X
- replace line
gg
- move to top of file
SHIFT+G
- move to bottom of file
:<line>
- move to line
<line>g
- ditto
<number>j
- move down multiple times
}
- move to next paragraph
{
- move to previous paragraph
CTRL-D
- move 1/2 page downwards
CTRL-U
- move 1/2 page upwards
%
- move to matching bracket
di{
- delete content of brackets
d<number>i{
- delete content of multiple surrounding brackets
da{
- delete enclosing brackets and their content
:e src/**/<tab>
- find and open file
CTRL+p
- fuzzy file search (requires fzf
)
CTRL+^
- switch between two files
CTRL+o
- move backwards through history
CTRL+i
- move forwards through history
mh
- set local mark h
'h
- move to local mark h
mH
- set global mark H
'H
- move to global mark H
CTRL+w o
- close all other buffers
CTRL+w v
- split vertically
CTRL+w s
- split horiSontally
:resize 10
- set split size to 10 rows
:vertical resize 10
- set split size to 10 columns
CTRL+w =
- set split size evenly
CTRL+w r
- rotate split buffers
CTRL+w SHIFT+H
- switch between vertical and horizontal split