Cursor movement

w jump by start of words
W jump by words (no punct.)
e jump to end of words
E jump to end of words (no punct.)
b jump backwards by words
B jump backwards by words (no punct.)
0 start of line
^ first non-blank character of line
$ end of line
G GoTo command (prefix like 5G)

Prefix a cursor movement command with a number:
for example, 4j moves down 4 lines.

Insert Mode - Inserting/Appending text

i start insert mode at cursor
I insert at the beginning of line
a append after cursor
A append at the end of line
o open (append) blank line below current one
O open blank line above current one
ea append at the end of word
Esc exit insert mode


r replace a single character
J join the line below to current one
cc change (replace) an entire line
cw change (replace) to the end of word
c$ change (replace) to the end of line
s delete character at cursor and substitute text
S delete line at cursor and substitute text
xp transpose two letters (delete+paste, technically)
u undo
ctrl+r redo
. repeat last command

Marking text (visual mode)

v start visual mode
V start Linewise vidual mode
o move to other end of marked area
ctrl+v start visual block mode
O move to other corner of block
aw mark a word
ab mark () block (incl. braces)
aB mark {} block (incl. brackets)
ib inner () block
iB inner {} block
Esc exit visual mode

Visual commands

> shift right
< shift left
y yank (copy) marked text
d delete marked text
~ switch case

Cut and Paste

yy yank (copy) a line
2yy yank 2 lines
yw yank word
y$ yank to end of line
p put (paste) the clipboard after cursor
P put (paste) before cursor
dd delete (cut) a line
dw delete (cut) the current word
x delete (cut) current character


:w write (save) the file, but don't quit
:wq write (save) and quit
:q quit (fails is anything has changed)
:q! quit and throw away changes


/pattern search for pattern
?pattern search backwards for pattern
n repeat search in same direction
N repeast search in opposite direction
:%s/old/new/g replace all old with new throughout file
%s/old/new/gc ... with confirmations

Working with multiple files

:e filename edit a file in a new buffer
:bnext (or :bn) go to next buffer
:bprev (or :bp) go to previous buffer
:bd delete a buffer (close a file)
:sp filename open a filename in a new buffer and split window
ctrl+ws split windows
ctrl+ww switch between windows
ctrl+wq quit a window
ctrl+wv split windows vertically