Vim modes, navigation, editing commands, search/replace, and essential configuration
Default mode for navigation and commands. Press Esc to return.
Esc or Ctrl+[ → enter Normal mode
: → enter Command modeType text. Enter from Normal mode.
i → insert before cursor
a → append after cursor
I → insert at start of line
A → append at end of line
o → open new line below
O → open new line aboveSelect text for operations.
v → visual (character)
V → visual line
Ctrl+v → visual blockExecute Ex commands after pressing :
:w → save
:q → quit
:wq → save and quit
:q! → quit without saving
:e file → open fileMove cursor without arrow keys (works in all modes)
h ← j ↓ k ↑ l →
0 → start of line
^ → first non-blank character
$ → end of lineJump between words efficiently
w → next word start
b → previous word start
e → next word end
W/B/E → same but WORD (space-separated)Jump to positions in the file
gg → first line
G → last line
50G → line 50
Ctrl+d → half-page down
Ctrl+u → half-page up
Ctrl+f → full page down
Ctrl+b → full page upJump to a character on the current line
f{char} → forward to char (inclusive)
t{char} → forward to char (exclusive)
F{char} → backward to char
; → repeat last f/t/F/T
, → repeat in opposite directionDelete text (also cuts to clipboard)
dd → delete line
dw → delete word
d$ → delete to end of line
d0 → delete to start of line
D → delete to end of lineCopy text and paste it
yy → yank (copy) line
yw → yank word
y$ → yank to end of line
p → paste after cursor
P → paste before cursorDelete and enter Insert mode
cc → change line
cw → change word
ci" → change inside quotes
ca( → change around parens
c$ → change to end of lineUndo and redo changes
u → undo
Ctrl+r → redo
. → repeat last changeSelect text then apply an operation
v then w, w, w → select 3 words
V then j, j → select 3 lines
d → delete selection
y → yank selection
> → indent selection
< → de-indent selection
~ → toggle caseSearch forward and backward in file
/pattern → search forward
?pattern → search backward
n → next match
N → previous match
* → search word under cursorFind and replace with :s command
:s/old/new/ → replace first on line
:s/old/new/g → replace all on line
:%s/old/new/g → replace all in file
:%s/old/new/gc → replace all with confirmOpen files loaded into memory
:ls → list buffers
:bn → next buffer
:bp → previous buffer
:b name → switch to buffer by nameSplit the editor into panes or tabs
:sp file → horizontal split
:vsp file → vertical split
Ctrl+w h/j/k/l → navigate splits
:tabnew file → open in new tab
gt / gT → next/prev tabVim's most powerful feature: operate on semantic units
# Pattern: [operator][inner/around][object]
# operators: d (delete), c (change), y (yank), v (visual)
# i = inner, a = around (includes delimiters)
diw # delete inner word (not surrounding spaces)
daw # delete a word (including trailing space)
di" # delete inside double quotes
da" # delete inside + the quotes themselves
ci( # change inside parentheses
ca{ # change around curly braces (including {})
yit # yank inside HTML/XML tag
vip # visual select inner paragraphRecord and replay a sequence of commands
# Record macro to register 'a'
qa # start recording into register a
... # perform your commands
q # stop recording
# Replay macro
@a # run macro a once
10@a # run macro a 10 times
@@ # repeat last macro
# Example: add semicolon to end of 5 lines
qa A;<Esc> j q
5@aPowerful substitution across file with regex
# Basic substitution
:%s/foo/bar/g # replace all 'foo' with 'bar'
# Case insensitive
:%s/foo/bar/gi # g=all, i=case insensitive
# With confirmation
:%s/foo/bar/gc # c=confirm each
# Regex substitution
:%s/\(\w\+\)/[\1]/g # wrap each word in brackets
# Only in selected range (visual mode first)
:'<,'>s/foo/bar/gThink in motions + text objects — daw, ci", yip are far more efficient than letter-by-letter edits
Use . (dot) to repeat the last change — it makes repetitive edits nearly instant
Start with vimtutor (run in terminal) — it takes ~30 minutes and covers the essentials interactively
Add :set number and :set relativenumber to your .vimrc for line numbers
Remap Caps Lock to Ctrl or Esc at the OS level to reduce finger travel