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 modeiInsert before cursoraInsert after cursorIInsert at start of lineAInsert at end of lineoOpen new line below, insertOOpen new line above, insert:Command-line modeMovement
h j k lLeft / down / up / rightw / bNext / previous word starteEnd of word0Start of line^First non-blank character$End of linegg / GFirst / last line of file:NGo to line N%Jump to matching bracketCtrl-f / Ctrl-bPage down / upEditing
xDelete character under cursorddDelete (cut) linedwDelete wordDDelete to end of lineccChange entire linecwChange wordr{char}Replace one characterJJoin line below with current~Toggle case of character.Repeat last changeCopy & Paste
yyYank (copy) lineywYank wordpPaste after cursorPPaste before cursorSearch & Replace
/patternSearch forward?patternSearch backwardn / NRepeat search, same / opposite direction*Search word under cursor:%s/old/new/gReplace all in file:%s/old/new/gcReplace all, with confirmationVisual Mode
vCharacter-wise selectionVLine-wise selectionCtrl-vBlock-wise selectiond / yDelete / yank selection> / <Indent / unindent selectionWindows, Buffers & Tabs
:split / :vsplitHorizontal / vertical splitCtrl-w wCycle between windowsCtrl-w qClose current window:bnext / :bprevNext / previous buffer:lsList open buffers:tabnewOpen new tabSaving, Exiting & Undo
:wSave:qQuit:wq / :xSave and quit:q!Quit, discard changesZZSave and quit (Normal mode)uUndoCtrl-rRedoThe #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.