Vim Commands
Essential Vim editor commands and keyboard shortcuts.
Modes
iEnter insert mode (before cursor)
aEnter insert mode (after cursor)
IInsert at beginning of line
AInsert at end of line
oOpen new line below
OOpen new line above
EscExit insert mode to normal mode
vEnter visual mode (character)
VEnter visual mode (line)
Ctrl+vEnter visual block mode
Navigation
h, j, k, lMove left, down, up, right
wMove to start of next word
bMove to start of previous word
eMove to end of word
0Move to start of line
$Move to end of line
ggGo to first line
GGo to last line
:<number>Go to line number
Ctrl+uScroll up half page
Ctrl+dScroll down half page
Editing
xDelete character under cursor
ddDelete current line
dwDelete word
d$Delete to end of line
yyYank (copy) current line
ywYank word
pPaste after cursor
PPaste before cursor
uUndo
Ctrl+rRedo
rReplace single character
cwChange word
ccChange entire line
Search & Replace
/patternSearch forward
?patternSearch backward
nNext search result
NPrevious search result
:%s/old/new/gReplace all in file
:s/old/new/gReplace all in line
:%s/old/new/gcReplace with confirmation
File Operations
:wSave file
:w filenameSave as filename
:qQuit
:q!Quit without saving
:wqSave and quit
:xSave and quit (shorter)
:e filenameOpen file
:bnNext buffer
:bpPrevious buffer
Advanced
.Repeat last command
>Indent line
<Unindent line
=Auto-indent
JJoin line with next
~Toggle case
*Search word under cursor
Ctrl+nAuto-complete (insert mode)