VIM Command ReferenceThis reference is being improved weekly. Please come back and check it out.
NavigationMoving 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.
EditingDelete 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.
CommandsThese can be followed immediately by a motion.
==== Change - c ====
Examples:
* Change 1 word
* Change 2 words
* Change to the end of the line
==== Delete - d ====
Examples
* delete to next word
* Repeat d to act on the current line, so this deletes current line
* Deletes current and next line, etc.
Multiple Window ControlSplit 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 possibleCTRL-w _ (Control-w Underscore)
Make all windows equal sizeCTRL-w = (Control-w Equal)
Grow the current window by 1 lineCTRL-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 lineCTRL-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 FocusMove 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 PositionRotate all windows down (or to the right)
CTRL-r
Rotate all windows up (or to the left)
CTRL-R
Miscellaneous CommandsRedraw screenCTRL-l (Control-ell)
Word completionCTRL-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.
SettingsUnhighlight previous search matches:noh
Turn on syntax highlighting:syntax on
Show matching braces:set showmatch
Disable this setting:
:set noshowmatch