Vim Cheat Sheet

Complete Vim quick reference — modes, navigation, editing, search, macros, splits, and registers. Print it, bookmark it, master it.

Modes Navigation Editing Search & Replace Macros & Registers Splits & Tabs

Modes

Esc Return to Normal mode from any mode
i Insert mode — before cursor
I Insert mode — beginning of line
a Append — after cursor
A Append — end of line
o Open new line below and enter Insert mode
O Open new line above and enter Insert mode
v Visual mode — character selection
V Visual line mode — line selection
Ctrl+v Visual block mode — column selection
: Command-line mode

Editing

x Delete character under cursor
dd Delete (cut) current line
d{motion} Delete with motion (dw, d$, d3j ...)
yy Yank (copy) current line
y{motion} Yank with motion (yw, y$, y3j ...)
p / P Paste after / before cursor
u / Ctrl+r Undo / redo
. Repeat last change
ciw / caw Change inner word / Change a word
ci" / ci( Change inside quotes / parentheses
J Join current line with next
~ Toggle case of character
>> / << Indent / de-indent line

Search & Replace

/pattern Search forward for pattern
?pattern Search backward for pattern
n / N Next / previous match
* Search for word under cursor (forward)
:s/old/new/ Replace first occurrence on current line
:s/old/new/g Replace all on current line
:%s/old/new/g Replace all in file
:%s/old/new/gc Replace with confirmation prompt
:noh Clear search highlighting

Macros & Registers

q{a} Start recording macro into register a
q Stop recording macro
@{a} Play back macro from register a
@@ Repeat last played macro
10@{a} Run macro 10 times
"{a}yy Yank line into register a
"{a}p Paste from register a
:reg Show all registers and their contents
"+y Yank to system clipboard
"+p Paste from system clipboard

Splits, Tabs & Files

:sp / :vsp Horizontal / vertical split
Ctrl+w h/j/k/l Move between splits
Ctrl+w = Equalize split sizes
:tabnew / :tabe file New tab / open file in new tab
gt / gT Next / previous tab
:w / :wq / :q! Save / save and quit / quit without saving
:e file Open file in current buffer
:bn / :bp Next / previous buffer

More Cheat Sheets