Vim Cheat Sheet

Quick reference for essential Vim commands. Navigation, editing, search, visual mode, buffers, and macros — everything you need on one page.

Modes Navigation Editing Search & Replace Visual Mode Files & Buffers Macros & Registers

Modes

i / I Insert mode (at cursor / start of line)
a / A Insert after cursor / end of line
o / O New line below / above
Esc Return to Normal mode
v / V / Ctrl+v Visual / Visual Line / Visual Block
: Command-line mode
R Replace mode (overtype)

Editing

x / X Delete char at / before cursor
dd / D Delete line / to end of line
dw / db Delete word forward / backward
cc / C Change line / to end of line
cw Change word
yy / Y Yank (copy) line
p / P Paste after / before cursor
u / Ctrl+r Undo / redo
. Repeat last command
>> / << Indent / unindent line
J Join line below to current

Search & Replace

/pattern Search forward
?pattern Search backward
n / N Next / previous match
* / # Search word under cursor fwd / bwd
:s/old/new/ Replace first 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 all with confirmation

Visual Mode

v + motion + d Select and delete
v + motion + y Select and yank
V + > / < Indent / unindent selected lines
Ctrl+v + I + text + Esc Block insert (add to multiple lines)
gv Reselect last visual selection

Files & Buffers

:w / :w file.txt Save / save as
:q / :q! Quit / force quit (discard changes)
:wq / ZZ Save and quit
:e file.txt Open file
:bn / :bp Next / previous buffer
:ls List open buffers
:sp / :vsp Horizontal / vertical split
Ctrl+w + h/j/k/l Navigate between splits

Macros & Registers

qa ... q Record macro into register a
@a Play macro a
@@ Repeat last macro
10@a Play macro a 10 times
"ay Yank into register a
"ap Paste from register a
:reg Show all registers
Step-by-Step Guide

How to Format JSON Online

Read Guide →

More Cheat Sheets