Code & computing / QUICK REFERENCE

vi / Vim

Modes, motions, editing, search, buffers and splits—with a clear way to save and get out.

55 entries

Modes and safe exits

Return to Normal mode
Esc

Stops insertion or clears an in-progress command. [1]

Insert before cursor
i

Enters Insert mode. [1]

Append after cursor
a

Starts typing after this character. [1]

Insert at first nonblank
I

Uppercase I begins at the text on this line. [1]

Append at end of line
A

Uppercase A begins after the final character. [1]

Open a line below
o

Creates a new line and enters Insert mode. [1]

Open a line above
O

Uppercase O creates a line above. [1]

Write this buffer
:w

Saves to its filename; an unnamed buffer needs one. [1]

Quit this window
:q

Refuses if unsaved changes would be lost. [1]

Write and quit
:wq

Saves, then closes this window. [1]

Discard changes and quit
:q!

Destructive: discards this buffer's unsaved changes when it is abandoned. [1]

Help on a command
:help :write

Opens the installed, version-matched help. [1]

Move without reaching for the mouse

Left / down / up / right
h / j / k / l

Character and line movement. [2]

Next word start
w

Moves by word boundaries. [2]

Previous word start
b

Moves back by a word. [2]

Word end
e

Lands at the end of a word. [2]

Line start
0

Digit zero goes to column one. [2]

First nonblank character
^

Skips leading indentation. [2]

Line end
$

Goes to the final character. [2]

File start
gg

Vim shortcut for the first line. [2]

File end
G

Uppercase G goes to the last line. [2]

Line forty-two
42G

Count before G selects a line. [2]

Next x on this line
fx

Finds the next literal x. [2]

Match bracket
%

Jumps between matching delimiters. [2]

Half page down / up
Ctrl+d / Ctrl+u

Scrolls while moving the cursor. [2]

Edit with operators

Undo
u

Reverses the latest change. [3]

Redo
Ctrl+r

Reapplies an undone change in Vim. [3]

Repeat latest change
.

Repeats the previous editing operation. [3]

Delete character
x

Deletes under the cursor; undo with u. [3]

Delete this line
dd

Removes a line into a register. [3]

Delete three lines
3dd

Count repeats the line operation. [3]

Delete a word
dw

Combines delete with the w motion. [3]

Change inner word
ciw

Replaces a word without surrounding whitespace. [3]

Yank this line
yy

Copies the line into a register. [3]

Paste after
p

Inserts register contents after the cursor or below the line. [3]

Paste before
P

Uppercase P inserts before or above. [3]

Join next line
J

Joins with whitespace handling. [3]

Indent / unindent line
>> / <<

Shifts indentation by shiftwidth. [3]

Visual character selection
v

Selects text using Normal-mode motions. [3]

Visual line selection
V

Selects complete lines in Vim. [3]

Buffers and split windows

List buffers
:ls

Shows buffer numbers and flags. [5]

Choose buffer
:buffer 2

Opens buffer number 2 in this window. [5]

Next / previous buffer
:bnext / :bprevious

Cycles loaded buffer entries. [5]

Horizontal split
:split

Opens another window above/below. [5]

Vertical split
:vsplit

Opens another window beside it. [5]

Next window
Ctrl+w, w

Cycles focus among Vim windows. [5]

Directional window focus
Ctrl+w, h / j / k / l

Chooses a window left/down/up/right. [5]

Equalize split sizes
Ctrl+w, =

Balances the split layout. [5]

Reserved placement, separate from reference controls. No ad network is active.

Updated Vim · default mappings / no plugins

Sources

  1. First steps in Vim ↗
  2. Moving around ↗
  3. Changing text ↗
  4. Windows and buffers ↗