Vim Commands

Vim commands cheatsheet.

Modes, motion, editing and search — the Vim commands that get you productive fast. Tap to copy.

Modes & saving
iEnter insert mode before the cursor
aEnter insert mode after the cursor
EscReturn to normal mode
:wSave the file
:qQuit
:wqSave and quit
:q!Quit without saving
Moving
h j k lMove left, down, up, right
wJump to the start of the next word
bJump back to the previous word
0Go to the start of the line
$Go to the end of the line
ggGo to the first line
GGo to the last line
:42Jump to line 42
Editing
xDelete the character under the cursor
ddDelete the current line
yyCopy (yank) the current line
pPaste after the cursor
uUndo
Ctrl + rRedo
dwDelete to the end of the word
ccChange (replace) the whole line
Search & replace
/textSearch forward for text
nJump to the next search match
NJump to the previous match
:%s/old/new/gReplace every occurrence in the file
:%s/old/new/gcReplace with confirmation for each
Commands are typed in normal mode (press Esc first). Type :wq then Enter to save and quit if you're stuck.

The idea that unlocks Vim

Vim feels baffling until one idea clicks: it's modal. In normal mode your keys move and manipulate text; press i to drop into insert mode and type normally; press Esc to come back. Beginners get stuck because they start typing in normal mode and chaos ensues — so the very first habit to build is reaching for Esc whenever you're unsure where you are. Everything else in Vim builds on this one distinction.

Motions and operators combine

Vim's real power is a small grammar: operators (like d delete, c change, y yank) combine with motions (w word, $ end of line, gg/G top/bottom). Learn them separately and you automatically get every combination: dw deletes a word, d$ deletes to end of line, cc changes a whole line. This is why Vim users say you don't memorise commands so much as learn a language — a few verbs and nouns produce hundreds of edits.

The survival kit

If you only remember a handful: dd deletes a line, yy copies it, p pastes, u undoes, and Ctrl + r redoes. To get out — the question every newcomer eventually searches for — press Esc, then type :wq to save and quit, or :q! to quit without saving. Don't try to learn everything at once; add one motion a week and let it become reflex. These pair well with the tmux and Linux cheatsheets for a full terminal setup.

FAQ

How do I exit Vim?
Press Esc to make sure you're in normal mode, then type :wq and Enter to save and quit, or :q! and Enter to quit without saving.
How do I find and replace in Vim?
Use :%s/old/new/g to replace every occurrence in the file, or add c (:%s/old/new/gc) to confirm each change.

More cheatsheets