Memorize.com

Vim

edit

Summary

Memorize keyboard shortcuts for the Vim editor. Most apply to vi also.

Conventions used

The ^ means hold down the ctrl key. For example, ^w means hold down ctrl and press w. Also, pressing Enter is necessary after commands that begin with : but this is omitted for brevity.

Movement

Getting around the screen...

 

Key (memorize) Description (memorize)
hleft
lright
kup
jdown
0beginning of line
$end of line
wforward 1 word

 

Note that the arrow keys also work for moving around. Also, feel free to use the mouse to move around and select (won't work in a terminal window).

Editing

Once you've enter edit mode (usually via i or A) and insert some text, you'll usually want to press esc (or ^[ ) so you can again use the movement-related commands.

 

Key (memorize) Description (memorize)
i (then start typing)insert text
esc (or ^[ )exit edit mode
A (then start typing)insert text (starting at end of line)
ainsert text (after cursor)
cw (then start typing)insert text (in place of a word)

Saving and quitting, etc.

Question (memorize) Answer (memorize)
:wsave file
ZZ (or) :wqexit (saving file)
:q!exit (without saving file)
:e myfile.txtopen myfile.txt (in current dir)
:Eview current dir

Misc

Key (memorize) Description (memorize)
uundo
^rredo
.repeat
^[shortcut for escape
3jdown 3 lines
3Ggo to line 3
^ogo back to previous locations

 

Note that typing numbers before commands usually means "repeat the command this many times" (as in 3 j).

Searching

Key (memorize) Description (memorize)
/search
?search (backward)
^p (while searching)do previous search
^n (while searching)do next search
^f (while searching)see previous searches
fago to next instance of a (on same line)
*find next instance of word

 

Incremental searching is a very cool feature. It means that the cursor will search forward as you type a search string (used with / search). Add "set incsearch" to your .vimrc file if incremental searching isn't enabled.

Pages

Vim 4 - has helpful config settings