Vim Cheat Sheet

A compact reference for the Vim commands you can use directly in this browser editor. Keep it open in a second tab while you practice, and pair it with the practical guide if a command needs more explanation.

Switching modes

KeysWhat it does
iInsert before the cursor
aInsert (append) after the cursor
AAppend at the end of the line
oOpen a new line below and insert
OOpen a new line above and insert
vStart Visual (selection) mode
:Start a Command-line command
EscReturn to Normal mode

Moving the cursor

KeysWhat it does
h / lMove left / right one character
j / kMove down / up one line
w / bJump forward / back by word
0Go to the start of the line
$Go to the end of the line
{ / }Jump to the previous / next blank line (paragraph)
ggGo to the first line of the file
GGo to the last line of the file
Ctrl-f / Ctrl-bScroll a full page down / up
Ctrl-d / Ctrl-uScroll a half page down / up

Editing text

KeysWhat it does
xDelete the character under the cursor
ddDelete (cut) the current line
>> / <<Indent / unindent the current line
>j / 3>>Indent with a motion or a line count
~Toggle case of the character under the cursor
guiw / gUiwLowercase / uppercase a word (motion or text object)
g~wToggle case over a motion
J / gJJoin the next line (with / without a space)
Ctrl-a / Ctrl-xIncrement / decrement the number under the cursor
i text EscInsert text, then leave Insert mode
BackspaceDelete back one character (Insert mode)
EnterInsert a new line (Insert mode)

Visual mode

KeysWhat it does
v / V / Ctrl-vStart characterwise / linewise / block selection
u / U / ~Lowercase / uppercase / toggle case of the selection
r{char}Replace every selected character
JJoin the selected lines
pReplace the selection with the register
> / <Indent / unindent the selection
oJump to the other end of the selection

Copy, paste and registers

KeysWhat it does
yyYank (copy) the current line into the register
p / PPaste the register after / before the cursor
"ayy / "apYank into / paste from named register a
"0pPaste the last yank (survives later deletes)
"1p ... "9pPaste from the numbered delete ring
"_ddDelete into the black hole (keep the register)
"+pPaste from the computer (system) clipboard
Ctrl/Cmd + VPaste the clipboard while in Insert mode

Macros and reselect

KeysWhat it does
qa ... qRecord keystrokes into register a
@aPlay back the macro in register a
@@Repeat the last played macro
3@aPlay a macro a set number of times
gvReselect the last Visual selection
.Repeat the last change

Files and commands

KeysWhat it does
:wWrite (save) the current file
:wqWrite (save) the file, same as :w here
:qNo-op in the browser (use :w to save)
Up / DownBrowse command/search history at the : or / prompt

How to read these commands

Most commands are typed in Normal mode—the mode you return to whenever you press Esc. Commands that start with a colon, like :w, are typed in Command mode and finished with Enter. If a key seems to type a letter instead of running a command, you are probably still in Insert mode: press Esc and try again.

Common Vim tasks, step by step

See all documents for the full list of guides, tutorials, and references.

Practice these in the editor

Advertisement