Vim
Vim commands with functionality in mind.
Navigation
H
- (High) Move cursor to first line in current screen (with same horizontal spacing).L
- (Low) Move cursor to last line in current screen (with same horizontal spacing).M
- (Mid) Move cursor to middle line in current screen (with same horizontal spacing).gg
- Top of file (with same horizontal spacing).G
- End of file (with same horizontal spacing).zz
- Move current line to screen center (with same horizontal spacing).z.
- Move current line at screen center and go to beginning of line.zt
- Move current line to screen top (with same horizontal spacing).zb
- Move current line to screen bottom (with same horizontal spacing).C-y
- Move current line below by 1 while keeping the cursor constant.C-e
- Move current line above by 1 while keeping the cursor constant.C-d
- Go down half a screen.C-o
- Go back to previous file.C-i
- Go forward to previous file.g ;
- Go to last change.g ,
- Reverse go to last change.
Lines
g q q
- Reformat lines taking over multiple visual lines.j
- Go up 1 line.k
- Go down 1 line.10 j
- Go down 10 lines.10 k
- Go up 10 lines.g j
- Go down 1 visual line.g k
- Go up 1 visual line.0
- Go to beginning of current line.$
- Go to end of current line.A
- Go to very end of current line and go to insert mode.I
- Go to very beginning of current line and go to insert mode.^
- Go to first non-blank character of current line.g_
- Go to last non-blank character of current line.o
- Create new line below current line and enter insert mode.O
- Create new line above current line and enter insert mode.(
- Go to paragraph above.*)
- Go to paragraph below.*J
- Join with line below.
Words
Small words are delineated by -, ., !, but not _. Otherwise it is considered a big word. E.g. "first" and "word" in "first-word" is considered small words, while "first-word" itself is considered a big word.
e
- Move forward by a word to the end of the word/consider current small word.w
- Move forward by a word to the beginning of the word/consider current small word.E
- Move forward by a word to the end of the word/consider current large word.W
- Move forward by a word to the beginning of the word/consider current large word.b
- Move forward by a word to the end of the word.
Text objects
i w
- (Inner word) Considers the current word as whole.i "
- (Inner quotes) Considers the content inside quotes.i [
- (Inner square brackets)i {
- (Inner curly brackets)i (
- (Inner parentheses)i h
- (Inner HTML tags)i p
- (Inner paragraph)a w
- (Around word) Considers the current word as whole.a "
- (Around quotes) Considers the content inside quotes.a [
- (Around square brackets)a {
- (Around curly brackets)a (
- (Around parentheses)a h
- (Around HTML tags)a p
- (Around paragraph)
Search
*
- Searches for occurences of current word, successive use goes to next occurences.#
- Searches for occurences of current word, successive use goes to previous occurences.f
- (find) Go to next occurence of successive character in current line, e.g.f l
goes to next l.t
- (till) Go to next occurence of successive character in current line not including that character./
- Followed bystring
to search for next occurence ofstring
. Usen
to go to next occurence ofstring
in file,N
to go to previous occurence.?
- Followed bystring
to search for previous occurence ofstring
. Usen
to go to previous occurence ofstring
in file.%
- When cursor is at at any form of bracket, go to its other pair assuming it exists.
Verbs
Verbs are often combined with all the above commands. The main ones
are d
for delete, c
for change (delete and enter insert mode), y
for
yank (which means copy).
x
- Delete visual block.s
- Delete current character under cursor and enter insert mode.~
- Change capitalization of character under cursor.d <MOTION>
- Delete a following motion.d w
- Delete (including any blank space right after) until end of current small word.d e
- Delete (excluding any blank space right after) until end of current small word.d W
- Delete (including any blank space right after) until end of current big word.d E
- Delete (excluding any blank space right after) until end of current big word.d i w
- Delete current small word.d i W
- Delete current big word.d 10 j
- Delete current line and the 10 lines below it.d 10 k
- Delete the current line and the 10 lines above it.d $
- Delete until end of current line (try if same asD
)
c <MOTION>
- Delete and insert a following motion.c w
- Delete (including any blank space right after) until end of current small word and enter insert mode.c e
- Delete (excluding any blank space right after) until end of current small word and enter insert mode.c W
- Delete (including any blank space right after) until end of current big word and enter insert mode.c E
- Delete (excluding any blank space right after) until end of current big word and enter insert mode.
g u <MOTION>
- Uncapitalize a following motion.g u f .
- Uncapitalize all characters from cursor to next.
character.
g U <MOTION>
- Capitalize a following motion.g U u
- Capitalize current line.
g ~ <MOTION>
- Change capitalization of a following motion.g f <FILENAME>
- Open a file with the given name.g v
- Move to last visual highlight.J
- Joins next line with previous line and adds a blank space character (can be applied to visual highlight blocks)g J
- Joins next line with previous line (can be applied to visual highlight blocks)g &
- Apply last used substitute command over the whole file..
- Repeat last change.
Visual mode
v <MOTION>
- Visual highlight a following motion.*
- Visual highlight current word.
Registers
R
- Enter register mode, where all edits done before leaving to command mode can be repeated via.
.C-r
in actual vim, this is a personal keymap.
Macros
q <CHAR>
Commands
:norm <COMMAND>
- Apply a given sequence/macro to visual selection.:read !<SHELL COMMAND>
- Insert output from shell command.
Windows/Buffers (In normal mode)
C ^
- Switch to last buffer.C-w q
- Close window.C-w r
- Rotate windows.C-w s
- Split window.C-w v
- Split window vertically.C-w w
- Go to other window.