All cheatsheets

Cheatsheets

Vim

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

34 entries

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 ?pattern

Search forward / backward

n / N

Next / previous match

* / #

Search word under cursor fwd / back

:%s/old/new/g

Replace all in the file

:%s/old/new/gc

Replace all, confirming each

:g/pattern/d

Delete all lines matching pattern

Visual & registers5

v / V / Ctrl-v

Visual / line / block mode

gv

Reselect the last visual selection

"ayy / "ap

Yank to / paste from register a

ma / `a

Set mark a / jump to mark a

qa ... q / @a

Record macro a / replay it

Files & windows5

: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