Editor

Vim Cheatsheet

Quick reference for Vim commands including modes, navigation, editing, search and replace, macros, registers, and window management.

Modes

KeyModeDescription
EscNormalDefault mode for navigation and commands
iInsertInsert before cursor
aInsertInsert after cursor
IInsertInsert at beginning of line
AInsertInsert at end of line
oInsertOpen new line below
OInsertOpen new line above
vVisualCharacter-wise selection
VVisual LineLine-wise selection
Ctrl+vVisual BlockBlock selection
:CommandEnter ex commands
RReplaceReplace characters as you type

Basic Movement

KeyDescription
h j k lLeft, Down, Up, Right
wNext word start
WNext WORD start (whitespace-delimited)
bPrevious word start
BPrevious WORD start
eNext word end
ENext WORD end
0Beginning of line
^First non-blank character
$End of line
ggFirst line of file
GLast line of file
{n}GGo to line n
{Previous paragraph
}Next paragraph
%Matching bracket
Ctrl+dHalf page down
Ctrl+uHalf page up
Ctrl+fFull page down
Ctrl+bFull page up
HTop of screen
MMiddle of screen
LBottom of screen
zzCenter current line on screen

Editing

KeyDescription
xDelete character under cursor
XDelete character before cursor
ddDelete line
DDelete to end of line
dwDelete word
d$Delete to end of line
d0Delete to beginning of line
ccChange entire line
CChange to end of line
cwChange word
ci"Change inside quotes
ca(Change around parentheses
yyYank (copy) line
ywYank word
y$Yank to end of line
pPaste after cursor
PPaste before cursor
uUndo
Ctrl+rRedo
.Repeat last command
JJoin line below to current
~Toggle case
>>Indent line
<<Unindent line
==Auto-indent line

Text Objects

ObjectDescription
iwInner word
awA word (including space)
isInner sentence
ipInner paragraph
i" / i' / i`Inside quotes
a" / a' / a`Around quotes
i( / i) / ibInside parentheses
i{ / i} / iBInside braces
i[ / i]Inside brackets
itInside HTML/XML tag
atAround HTML/XML tag

Search & Replace

CommandDescription
/patternSearch forward
?patternSearch backward
nNext match
NPrevious match
*Search word under cursor (forward)
#Search word under cursor (backward)
:s/old/new/Replace first on current line
:s/old/new/gReplace all on current line
:%s/old/new/gReplace all in file
:%s/old/new/gcReplace all with confirmation
:nohClear search highlighting

Macros

CommandDescription
qaStart recording macro into register a
qStop recording
@aPlay macro from register a
@@Replay last macro
10@aPlay macro 10 times

Registers

RegisterDescription
"aNamed register a-z
"AAppend to register a
""Default (unnamed) register
"0Last yank
"1-"9Last deletes
"+System clipboard
"*Primary selection (X11)
"/Last search pattern
":Last command
".Last inserted text
"%Current filename

Marks

CommandDescription
maSet mark a at cursor
`aJump to mark a (exact position)
'aJump to mark a (line start)
:marksList all marks
`.Jump to last change
`` ``Jump to position before last jump

File & Buffer Commands

CommandDescription
:wSave
:w fileSave as
:qQuit
:q!Quit without saving
:wq / :x / ZZSave and quit
:e fileOpen file
:bn / :bpNext / previous buffer
:lsList buffers
:bdClose buffer

Windows & Tabs

CommandDescription
:sp fileHorizontal split
:vsp fileVertical split
Ctrl+w h/j/k/lNavigate between windows
Ctrl+w =Equal size windows
Ctrl+w _Maximize height
Ctrl+w |Maximize width
:tabnew fileNew tab
gt / gTNext / previous tab