elefcode
← All cheat sheets

Tools

Vim Cheat Sheet — Commands & Shortcuts

Vim commands grouped by mode and task. Most commands run in normal mode — press Esc to get there.

Advertisement

Modes

EscReturn to normal mode
i / aInsert before / after the cursor
I / AInsert at start / end of the line
o / OOpen a new line below / above
v / VVisual mode / visual line mode
Ctrl-vVisual block mode

Movement

h j k lLeft, down, up, right
w / bForward / back one word
0 / $Start / end of the line
gg / GTop / bottom of the file
:42Jump to line 42
Ctrl-d / Ctrl-uHalf page down / up
{ / }Previous / next paragraph

Editing

xDelete the character under the cursor
ddDelete (cut) the whole line
yyYank (copy) the line
p / PPaste after / before the cursor
dw / cwDelete / change a word
uUndo
Ctrl-rRedo
.Repeat the last change

Search & replace

/textSearch forward (n / N for next / previous)
?textSearch backward
:%s/old/new/gReplace every occurrence in the file
:%s/old/new/gcReplace all, confirming each one
*Search for the word under the cursor

Files & quitting

:wSave
:qQuit
:wq or ZZSave and quit
:q!Quit without saving
:e fileOpen another file
:sp / :vspSplit horizontally / vertically

More cheat sheets