Vim Cheatsheet

Searchable reference of essential Vim commands, modes, and motions.

​
Modes
i

Insert before cursor

a

Insert after cursor (append)

o

Open new line below and insert

v

Visual mode (character)

V

Visual line mode

Ctrl-v

Visual block mode

Esc

Return to normal mode

Movement
h j k l

Left, down, up, right

w / b

Next / previous word start

0 / $

Start / end of line

gg / G

First / last line

:42

Go to line 42

{ / }

Previous / next paragraph

Ctrl-d / Ctrl-u

Half page down / up

Editing
x

Delete character

dd

Delete (cut) line

yy

Yank (copy) line

p / P

Paste after / before

dw

Delete to next word

ciw

Change inner word

u / Ctrl-r

Undo / redo

.

Repeat last change

Search & replace
/foo

Search forward for foo

?foo

Search backward for foo

n / N

Next / previous match

:%s/a/b/g

Replace all a with b

:%s/a/b/gc

Replace all, with confirm

*

Search word under cursor

Files & windows
:w

Save

:q

Quit

:wq / ZZ

Save and quit

:q!

Quit without saving

:sp / :vsp

Split horizontal / vertical

Ctrl-w w

Cycle windows

Marks & macros
ma

Set mark a

`a

Jump to mark a

qa … q

Record macro into register a

@a

Play macro a

@@

Replay last macro