After some
poking around, I didn't spot a
nifty command reference for vim. So lets see what we can do about that... Why call them
cheat codes you ask? Well, it is
vim.
Some people think that all
commands in
vi and vim are
secret.
--Node Gods: should this be split up?--
- Insert mode
- Normal mode
- Text objects
- Window commands
- Square bracket commands
- Commands starting with 'g'
- Visual mode
- Command-line editing
- EX commands
1. Insert mode
- CTRL-@
- insert previously inserted text and stop insert
- CTRL-A
- insert previously inserted text
- CTRL-B
- not used
- CTRL-C
- quit insert mode, without checking for abbreviation, unless 'insertmode' set.
- CTRL-D
- delete one shiftwidth of indent in the current line
- CTRL-E
- insert the character which is below the cursor
- CTRL-F
- not used
- CTRL-G
- reserved for future expansion
- <BS>
- delete character before the cursor
- {char1}<BS>{char2}
- enter digraph (only when 'digraph' option set)
- CTRL-H
- same as <BS>
- <Tab>
- insert a <Tab> character
- CTRL-I
- same as <Tab>
- <NL>
- same as <CR>
- CTRL-J
- same as <CR>
- CTRL-K {char1} {char2}
- enter digraph
- CTRL-L
- when 'insertmode' set: Leave Insert mode
- <CR>
- begin new line
- CTRL-M
- same as <CR>
- CTRL-N
- find next match for keyword in front of the cursor
- CTRL-O
- execute a single command and return to insert mode
- CTRL-P
- find previous match for keyword in front of the cursor
- CTRL-Q
- same as CTRL-V (used for terminal control flow)
- CTRL-R {0-9a-z"%#*:=}
- insert the contents of a register
- CTRL-R CTRL-R {0-9a-z"%#*:=}
- insert the contents of a register literally
- CTRL-R CTRL-O {0-9a-z"%#*:=}
- insert the contents of a register literally and don't auto-indent
- CTRL-R CTRL-P {0-9a-z"%#*:=}
- insert the contents of a register literally and fix indent.
- CTRL-S
- (used for terminal control flow)
- CTRL-T
- insert one shiftwidth of indent in current line
- CTRL-U
- delete all entered characters in the current line
- CTRL-V {char}
- insert next non-digit literally
- CTRL-V {number}
- insert three digit decimal number as a single byte.
- CTRL-W
- delete word before the cursor
- CTRL-X {mode}
- enter CTRL-X sub mode, see below
- CTRL-Y
- insert the character which is above the cursor
- CTRL-Z
- when 'insertmode' set: suspend Vim
- <Esc>
- end insert mode (unless 'insertmode' set)
- CTRL-[
- same as <Esc>
- CTRL-\ CTRL-N
- go to Normal mode
- CTRL-\ a - z
- reserved for extensions
- CTRL-\ others
- not used
- CTRL-]
- trigger abbreviation
- CTRL-^
- not used
- CTRL-_
- When 'allowrevins' set: change language (Hebrew, Farsi) {only when compiled with +rightleft feature}
- <Space>
- to '~' not used, except '0' and '^' followed by CTRL-D
- 0 CTRL-D
- delete all indent in the current line
- ^ CTRL-D
- delete all indent in the current line, restore it in the next line
- <Down>
- cursor one line down
- <S-Down>
- same as <PageDown>
- <Home>
- cursor to start of line
- <C-Home>
- cursor to start of file
- <End>
- cursor past end of line
- <C-End>
- cursor past end of file
- <PageUp>
- one screenfull backward
- <PageDown>
- one screenfull forward
- <F1>
- same as <Help>
- <Help>
- stop insert mode and display help window
- <Insert>
- toggle Insert/Replace mode
- <LeftMouse>
- cursor at mouse click
- <MouseDown>
- scroll three lines downwards
- <S-MouseDown>
- scroll a full page downwards
- <MouseUp>
- scroll three lines upwards
- <S-MouseUp>
- scroll a full page upwards
Commands in CTRL-X submode
- CTRL-X CTRL-D
- complete defined identifiers
- CTRL-X CTRL-E
- scroll up
- CTRL-X CTRL-F
- complete file names
- CTRL-X CTRL-I
- complete identifiers
- CTRL-X CTRL-K
- complete identifiers from dictionary
- CTRL-X CTRL-L
- complete whole lines
- CTRL-X CTRL-N
- next completion
- CTRL-X CTRL-P
- previous completion
- CTRL-X CTRL-Y
- scroll down
- CTRL-X CTRL-]
- complete tags
{not available when compiled without the +insert_expand feature}
2. Normal mode
- CHAR
- any non-blank character
- WORD
- any sequences of non-blank characters
- N
- a number entered before the command
- {motion}
- a cursor movement command
- Nmove
- the text that is moved over with a {motion}
- SECTION
- a section that possibly starts with '}' instead of '{'
- ¹
- cursor movement command
- ²
- can be undone/redone
- CTRL-@
- not used
- CTRL-A
- add N to number at/after cursor²
- CTRL-B
- scroll N screens Backwards¹
- CTRL-C
- interrupt current (search) command
- CTRL-D
- scroll Down N lines (default: half a screen)
- CTRL-E
- scroll N lines upwards (N lines Extra)
- CTRL-F
- scroll N screens Forward¹
- CTRL-G
- display current file name and position
- <BS>
- same as "h"¹
- CTRL-H
- same as "h"¹
- <Tab>
- go to N newer entry in jump list¹
- CTRL-I
- same as <Tab>¹
- <NL>
- same as "j"¹
- CTRL-J
- same as "j"¹
- CTRL-K
- not used
- CTRL-L
- redraw screen
- <CR>
- cursor to the first CHAR N lines lower¹
- CTRL-M>
- same as <CR>¹
- CTRL-N
- same as "j"¹
- CTRL-O
- go to N older entry in jump list¹
- CTRL-P
- cursor N lines upward¹
- CTRL-Q
- (used for terminal control flow)
- CTRL-R
- redo changes which were undone with 'u'²
- CTRL-S
- (used for terminal control flow)
- CTRL-T
- jump to N older Tag in tag list
- CTRL-U
- scroll N lines Upwards (default: half a screen)
- CTRL-V
- start blockwise Visual mode
- CTRL-W {char}
- window commands
- CTRL-X
- subtract N from number at/after cursor²
- CTRL-Y
- scroll N lines downwards
- CTRL-Z
- suspend program (or start new shell)
- CTRL-[
- <Esc> not used
- CTRL-\ CTRL-N
- go to Normal mode (no-op)
- CTRL-\
- a - z reserved for extensions
- CTRL-\
- others not used
- CTRL-]
- :ta to ident under cursor
- CTRL-^
- edit Nth alternate file (equivalent to ":e #N")
- CTRL-_
- not used
- <Space>
- same as "l"¹
- !{motion}{filter}
- filter Nmove text through the {filter} command²
- !!{filter}
- filter N lines through the {filter} command²
- "{a-zA-Z0-9.%#:-"}
- use buffer {a-zA-Z0-9.%#:-"} for next delete, yank or put (upper case to append) ({.%#:} only work with put)
- #
- search backward for the Nth occurrence of the ident under the cursor¹
- $
- cursor to the end of Nth next line¹
- %
- find the next (curly/square) bracket on this line and go to its match, or go to matching comment bracket, or go to matching preprocessor directive.¹
- {count}%
- go to N percentage in the file¹
- &
- repeat last :s²
- '{a-zA-Z0-9}
- cursor to the first CHAR on the line with mark {a-zA-Z0-9}¹
- ''
- cursor to the first CHAR of the line where the cursor was before the latest jump.¹
- '<
- cursor to the first CHAR of the line where highlighted area starts/started in the current buffer.¹
- '>
- cursor to the first CHAR of the line where highlighted area ends/ended in the current buffer.¹
- '[
- cursor to the first CHAR on the line of the start of last operated text or start of putted text¹
- ']
- cursor to the first CHAR on the line of the end of last operated text or end of putted text¹
- (
- cursor N sentences backward¹
- )
- cursor N sentences forward¹
- *
- search forward for the Nth occurrence of the ident under the cursor¹
- +
- cursor to the first CHAR N lines lower¹
- ,
- repeat latest f, t, F or T in opposite direction N times¹
- -
- cursor to the first CHAR N lines higher¹
- .
- repeat last change with count replaced with N²
- /{pattern}<CR>
- search forward for the Nth occurrence of {pattern}¹
- /<CR>
- search forward for {pattern} of last search¹
- 0
- cursor to the first char of the line¹
- 1
- prepend to command to give a count
- 2
- "
- 3
- "
- 4
- "
- 5
- "
- 6
- "
- 7
- "
- 8
- "
- 9
- "
- :
- start entering an Ex command
- {count}:
- start entering an Ex command with range from current line to N lines down
- ;
- repeat latest f, t, F or T N times¹
- <{motion}
- shift Nmove lines one 'shiftwidth' leftwards²
- <<
- shift N lines one 'shiftwidth' leftwards²
- ={motion}
- filter Nmove lines through "indent"²
- ==
- filter N lines through "indent"²
- >{motion}
- shift Nmove lines one 'shiftwidth' rightwards²
- >>
- shift N lines one 'shiftwidth' rightwards²
- ?{pattern}<CR>
- search backward for the Nth previous occurrence of {pattern}¹
- ?<CR>
- search backward for {pattern} of last search¹
- @{a-z}
- execute the contents of named buffer {a-z} N times²
- @:
- repeat the previous ":" command N times
- @@
- repeat the previous @{a-z} N times²
- A
- append text after the end of the line N times²
- B
- cursor N WORDS backward¹
- ["x]C
- change from the cursor position to the end of the line, and N-1 more lines [into buffer x] synonym for "c$"²
- ["x]D
- delete the characters under the cursor until the end of the line and N-1 more lines [into buffer x] synonym for "d$"²
- E
- cursor forward to the end of WORD N¹
- F{char}
- cursor to the Nth occurrence of {char} to the left¹
- G
- cursor to line N, default last line¹
- H
- cursor to line N from top of screen¹
- I
- insert text before the first CHAR on the line N times²
- J
- Join N lines; default is 2²
- K
- lookup Keyword under the cursor with 'keywordprg'
- L
- cursor to line N from bottom of screen¹
- M
- cursor to middle line of screen¹
- N
- repeat the latest '/' or '?' N times in opposite direction¹
- O
- begin a new line above the cursor and insert text, repeat N times²
- ["x]P
- put the text [from buffer x] before the cursor N times²
- Q
- switch to "Ex" mode
- R
- enter replace mode: overtype existing characters, repeat the entered text N-1 times²
- ["x]S
- delete N lines [into buffer x] and start insert; synonym for "^cc" or "0cc", depending on autoindent²
- T{char}
- cursor till after Nth occurrence of {char} to the left¹
- U
- undo all latest changes on one line²
- V
- start linewise Visual mode
- W
- cursor N WORDS forward¹
- ["x]X
- delete N characters before the cursor [into buffer x]²
- ["x]Y
- yank N lines [into buffer x] synonym for "yy"
- ZZ
- store current file if modified, and exit
- ZQ
- exit current file always
- [{char}
- square bracket command (see below)
- \
- not used
- ]{char}
- square bracket command (see below)
- ^
- cursor to the first CHAR of the line¹
- _
- cursor to the first CHAR N - 1 lines lower¹
- `{a-zA-Z0-9}
- cursor to the mark {a-zA-Z0-9}¹
- `<
- cursor to the start of the highlighted area¹
- `>
- cursor to the end of the highlighted area¹
- `[
- cursor to the start of last operated text or start of putted text¹
- `]
- cursor to the end of last operated text or end of putted text¹
- ``
- cursor to the position before latest jump¹
- a
- append text after the cursor N times²
- b
- cursor N words backward¹
- ["x]c{motion}
- delete Nmove text [into buffer x] and start insert²
- ["x]cc
- delete N lines [into buffer x] and start insert²
- ["x]d{motion}
- delete Nmove text [into buffer x]²
- ["x]dd
- delete N lines [into buffer x]²
- e
- cursor forward to the end of word N¹
- f{char}
- cursor to Nth occurrence of {char} to the right¹
- g{char}
- extended commands, see below
- h
- cursor N chars to the left¹
- i
- insert text before the cursor N times²
- j
- cursor N lines downward¹
- k
- cursor N lines upward¹
- l
- cursor N chars to the right¹
- m{A-Za-z}
- set mark {A-Za-z} at cursor position
- n
- repeat the latest '/' or '?' N times¹
- o
- begin a new line below the cursor and insert text, repeat N times²
- ["x]p
- put the text [from register x] after the cursor N times²
- q{0-9a-zA-Z"}
- record typed characters into named register {0-9a-zA-Z"} (upper case to append)
- q
- (while recording) stops recording
- r{char}
- replace N chars with {char}²
- ["x]s
- (substitute) delete N characters [into buffer x] and start insert²
- t{char}
- cursor till before Nth occurrence of {char} to the right¹
- u
- undo changes²
- v
- start characterwise Visual mode
- w
- cursor N words forward¹
- ["x]x
- delete N characters under and after the cursor [into buffer x]²
- ["x]y{motion}
- yank Nmove text [into buffer x]
- ["x]yy
- yank N lines [into buffer x]
- z<CR>
- redraw, cursor line to top of window, cursor on first non-blank
- z{height}<CR>
- redraw, make window {height} lines high
- z+
- cursor on line N (default line below window), otherwise like "z<CR>"
- z-
- redraw, cursor line at bottom of window, cursor on first non-blank
- z.
- redraw, cursor line to center of window, cursor on first non-blank
- z^
- cursor on line N (default line above window), otherwise like "z-"
- zb
- redraw, cursor line at bottom of window
- ze
- when 'wrap' off scroll horizontally to position the cursor at the end (right side) of the screen
- zh
- when 'wrap' off scroll screen N characters to the right
- zl
- when 'wrap' off scroll screen N characters to the left
- zs
- when 'wrap' off scroll horizontally to position the cursor at the start (left side) of the screen
- zt
- redraw, cursor line at top of window
- zz
- redraw, cursor line at center of window
- z<Left>
- same as "zh"
- z<Right>
- same as "zl"
- {
- cursor N paragraphs backward¹
- |
- cursor to column N¹
- }
- cursor N paragraphs forward¹
- ~
- 'tildeop' off: switch case of N characters under cursor and move the cursor N characters to the right²
- ~{motion}
- 'tildeop' on: switch case of Nmove text
- <C-End>
- same as "G"¹
- <C-Home>
- same as "gg"¹
- <C-Left>
- same as "b"¹
- <C-LeftMouse>
- ":ta" to the keyword at the mouse click
- <C-Right>
- same as "w"¹
- <C-RightMouse>
- same as "CTRL-T"
- ["x]<Del>
- same as "x"²
- {count}<Del>
- remove the last digit from {count}
- <Down>
- same as "j"¹
- <End>
- same as "$"¹
- <F1>
- same as <Help>
- <Help>
- open a help window
- <Home>
- same as "0"¹
- <Insert>
- same as "i"²
- <Left>
- same as "h"¹
- <LeftMouse>
- move cursor to the mouse click position¹
- <MiddleMouse>
- same as "P" at the mouse click position²
- <PageDown>
- same as CTRL-F
- <PageUp>
- same as CTRL-B
- <Right>
- same as "l"¹
- <RightMouse>
- start Visual mode, move cursor to the mouse click position
- <S-Down>
- same as CTRL-F¹
- <S-Left>
- same as "b"¹
- <S-LeftMouse>
- same as "*" at the mouse click position
- <S-Right>
- same as "w"¹
- <S-RightMouse>
- same as "#" at the mouse click position
- <S-Up>
- same as CTRL-B¹
- <Undo>
- same as "u"²
- <Up>
- same as "k"¹
- <MouseDown>
- scroll three lines downwards
- <S-MouseDown>
- scroll a full page downwards
- <MouseUp>
- scroll three lines upwards
- <S-MouseUp>
- scroll a full page upwards
2.1 Text objects
These can be used after an operator or in Visual mode to select an object.
- a(
- same as ab
- a)
- same as ab
- a<
- "a <>" from '<' to the matching '>'
- a>
- same as a<
- aB
- "a Block" from "[{" to "]}" (with brackets)
- aW
- "a WORD" (with white space)
- a[
- "a []" from '[' to the matching ']'
- a]
- same as a[
- ab
- "a block" from "[(" to "])" (with braces)
- ap
- "a paragraph" (with white space)
- as
- "a sentence" (with white space)
- aw
- "a word" (with white space)
- a{
- same as aB
- a}
- same as aB
- i(
- same as ib
- i)
- same as ib
- i<
- "inner <>" from '<' to the matching '>'
- i>
- same as i<
- iB
- "inner Block" from "[{" and "]}"
- iW
- "inner WORD"
- i[
- "inner []" from '[' to the matching ']'
- i]
- same as i[
- ib
- "inner block" from "[(" to "])"
- ip
- "inner paragraph"
- is
- "inner sentence"
- iw
- "inner word"
- i{
- same as iB
- i}
- same as iB
2.2 Window commands
- CTRL-W CTRL-B
- same as "CTRL-W b"
- CTRL-W CTRL-C
- same as "CTRL-W c"
- CTRL-W CTRL-D
- same as "CTRL-W d"
- CTRL-W CTRL-F
- same as "CTRL-W f"
- CTRL-W CTRL-G
- same as "CTRL-W g .."
- CTRL-W CTRL-I
- same as "CTRL-W i"
- CTRL-W CTRL-J
- same as "CTRL-W j"
- CTRL-W CTRL-K
- same as "CTRL-W k"
- CTRL-W CTRL-N
- same as "CTRL-W n"
- CTRL-W CTRL-O
- same as "CTRL-W o"
- CTRL-W CTRL-P
- same as "CTRL-W p"
- CTRL-W CTRL-Q
- same as "CTRL-W q"
- CTRL-W CTRL-R
- same as "CTRL-W r"
- CTRL-W CTRL-S
- same as "CTRL-W s"
- CTRL-W CTRL-T
- same as "CTRL-W t"
- CTRL-W CTRL-W
- same as "CTRL-W w"
- CTRL-W CTRL-X
- same as "CTRL-W x"
- CTRL-W CTRL-Z
- same as "CTRL-W z"
- CTRL-W CTRL-]
- same as "CTRL-W ]"
- CTRL-W CTRL-^
- same as "CTRL-W ^"
- CTRL-W CTRL-_
- same as "CTRL-W _"
- CTRL-W +
- increase current window height N lines
- CTRL-W -
- decrease current window height N lines
- CTRL-W =
- make all windows the same height
- CTRL-W R
- rotate windows upwards N times
- CTRL-W S
- same as "CTRL-W s"
- CTRL-W W
- go to N previous window (wrap around)
- CTRL-W ]
- split window and jump to tag under cursor
- CTRL-W ^
- split current window and edit alternate file N
- CTRL-W _
- set current window height to N (default: very high)
- CTRL-W b
- go to bottom window
- CTRL-W c
- close current window (like ":close")
- CTRL-W d
- split window and jump to definition under the cursor
- CTRL-W f
- split window and edit file name under the cursor
- CTRL-W g CTRL-]
- split window and do ":tjump" to tag under cursor
- CTRL-W g ]
- split window and do ":tselect" for tag under cursor
- CTRL-W g }
- do a ":ptjump" to the tag under the cursor
- CTRL-W i
- split window and jump to declaration of identifier under the cursor
- CTRL-W j
- go to N next window (stop at last window)
- CTRL-W k
- go to N previous window (stop at first window)
- CTRL-W n
- open new window, N lines high
- CTRL-W o
- close all but current window (like ":only")
- CTRL-W p
- go to previous (last accessed) window
- CTRL-W q
- quit current window (like ":quit")
- CTRL-W r
- rotate windows downwards N times
- CTRL-W s
- split current window in two parts, new window N lines high
- CTRL-W t
- go to top window
- CTRL-W w
- go to N next window (wrap around)
- CTRL-W x
- exchange current window with window N (default: next window)
- CTRL-W z
- close preview window
- CTRL-W }
- show tag under cursor in preview window
- CTRL-W <Down>
- same as "CTRL-W j"
- CTRL-W <Up>
- same as "CTRL-W k"
2.3 Square bracket commands
- [_CTRL-D
- jump to first #define found in current and included files matching the word under the cursor, start searching at beginning of current file
- [_CTRL-I
- jump to first line in current and included files that contains the word under the cursor, start searching at beginning of current file
- [#
- cursor to N previous unmatched #if, #else or #ifdef¹
- [(
- cursor N times back to unmatched '('¹
- [*
- same as "[/"¹
- [/
- cursor to N previous start of a C comment¹
- [D
- list all defines found in current and included files matching the word under the cursor, start searching at beginning of current file
- [I
- list all lines found in current and included files that contain the word under the cursor, start searching at beginning of current file
- [P
- same as "[p"²
- [[
- cursor N sections backward¹
- []
- cursor N SECTIONS backward¹
- [d
- show first #define found in current and included files matching the word under the cursor, start searching at beginning of current file
- [f
- same as "gf"
- [i
- show first line found in current and included files that contains the word under the cursor, start searching at beginning of current file
- [p
- like "P", but adjust indent to current line²
- [m
- cursor N times back to start of member function¹
- [{
- cursor N times back to unmatched '{'¹
- [<MiddleMouse>
- same as "[p"²
- ]_CTRL-D
- jump to first #define found in current and included files matching the word under the cursor, start searching at cursor position
- ]_CTRL-I
- jump to first line in current and included files that contains the word under the cursor, start searching at cursor position
- ]#
- cursor to N next unmatched #endif or #else¹
- ])
- cursor N times forward to unmatched ')'¹
- ]*
- same as "]/"¹
- ]/
- cursor to N next end of a C comment¹
- ]D
- list all #defines found in current and included files matching the word under the cursor, start searching at cursor position
- ]I
- list all lines found in current and included files that contain the word under the cursor, start searching at cursor position
- ]P
- same as "[p"²
- ][
- cursor N SECTIONS forward¹
- ]]
- cursor N sections forward¹
- ]d
- show first #define found in current and included files matching the word under the cursor, start searching at cursor position
- ]f
- same as "gf"
- ]i
- show first line found in current and included files that contains the word under the cursor, start searching at cursor position
- ]p
- like "p", but adjust indent to current line²
- ]m
- cursor N times forward to end of memberfunction¹
- ]}
- cursor N times forward to unmatched '}'¹
- ]<MiddleMouse>
- same as "]p"²
2.4 Commands starting with 'g'
- g_CTRL-A
- only when compiled with MEM_PROFILE defined: dump a memory profile
- g_CTRL-G
- show information about current cursor position
- g_CTRL-H
- start Select block mode
- g_CTRL-]
- ":tjump" to the tag under the cursor
- g#
- like "#", but without using "\<" and "\>"¹
- g$
- when 'wrap' off go to rightmost character of the current line that is on the screen; when 'wrap' on go to the rightmost character of the current screen line¹
- g*
- like "*", but without using "\<" and "\>"¹
- g0
- when 'wrap' off go to leftmost character of the current line that is on the screen; when 'wrap' on go to the leftmost character of the current screen line¹
- g?
- Rot13 encoding operator²
- g??
- Rot13 encode current line²
- g?g?
- Rot13 encode current line²
- gD
- go to definition of word under the cursor in current file¹
- gE
- go backwards to the end of the previous WORD¹
- gH
- start Select line mode
- gI
- like "I", but always start in column 1²
- gJ
- join lines without inserting space²
- ["x]gP
- put the text [from register x] before the cursor N times, leave the cursor after it²
- gR
- enter virtual replace mode²
- gU{motion}
- make Nmove text uppercase²
- gV
- don't reselect the previous Visual area when executing a mapping or menu in Select mode
- g]
- :tselect on the tag under the cursor
- g^
- when 'wrap' off go to leftmost non-white character of the current line that is on the screen; when 'wrap' on go to the leftmost non-white character of the current screen line¹
- ga
- print ascii value of character under the cursor
- gd
- go to definition of word under the cursor in current function¹
- ge
- go backwards to the end of the previous word¹
- gf
- start editing the file whose name is under the cursor
- gg
- cursor to line N, default first line¹
- gh
- start Select mode
- gj
- like "j", but when 'wrap' on go N screen lines down¹
- gk
- like "k", but when 'wrap' on go N screen lines up¹
- gm
- go to character at middle of the screenline¹
- go
- cursor to byte N in the buffer¹
- ["x]gp
- put the text [from register x] after the cursor N times, leave the cursor after it²
- gq{motion}
- format Nmove text²
- gr{char}
- virtual replace N chars with {char}²
- gs
- go to sleep for N seconds (default 1)
- gu{motion}
- make Nmove text lowercase²
- gv
- reselect the previous Visual area
- g~{motion}
- swap case for Nmove text²
- g<Down>
- same as "gj"¹
- g<End>
- same as "g$"¹
- g<Home>
- same as "g0"¹
- g<LeftMouse>
- same as <C-LeftMouse>
- g<MiddleMouse>
- same as <C-MiddleMouse>
- g<RightMouse>
- same as <C-RightMouse>
- g<Up>
- same as "gk"¹
3. Visual mode
Most commands in Visual mode are the same as in Normal mode. The ones listed here are those that are different.
- CTRL-\ CTRL-N
- stop Visual mode
- CTRL-G
- toggle between Visual mode and Select mode
- <BS>
- Select mode: delete highlighted area²
- CTRL-H
- same as <BS>²
- CTRL-O
- switch from Select to Visual mode for one command
- CTRL-V
- make Visual mode blockwise or stop Visual mode
- CTRL-]
- jump to highlighted tag
- !{filter}
- filter the highlighted lines through the external command {filter}²
- :
- start a command-line with the highlighted lines as a range
- <
- shift the highlighted lines one 'shiftwidth' left²
- =
- filter the highlighted lines through the external program given with the 'equalprg' option²
- >
- shift the highlighted lines one'shiftwidth' right²
- A
- block mode: append same text in all lines, after the highlighted area²
- C
- delete the highlighted lines and start insert²
- D
- delete the highlighted lines²
- I
- block mode: insert same text in all lines, before the highlighted area²
- J
- join the highlighted lines²
- K
- run 'keywordprg' on the highlighted area
- O
- Move horizontally to other corner of area.
- Q
- does not start Ex mode
- R
- delete the highlighted lines and start insert²
- S
- delete the highlighted lines and start insert²
- U
- make highlighted area uppercase²
- V
- make Visual mode linewise or stop Visual mode
- X
- delete the highlighted lines²
- Y
- yank the highlighted lines
- a(
- same as ab
- a)
- same as ab
- a<
- extend highlighted area with a <> block
- a>
- same as a<
- aB
- extend highlighted area with a {} block
- aW
- extend highlighted area with "a WORD"
- a[
- extend highlighted area with a [] block
- a]
- same as a[
- ab
- extend highlighted area with a () block
- ap
- extend highlighted area with a paragraph
- as
- extend highlighted area with a sentence
- aw
- extend highlighted area with "a word"
- a{
- same as aB
- a}
- same as aB
- c
- delete highlighted area and start insert²
- d
- delete highlighted area²
- gJ
- join the highlighted lines without inserting spaces²
- gq
- format the highlighted lines²
- gv
- exchange current and previous highlighted area
- i(
- same as ib
- i)
- same as ib
- i<
- extend highlighted area with inner <> block
- i>
- same as i<
- iB
- extend highlighted area with inner {} block
- iW
- extend highlighted area with "inner WORD"
- i[
- extend highlighted area with inner [] block
- i]
- same as i[
- ib
- extend highlighted area with inner () block
- ip
- extend highlighted area with inner paragraph
- is
- extend highlighted area with inner sentence
- iw
- extend highlighted area with "inner word"
- i{
- same as iB
- i}
- same as iB
- o
- move cursor to other corner of area
- r
- delete highlighted area and start insert²
- s
- delete highlighted area and start insert²
- u
- make highlighted area lowercase²
- v
- make Visual mode characterwise or stop Visual mode
- x
- delete the highlighted area²
- y
- yank the highlighted area
- ~
- swap case for the highlighted area²
4. Command-line editing
Get to the command-line with the ':', '!', '/' or '?' commands. Normalcharacters are inserted at the current cursor position. "Completion" below refers to context-sensitive completion. It will complete file names, tags, commands etc. as appropriate.
- CTRL-@
- not used
- CTRL-A
- do completion on the pattern in front of the cursor and insert all matches
- CTRL-B
- cursor to begin of command-line
- CTRL-C
- same as <ESC>
- CTRL-D
- list completions that match the pattern in front of the cursor
- CTRL-E
- cursor to end of command-line
- CTRL-F
- not used
- CTRL-G
- not used
- <BS>
- delete the character in front of the cursor
- {char1} <BS> {char2}
- enter digraph when 'digraph' is on
- CTRL-H
- same as <BS>
- <Tab>
- if 'wildchar' is <Tab>: Do completion on the pattern in front of the cursor
- <S-Tab>
- same as CTRL-P
- 'wildchar'
- Do completion on the pattern in front of the cursor (default: <Tab>)
- CTRL-I
- same as <Tab>
- <NL>
- same as <CR>
- CTRL-J
- same as <CR>
- CTRL-K {char1} {char2}
- enter digraph
- CTRL-L
- do completion on the pattern in front of the cursor and insert the longest common part
- <CR>
- execute entered command
- CTRL-M
- same as <CR>
- CTRL-N
- after using 'wildchar' with multiple matches: go to next match, otherwise: same as <Down>
- CTRL-O
- not used
- CTRL-P
- after using 'wildchar' with multiple matches: go to previous match, otherwise: same as <Up>
- CTRL-Q
- same as CTRL-V (used for terminal control flow)
- CTRL-R {0-9a-z"%#*:= CTRL-F CTRL-P CTRL-W CTRL-A}
- insert the contents of a register or object under the cursor as if typed
- CTRL-R CTRL-R {0-9a-z"%#*:= CTRL-F CTRL-P CTRL-W CTRL-A}
- insert the contents of a register or object under the cursor literally
- CTRL-S
- (used for terminal control flow)
- CTRL-U
- remove all characters
- CTRL-V
- insert next non-digit literally, insert three digit decimal number as a single byte.
- CTRL-W
- delete the word in front of the cursor
- CTRL-X
- not used (reserved for completion)
- CTRL-Y
- not used
- CTRL-Z
- not used (reserved for suspend)
- <Esc>
- abandon command-line without executing it
- CTRL-[
- same as <Esc>
- CTRL-\ CTRL-N
- go to Normal mode, abandon command-line
- CTRL-\ a - z
- reserved for extensions
- CTRL-\ others
- not used
- CTRL-]
- not used
- CTRL-^
- not used
- CTRL-_
- when 'allowrevins' set: change language (Hebrew, Farsi)
- <Del>
- delete the character under the cursor
- <Left>
- cursor left
- <S-Left>
- cursor one word left
- <C-Left>
- cursor one word left
- <Right>
- cursor right
- <S-Right>
- cursor one word right
- <C-Right>
- cursor one word right
- <Up>
- recall previous command-line from history that matches pattern in front of the cursor
- <S-Up>
- recall previous command-line from history
- <Down>
- recall next command-line from history that matches pattern in front of the cursor
- <S-Down>
- recall next command-line from history
- <Home>
- cursor to start of command-line
- <End>
- cursor to end of command-line
- <PageDown>
- same as <S-Down>
- <PageUp>
- same as <S-Up>
- <Insert>
- toggle insert/overstrike mode
- <LeftMouse>
- cursor at mouse click
5. EX commands
This is a brief but complete listing of all the ":" commands, without mentioning any arguments. The optional part of the command name is inside []. The commands are sorted on the non-optional part of their name.
- :!
- filter lines or execute an external command
- :!!
- repeat last ":!" command
- :#
- same as ":number"
- :&
- repeat last ":substitute"
- :*
- execute contents of a register
- :<
- shift lines one 'shiftwidth' left
- :=
- print the cursor line number
- :>
- shift lines one 'shiftwidth' right
- :@
- execute contents of a register
- :@@
- repeat the previous ":@"
- :N[ext]
- go to previous file in the argument list
- :P[rint]
- print lines
- :X
- ask for encryption key
- :a[ppend]
- append text
- :ab[breviate]
- enter abbreviation
- :abc[lear]
- remove all abbreviations
- :al[l]
- open a window for each file in the argument list
- :am[enu]
- enter new menu item for all modes
- :an[oremenu]
- enter a new menu for all modes that will not be remapped
- :ar[gs]
- print the argument list
- :argu[ment]
- go to specific file in the argument list
- :as[cii]
- print ascii value of character under the cursor
- :au[tocmd]
- enter or show autocommands
- :aug[roup]
- select the autocommand group to use
- :aun[menu]
- remove menu for all modes
- :b[uffer]
- go to specific buffer in the buffer list
- :bN[ext]
- go to next buffer in the buffer list
- :ba[ll]
- open a window for each file in the buffer list
- :bad[d]
- add file to the buffer list
- :bd[elete]
- delete specific files from the buffer list
- :be[have]
- set mouse and selection behavior
- :bl[ast]
- go to last file in the buffer list
- :bm[odified]
- go to next file in the buffer list that has been modified
- :bn[ext]
- go to next file in the buffer list
- :bp[revious]
- go to previous file in the buffer list
- :br[ewind]
- go to last file in the buffer list
- :brea[k]
- break out of while loop
- :bro[wse]
- use file selection dialog
- :buffers
- list all files in the buffer list
- :bun[load]
- unload a specific buffer
- :c[hange]
- replace a line or series of lines
- :cN[ext]
- go to previous error
- :ca[bbrev]
- like ":abbreviate" but for Command-line mode
- :cabc[lear]
- clear all abbreviations for Command-line mode
- :cal[l]
- call a function
- :cc
- go to specific error
- :cd
- change directory
- :ce[nter]
- format lines at the center
- :cf[ile]
- read the file with error messages
- :ch[ange]
- delete and insert lines
- :chd[ir]
- change directory
- :che[ckpath]
- list included files
- :cl[ist]
- list all errors
- :cla[st]
- go to the specified error, default last one
- :clo[se]
- close current window
- :cm[ap]
- like ":map" but for Command-line mode
- :cmapc[lear]
- clear all mappings for Command-line mode
- :cme[nu]
- add menu for Command-line mode
- :cn[ext]
- go to next error
- :cnew[er]
- go to newer error list
- :cnf[ile]
- go to first error in next file
- :cno[remap]
- like ":noremap" but for Command-line mode
- :cnorea[bbrev]
- like ":noreabbrev" but for Command-line mode
- :cnoreme[nu]
- like ":noremenu" but for Command-line mode
- :co[py]
- copy lines
- :col[der]
- go to older error list
- :com[mand]
- create user-defined command
- :comc[lear]
- clear all user-defined commands
- :con[tinue]
- go back to :while
- :conf[irm]
- prompt user when confirmation required
- :cp[revious]
- go to previous error
- :cq[uit]
- quit Vim with an error code
- :cr[ewind]
- go to the specified error, default first one
- :cs[cope]
- execute cscope command
- :cst[ag]
- use cscope to jump to a tag
- :cu[nmap]
- like ":unmap" but for Command-line mode
- :cuna[bbrev]
- like ":unabbrev" but for Command-line mode
- :cunme[nu]
- remove menu for Command-line mode
- :d[elete]
- delete lines
- :delc[ommand]
- delete user-defined command
- :delf[unction]
- delete a user function
- :di[splay]
- display registers
- :dig[raphs]
- show or enter digraphs
- :dj[ump]
- jump to #define
- :dl[ist]
- list #defines
- :do[autocmd]
- apply autocommands to current buffer
- :doautoa[ll]
- apply autocommands for all loaded buffers
- :ds[earch]
- list one #define
- :dsp[lit]
- split window and jump to #define
- :e[dit]
- edit a file
- :ec[ho]
- echoes the result of expressions
- :echoh[l]
- set highlighting for echo commands
- :echon
- same as :echo, but without <EOL>
- :el[se]
- part of an :if command
- :elsei[f]
- part of an :if command
- :em[enu]
- execute a menu by name
- :en[dif]
- end previous :if
- :endf[unction]
- end of a user function
- :endw[hile]
- end previous :while
- :ex
- same as ":edit"
- :exe[cute]
- execute result of expressions
- :exi[t]
- same as ":xit"
- :f[ile]
- show or set the current file name
- :files
- list all files in the buffer list
- :filet[ype]
- switch file type detection on/off
- :fin[d]
- find file in 'path' and edit it
- :fix[del]
- set key code of <Del>
- :fu[nction]
- define a user function
- :g[lobal]
- execute commands for matching lines
- :go[to]
- go to byte in the buffer
- :gr[ep]
- run 'grepprg' and jump to first match
- :gu[i]
- start the GUI
- :gv[im]
- start the GUI
- :h[elp]
- open a help window
- :helpf[ind]
- dialog to open a help window
- :hi[ghlight]
- specify highlighting methods
- :hid[e]
- hide current buffer for a command
- :his[tory]
- print a history list
- :i[nsert]
- insert text
- :ia[bbrev]
- like ":abbrev" but for Insert mode
- :iabc[lear]
- like ":abclear" but for Insert mode
- :if
- execute commands when condition met
- :ij[ump]
- jump to definition of identifier
- :il[ist]
- list lines where identifier matches
- :im[ap]
- like ":map" but for Insert mode
- :imapc[lear]
- like ":mapclear" but for Insert mode
- :ime[nu]
- add menu for Insert mode
- :ino[remap]
- like ":noremap" but for Insert mode
- :inorea[bbrev]
- like ":noreabbrev" but for Insert mode
- :inoreme[nu]
- like ":noremenu" but for Insert mode
- :int[ro]
- print the introductory message
- :is[earch]
- list one line where identifier matches
- :isp[lit]
- split window and jump to definition of identifier
- :iu[nmap]
- like ":unmap" but for Insert mode
- :iuna[bbrev]
- like ":unabbrev" but for Insert mode
- :iunme[nu]
- remove menu for Insert mode
- :j[oin]
- join lines
- :ju[mps]
- print the jump list
- :k
- set a mark
- :l[ist]
- print lines
- :la[st]
- go to the last file in the argument list
- :le[ft]
- left align lines
- :let
- assign a value to a variable or option
- :ls
- list all buffers
- :m[ove]
- move lines
- :ma[rk]
- set a mark
- :mak[e]
- execute external command 'makeprg' and parse error messages
- :map
- show or enter a mapping
- :mapc[lear]
- clear all mappings for Normal and Visual mode
- :marks
- list all marks
- :me[nu]
- enter a new menu item
- :mes[sages]
- view previously displayed messages
- :mk[exrc]
- write current mappings and settings to a file
- :mks[ession]
- write session info to a file
- :mkv[imrc]
- write current mappings and settings to a file
- :mod[e]
- show or change the screen mode
- :n[ext]
- go to next file in the argument list
- :new
- create a new empty window
- :nm[ap]
- like ":map" but for Normal mode
- :nmapc[lear]
- clear all mappings for Normal mode
- :nme[nu]
- add menu for Normal mode
- :nn[oremap]
- like ":noremap" but for Normal mode
- :nnoreme[nu]
- like ":noremenu" but for Normal mode
- :no[remap]
- enter a mapping that will not be remapped
- :noh[lsearch]
- suspend 'hlsearch' highlighting
- :norea[bbrev]
- enter an abbreviation that will not be remapped
- :noreme[nu]
- enter a menu that will not be remapped
- :norm[al]
- execute Normal mode commands
- :nu[mber]
- print lines with line number
- :nun[map]
- like ":unmap" but for Normal mode
- :nunme[nu]
- remove menu for Normal mode
- :o[pen]
- start open mode (not implemented)
- :om[ap]
- like ":map" but for Operator-pending mode
- :omapc[lear]
- remove all mappings for Operator-pending mode
- :ome[nu]
- add menu for Operator-pending mode
- :on[ly]
- close all windows except current one
- :ono[remap]
- like ":noremap" but for Operator-pending mode
- :onoreme[nu]
- like ":noremenu" but for Operator-pending mode
- :opt[ions]
- open the options-window
- :ou[nmap]
- like ":unmap" but for Operator-pending mode
- :ounme[nu]
- remove menu for Operator-pending mode
- :p[rint]
- print lines
- :pc[lose]
- close preview window
- :pe[rl]
- execute Perl command
- :perld[o]
- execute Perl command for each line
- :po[p]
- jump to older entry in tag stack
- :pp[op]
- ":pop" in preview window
- :pre[serve]
- write all text to swap file
- :prev[ious]
- go to previous file in argument list
- :pro[mptfind]
- Search dialog
- :promptr[epl]
- Search/Replace dialog
- :pt[ag]
- show tag in preview window
- :ptN[ext]
- ":tNext" in preview window
- :ptj[ump]
- ":tjump" and show tag in preview window
- :ptl[ast]
- ":tlast" in preview window
- :ptn[ext]
- ":tnext" in preview window
- :ptp[revious]
- ":tprevious" in preview window
- :ptr[ewind]
- ":trewind" in preview window
- :pts[elect]
- ":tselect" and show tag in preview window
- :pu[t]
- insert contents of register in the text
- :pw[d]
- print current directory
- :py[thon]
- execute Python command
- :pyf[ile]
- execute Python script file
- :q[uit]
- quit current window or Vim
- :qa[ll]
- quit Vim
- :r[ead]
- read file into the text
- :rec[over]
- recover a file from a swap file
- :red[o]
- redo one undone change
- :redi[r]
- redirect messages to a file or register
- :reg[isters]
- display the contents of registers
- :res[ize]
- change current window height
- :ret[ab]
- change tab size
- :retu[rn]
- return from a user function
- :rew[ind]
- go to the first file in the argument list
- :ri[ght]
- right align text
- :rv[iminfo]
- read from viminfo file
- :s[ubstitute]
- find and replace text
- :sN[ext]
- split window and go to previous file in argument list
- :sa[rgument]
- split window and go to specific file in argument list
- :sal[l]
- open a window for each file in argument list
- :sb[uffer]
- split window and go to specific file in the buffer list
- :sbN[ext]
- split window and go to previous file in the buffer list
- :sba[ll]
- open a window for each file in the buffer list
- :sbl[ast]
- split window and go to last file in buffer list
- :sbm[odified]
- split window and go to modified file in the buffer list
- :sbn[ext]
- split window and go to next file in the buffer list
- :sbp[revious]
- split window and go to previous file in the buffer list
- :sbr[ewind]
- split window and go to first file in the buffer list
- :se[t]
- show or set options
- :sf[ind]
- split current window and edit file in 'path'
- :sh[ell]
- escape to a shell
- :si[malt]
- Win32 GUI: simulate Windows ALT key
- :sl[eep]
- do nothing for a few seconds
- :sla[st]
- split window and go to last file in the argument list
- :sm[agic]
- :substitute with 'magic'
- :sn[ext]
- split window and go to next file in the argument list
- :sni[ff]
- send request to sniff
- :sno[magic]
- :substitute with 'nomagic'
- :so[urce]
- read Vim or Ex commands from a file
- :sp[lit]
- split current window
- :spr[evious]
- split window and go to previous file in the argument list
- :sr[ewind]
- split window and go to first file in the argument list
- :st[op]
- suspend the editor or escape to a shell
- :sta[g]
- split window and jump to a tag
- :star[tinsert]
- start Insert mode
- :stj[ump]
- do ":tjump" and split window
- :sts[elect]
- do ":tselect" and split window
- :sun[hide]
- same as ":unhide"
- :sus[pend]
- same as ":stop"
- :sv[iew]
- split window and edit file read-only
- :sw[apname]
- show the name of the current swap file
- :sy[ntax]
- syntax highlighting
- :sync[bind]
- sync scroll binding
- :t
- same as ":copy"
- :tN[ext]
- jump to previous matching tag
- :ta[g]
- jump to tag
- :tags
- show the contents of the tag stack
- :tc[l]
- execute Tcl command
- :tcld[o]
- execute Tcl command for each line
- :tclf[ile]
- execute Tcl script file
- :te[aroff]
- tear-off a menu
- :tj[ump]
- like ":tselect", but jump directly when there is only one match
- :tl[ast]
- jump to last matching tag
- :tm[enu]
- define menu tooltip
- :tn[ext]
- jump to next matching tag
- :tp[revious]
- jump to previous matching tag
- :tr[ewind]
- jump to first matching tag
- :ts[elect]
- list matching tags and select one
- :tu[nmenu]
- remove menu tooltip
- :u[ndo]
- undo last change(s)
- :una[bbreviate]
- remove abbreviation
- :unh[ide]
- open a window for each loaded file in the buffer list
- :unl[et]
- delete variable
- :unm[ap]
- remove mapping
- :unme[nu]
- remove menu
- :up[date]
- write buffer if modified
- :v[global]
- execute commands for not matching lines
- :ve[rsion]
- print version number and other info
- :vi[sual]
- same as ":edit", but turns off "Ex" mode
- :vie[w]
- edit a file read-only
- :vm[ap]
- like ":map" but for Visual mode
- :vmapc[lear]
- remove all mappings for Visual mode
- :vme[nu]
- add menu for Visual mode
- :vn[oremap]
- like ":noremap" but for Visual mode
- :vnoreme[nu]
- like ":noremenu" but for Visual mode
- :vu[nmap]
- like ":unmap" but for Visual mode
- :vunme[nu]
- remove menu for Visual mode
- :w[rite]
- write to a file
- :wN[ext]
- write to a file and go to previous file in argument list
- :wa[ll]
- write all (changed) buffers
- :wh[ile]
- execute loop for as long as condition met
- :wi[nsize]
- get or set window size (obsolete)
- :winp[os]
- get or set window position
- :wn[ext]
- write to a file and go to next file in argument list
- :wp[revious]
- write to a file and go to previous file in argument list
- :wq
- write to a file and quit window or Vim
- :wqa[ll]
- write all changed buffers and quit Vim
- :wv[iminfo]
- write to viminfo file
- :x[it]
- write if buffer changed and quit window or Vim
- :xa[ll]
- same as ":wqall"
- :y[ank]
- yank lines into a register
- :z
- display context lines
- :~
- repeat last ":substitute"
Thanks to Bram Moolenaar for a great editor. This command list was taken from index.txt of the "VIM REFERENCE MANUAL" for vim version 5.7 last changed: 2000 Apr 01.