VIM Command Reference

This reference is being improved weekly. Please come back and check it out.


Navigation

Moving the Cursor

h - Move left 1 character
j - Move up 1 line
k - Move down 1 line
l - (ell) Move right 1 character

e - Move to the end of the current word
b - Move to the beginning of the current word

0 - Move to the beginning of line
$ - Move to the end of line

^ - Move to the first non-whitespace character in the current line
+ - Move to the first character of next line
- - Move to the first character of previous line

) - Move to the next sentence
( - Move to the previous sentence

} - Move to the next paragraph
{ - Move to the previous paragraph

]] - Move to the next section
[[ - Move to the previous section

:# - Move the cursor to the specified line number (replace # with a number)

Scrolling the Screen

CTRL-y - Scroll screen up 1 line
CTRL-e - Scroll screen down 1 line

CTRL-u - Scroll 1 page up
CTRL-d - Scroll 1 page down


Bookmarks

ma - Make a bookmark named 'a' at the current cursor position.

A bookmark can be named any lowercase letter. You can't see the bookmark, but it's there!

`a - (backtick-a) Go to bookmark a.

`. - Go to the line that you last edited.


Editing

Delete Current Character

x - Delete the current character (the character under the cursor).
r - Alter the current character. Just type the new character after you type r.


Navigation commands can be lead by a command, such as d (delete) to delete everything within the navigation zone.

The format is <command><navigation>

w - (normal mode) Move ahead 1 word
% - (normal mode) Bounce to matching paren/braces, etc.

If you're not on a paren (etc.), vim will scan forward (within the same line only) to next paren and then move to matching paren.

Since % is a motion (navigation command), use d% to delete the specified zone.

Example: Delete to matching paren/brace
d% - command then move

* f - (normal mode) "Find"
* t - (normal mode) "Till": Move to the char just before 'f' would.


Commands
These can be followed immediately by a motion.

==== Change - c ====

Examples:
* Change 1 word
Code
cw

* Change 2 words
Code
c2w

* Change to the end of the line
Code
c$


==== Delete - d ====
Examples
* delete to next word
Code
dw

* Repeat d to act on the current line, so this deletes current line
Code
dd

* Deletes current and next line, etc.
Code
2dd



Multiple Window Control

Split A Window

:sp <filename>

This opens up a new window with the specified file ready for editing.

TAB expansion works when typing in the filename just as it does on the BASH command line.

To split the current window in 2 with the same file in both windows
CTRL-w s

To split a window vertically
:vsp <filename> (<filename> is optional)
When <filename> is omitted, the same file is opened in both windows.

Make current window as large as possible
CTRL-w _ (Control-w Underscore)

Make all windows equal size
CTRL-w = (Control-w Equal)

Grow the current window by 1 line
CTRL-w + (Control-w Plus)

To grow the window by more than 1 line, precede this command with a number. Example:

5 CTRL-w +
This command grows the current window by 5 lines.

Shrink the current window by 1 line
CTRL-w (Control-w Minus)

To shrink the window by more than 1 line, precede this command with a number. Example:

5 CTRL-w - (5 Control-w Minus)
This command shrinks the current window by 5 lines.

Changing Window Focus

Move to the next window
CTRL-w CTRL-w

Move the window to the left
CTRL-W h

Move the window to the right
CTRL-W l

Move the window below
CTRL-W j

Move the window above
CTRL-W k

Move the window to the top
CTRL-W t

Move the window to the bottom
CTRL-W b

Moving Window Position

Rotate all windows down (or to the right)
CTRL-r

Rotate all windows up (or to the left)
CTRL-R

Miscellaneous Commands

Redraw screen
CTRL-l (Control-ell)

Word completion

CTRL-n
Next match (insert mode)

This completes words whose prefix is to the right of the cursor. Words are taken from all open windows.

CTRL-p
Previous match (insert mode)

This completes words whose prefix is to the left of the cursor. Words are taken from all open windows.


Settings

Unhighlight previous search matches
:noh

Turn on syntax highlighting
:syntax on

Show matching braces
:set showmatch

Disable this setting:
:set noshowmatch



The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)