Vim Commands
Essential Vim editor commands and keyboard shortcuts.
Vim Commands
Essential Vim editor commands and keyboard shortcuts
Modes
iEnter insert mode (before cursor)
iaEnter insert mode (after cursor)
aIInsert at beginning of line
IAInsert at end of line
AoOpen new line below
oOOpen new line above
OEscExit insert mode to normal mode
EscvEnter visual mode (character)
vVEnter visual mode (line)
VCtrl+vEnter visual block mode
Ctrl+vNavigation
h, j, k, lMove left, down, up, right
k (move up)wMove to start of next word
wbMove to start of previous word
beMove to end of word
e0Move to start of line
0$Move to end of line
$ggGo to first line
ggGGo to last line
G:<number>Go to line number
:42Ctrl+uScroll up half page
Ctrl+uCtrl+dScroll down half page
Ctrl+dEditing
xDelete character under cursor
xddDelete current line
dddwDelete word
dwd$Delete to end of line
d$yyYank (copy) current line
yyywYank word
ywpPaste after cursor
pPPaste before cursor
PuUndo
uCtrl+rRedo
Ctrl+rrReplace single character
ra (replace with a)cwChange word
cwccChange entire line
ccSearch & Replace
/patternSearch forward
/function?patternSearch backward
?classnNext search result
nNPrevious search result
N:%s/old/new/gReplace all in file
:%s/foo/bar/g:s/old/new/gReplace all in line
:s/foo/bar/g:%s/old/new/gcReplace with confirmation
:%s/foo/bar/gcFile Operations
:wSave file
:w:w filenameSave as filename
:w newfile.txt:qQuit
:q:q!Quit without saving
:q!:wqSave and quit
:wq:xSave and quit (shorter)
:x:e filenameOpen file
:e config.js:bnNext buffer
:bn:bpPrevious buffer
:bpAdvanced
.Repeat last command
.>Indent line
>><Unindent line
<<=Auto-indent
==JJoin line with next
J~Toggle case
~*Search word under cursor
*Ctrl+nAuto-complete (insert mode)
Ctrl+n