Please enable JavaScript in your browser settings.
Updated
2010-04-09 21:59
Summary
Memorize keyboard shortcuts for the
Vim editor. Most apply to
vi also.
Conventions
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.
Basics
Action Type
start vim vim (command)
start vim tutorial vimtutor (command)
two "modes" normal mode and insert mode
go into insert mode i (see below for others)
go into normal mode esc (or ^c or ^[)
cancel out of current command (or search, etc.) esc (or ^c or ^[)
memorize
Cursor Movement
Getting around the screen...
Action Key
left h
right l
up k
down j
beginning of line 0
end of line $
memorize
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 ^c or ^[) so you can again use the movement-related commands.
Action Key
insert text i
insert text at end of line A (then start typing)
insert text after cursor a
insert text in place of a word cw (then start typing)
memorize
Saving and quitting, etc.
Action Key
save file :w
exit (saving file) ZZ (or) :wq
exit (without saving file) :q!
open myfile.txt (in current dir) :e myfile.txt
browse current dir :e .
memorize
Misc
Action Key
undo u
redo ^r
repeat (last action) .
alternatives for escape ^c or ^[
down 3 lines 3 j
go to line 3 3 G
go back to previous "jump" locations ^o
memorize
Note that typing
numbers before commands usually means "repeat the command
this many times" (as in
3 j).
Searching
Action Key
search /
search (backward) ?
do previous search (while searching) ^p
do next search (while searching) ^n
see previous searches (while searching) ^f
go to next instance of a (on same line) fa
find next instance of word *
memorize
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.
Movement II
Action Key
right 1 word w
left 1 word b
right 1 word (to word end) e
page down ^f
page up ^b
beginning of line text ^ (shift-6)
memorize
Movement III
Action Key
beginning of file gg
end of file G
jump to matching parenthesis %
backward or forward paragraph { or }
backward or forward sentence ( or )
memorize
Directories
Action Key
view root dir
up one dir - (while viewing dir)
toggle dir display mode i (while viewing dir)
create dir d (while viewing dir)
rename file or dir R (while viewing dir)
memorize
Deleting
Action Key
delete char x
delete line dd
delete word dw
insert last deleted P
delete until end of line d$
memorize
Pages
Vim 2 - includes config settings