Sidebar Linux

Vim Cheat Sheet

Sidebar

Linux · Vim Cheat Sheet

Modal editing, at a glance. For the full picture — including why Vim works this way — see Learning Vim and Vim Intermediate/Advanced.

Modes

EscReturn to Normal mode
iInsert before cursor
aInsert after cursor
IInsert at start of line
AInsert at end of line
oOpen new line below, insert
OOpen new line above, insert
:Command-line mode

Movement

h j k lLeft / down / up / right
w / bNext / previous word start
eEnd of word
0Start of line
^First non-blank character
$End of line
gg / GFirst / last line of file
:NGo to line N
%Jump to matching bracket
Ctrl-f / Ctrl-bPage down / up

Editing

xDelete character under cursor
ddDelete (cut) line
dwDelete word
DDelete to end of line
ccChange entire line
cwChange word
r{char}Replace one character
JJoin line below with current
~Toggle case of character
.Repeat last change

Copy & Paste

yyYank (copy) line
ywYank word
pPaste after cursor
PPaste before cursor

Search & Replace

/patternSearch forward
?patternSearch backward
n / NRepeat search, same / opposite direction
*Search word under cursor
:%s/old/new/gReplace all in file
:%s/old/new/gcReplace all, with confirmation

Visual Mode

vCharacter-wise selection
VLine-wise selection
Ctrl-vBlock-wise selection
d / yDelete / yank selection
> / <Indent / unindent selection

Windows, Buffers & Tabs

:split / :vsplitHorizontal / vertical split
Ctrl-w wCycle between windows
Ctrl-w qClose current window
:bnext / :bprevNext / previous buffer
:lsList open buffers
:tabnewOpen new tab

Saving, Exiting & Undo

:wSave
:qQuit
:wq / :xSave and quit
:q!Quit, discard changes
ZZSave and quit (Normal mode)
uUndo
Ctrl-rRedo
The #1 new-user trap
Typing a Normal-mode command while still in Insert mode doesn't run the command — it just types those characters into the document. If Vim seems to be "ignoring" a command, press Esc first to confirm you're actually in Normal mode before trying again.