Memra
Cheat-sheet

Vim reference

Every command grouped by what it does. Want to drill them? The playground turns each into a challenge.

Motions

Move the cursor. Combine with a count (3w) or an operator (d3w).

h j k l
left · down · up · right
w / W
next word / WORD (WORD = whitespace-delimited)
b / B
back a word / WORD
e / E
end of word / WORD
0 ^ $
line start · first non-blank · line end
gg G
first line · last line (3G → line 3)
%
jump to the matching bracket () [] {}

Find on line

Jump to a character; ; and , repeat the last find.

f{c} / F{c}
onto next / previous {c}
t{c} / T{c}
up to (before) next / previous {c}
; ,
repeat last find · repeat reversed

Operators

op + motion, or doubled for the whole line (dd, cc, yy).

d{motion}
delete over the motion (dw, d$, dfx)
c{motion}
change — delete then INSERT (ce, ci")
y{motion}
yank (copy) into the register
dd cc yy
whole-line delete · change · yank
D C
delete · change to end of line (= d$ / c$)
x X
delete char under · before the cursor
s S
substitute char · whole line (then INSERT)
r{c}
replace the char under the cursor with {c}

Text objects

Use after an operator: di( deletes inside, da( includes the pair.

iw / aw
inner word / a word
i" i' i`
inside quotes
i( i[ i{
inside brackets / braces
a( a[ a{
a pair — includes the brackets

Insert mode

Enter INSERT, type text, then Esc back to NORMAL.

i a
insert before · after the cursor
I A
insert at line start (first non-blank) · line end
o O
open a new line below · above
Esc
leave INSERT, return to NORMAL

Visual mode

Select, then an operator acts on the selection.

v V
characterwise · linewise visual
{motion}
extend the selection (e, $, j, f{c})
d c y
delete · change · yank the selection

Yank, paste, repeat & undo

p P
paste after · before (linewise pastes on a new line)
yy p
duplicate a line
dd p
move a line down
xp
transpose two characters
.
repeat the last change (e.g. ciwfoo⎋ then . on the next word)
u
undo the last change (a whole insert undoes as one)
NORMAL ~/memra/vim/reference utf-8 LF