All cheatsheets

Cheatsheets

Vim

Vim motions, editing, search/replace, and file commands.

Visualize

Vim — modal editing

Keys mean different things per mode; Esc always returns to Normal.

Normal: Navigate & run commands — keys are actions (dd, yy, p, hjkl).

Keys mean different things per mode — and Esc always returns you to Normal.

40 entries

The operator+motion grammar (verb + noun)2

<operator><motion>

Vim is a language: combine an operator (verb) with a motion or text object (noun).

[count]<operator><motion>

Prefix any command with a count to repeat it that many times.

Text objects3

i / a (inner vs around)

Text objects select structured regions. `i` = inner (content only); `a` = around (includes delimiters/whitespace).

iw / aw / iW / aW

Inner word / around word / inner WORD / around WORD

i( i[ i{ i< i" i' i` / it is ip

Inner pair / tag / sentence / paragraph text objects

Motions9

h j k l

Left, down, up, right

w / b / e

Next / previous / end of word

0 / ^ / $

Line start / first non-blank / end

gg / G

Top / bottom of file

{ / }

Previous / next paragraph

Ctrl-d / Ctrl-u

Half page down / up

:<n> or <n>G

Jump to line n

%

Jump to matching bracket

f<char> / t<char>

Jump to / before next char on line

Editing9

i / a / A

Insert before / after cursor / end of line

o / O

Open line below / above

dd / yy / p

Delete / yank line, paste

cw / ciw

Change word / inner word

ci" / di(

Change inside quotes / delete inside parens

x / r<char>

Delete char / replace char

u / Ctrl-r

Undo / redo

>> / <<

Indent / dedent line

.

Repeat the last change

Search & replace6

/pattern

Search forward for pattern (regex)

n / N

Next / previous match

* / #

Search word under cursor fwd / back

:%s/old/new/gc

Replace all occurrences in the file, confirming each

:%s/old/new/g

Replace all in the file

:g/pattern/d

Delete all lines matching pattern

Visual modes5

v / V / Ctrl-v

Char-wise / line-wise / block visual mode

gv

Reselect the last visual selection

"ayy / "ap

Yank to / paste from register a

ma / `a

Set mark a / jump to exact position of mark a

qa ... q / @a

Record macro into register a / replay macro a

Files, windows & buffers5

:w :q :wq :q!

Save / quit / save+quit / force-quit

:e file

Open a file

:sp / :vsp

Horizontal / vertical split

Ctrl-w h/j/k/l

Move between splits

:bn / :bp / :ls

Next / prev buffer / list buffers

Jumps & the jump list1

Ctrl-o / Ctrl-i

Jump back / forward through the jump list