VIM help file


VIM stands for Vi IMproved. Most of VIM was made by Bram Moolenaar.

Contents

Left-right motions
Up-down motions
Text object motions
Text objects
Pattern searches
Marks and motions
Various motions
Using tags
Scrolling
Inserting text
Keys in insert mode
Special keys in insert mode
Digraphs
Special inserts
Changing text
Visual mode
Complex changes
Deleting text
Copying and moving text
Repeating commands
Key mapping
Abbreviations
Options
Undo/Redo commands
External commands
Quickfix commands
Various commands
Command line editing
Ex ranges
Special Ex characters
Editing a file
Using the file list
Writing and quitting
Starting VIM
Automatic commands
Multi window functions
Buffer list functions

About copying Vim and Uganda
People who contributed
Vim on the World Wide Web
Where to send bug reports

List of documentation files

quick reference (this file)
alphabetical index
reference manual (Part 1)
reference manual (Part 2)
reference manual (Part 3)
reference manual (Part 4)
reference manual (Part 5)
reference manual (Part 6)
reference manual (Part 7)
reference manual (Part 8)
reference manual (Part 9)
reference for window commands
differences between Vim and Vi
list of available digraphs
tips on using Vim
about the Graphical User Interface
about right-to-left editing
about this version

Remarks about specific systems

Unix
Amiga
MS-DOS
Win-NT/95
Archimedes
Macintosh

How to ...


N is used to indicate an optional count that can be given before the command.

Left-right motions

N h left (also: CTRL-H, BS or cursor-left key)
N l right (also: <Space> or cursor-right key)
0 to first character in the line (also: <Home> key)
^ to first non-blank character in the line
N $ to the last character in the line (N-1 lines lower) (also: <End> key)
N g0 to first character in screen line (differs from "0" when lines wrap)
N g^ to first non-blank character in screen line (differs from "^" when lines wrap)
N g$ to last character in screen line (differs from "$" when lines wrap)
N | to column N (default: 0)
N f<char> to the Nth occurrence of <char> to the right
N F<char> to the Nth occurrence of <char> to the left
N t<char> till before the Nth occurrence of <char> to the right
N T<char> till before the Nth occurrence of <char> to the left
N ; repeat the last f, F, t or T N times
N , repeat the last f, F, t or T N times in opposite direction

Up-down motions

N k up N lines (also: CTRL-P and <Up>)
N j down N lines (also: CTRL-J, CTRL-N, <NL> and <Down>)
N - up N lines, on the first non-blank character
N + down N lines, on the first non-blank character (also: CTRL-M and <CR>)
N _ down N - 1 lines, on the first non-blank character
N G goto line N (default last line), on the first non-blank character
N gg goto line N (default first line), on the first non-blank character
N % goto line N percentage down in the file. N must be given, otherwise it is the % command.
N gk up N screen lines (differs from "k" when line wraps)
N gj down N screen lines (differs from "j" when line wraps)

Text object motions

N w N words forward
N W N blank-separated words forward
N e forward to the end of the Nth word
N E forward to the end of the Nth blank-separated word
N b N words backward
N B N blank-separated words backward
N ge backward to the end of the Nth word
N gE backward to the end of the Nth blank-separated word
N ) N sentences forward
N ( N sentences backward
N } N paragraphs forward
N { N paragraphs backward
N ]] N sections forward, at start of section
N [[ N sections backward, at start of section
N ][ N sections forward, at end of section
N [] N sections backward, at end of section
N [( N times back to unclosed <(>
N [( N times back to unclosed <{>
N ]) N times forward to unclosed <(>
N ]) N times forward to unclosed <{>
N [# N times back to unclosed #if or #else
N ]# N times forward to unclosed #else or #endif
N [* N times back to start of comment (/*)
N ]* N times forward to end of comment (*/)

Pattern searches

N /{pattern}[/[offset]]<CR> search forward for the Nth occurrence of {pattern}
N ?{pattern}[?[offset]]<CR> search backward for the Nth occurrence of {pattern}
N /<CR> repeat last search, in the forward direction
N ?<CR> repeat last search, in the backward direction
N n repeat last search
N N repeat last search, in opposite direction
N * search forward for the ident under the cursor
N # search backward for the ident under the cursor
N g* like "*", but also find partial matches
N g# like "#", but also find partial matches
gd goto local declaration of ident under the cursor
gD goto global declaration of ident under the cursor

Special characters in search patterns

meaning magic nomagic
matches any single character . \.
matches start of line ^ ^
matches end of line $ $
matches start of word \< \<
matches end of word \> \>
matches a single char from the range [a-z] \[a-z]
matches a single char not in the range [^a-z] \[^a-z]
matches an identifier char \i \i
idem but excluding digits \I \I
matches a keyword character \k \k
idem but excluding digits \K \K
matches a file name character \f \f
idem but excluding digits \F \F
matches a printable character \p \p
idem but excluding digits \P \P
matches <Esc> \e \e
matches <Tab> \t \t
matches <CR> \r \r
matches <BS> \b \b
matches 0 or more of the preceding atom * \*
matches 1 or more of the preceding atom \+ \+
matches 0 or 1 of the preceding atom \= \=
separates two branches \| \|
group a pattern into an atom \(\) \(\)

Offsets allowed after search command

[num] [num] lines downwards, in column 1
+[num] [num] lines downwards, in column 1
-[num] [num] lines upwards, in column 1
e[+num] [num] characters to the right of the end of the match
e[-num] [num] characters to the left of the end of the match
s[+num] [num] characters to the right of the start of the match
s[-num] [num] characters to the left of the start of the match
b[+num] [num] characters to the right of the start (begin) of the match
b[-num] [num] characters to the left of the start (begin) of the match
;{search command} execute {search command} next

Marks and motions

m<a-zA-Z> mark current position with mark <a-zA-Z>
`<a-z> go to mark <a-z> within current file
`<A-Z> go to mark <A-Z> in any file
`<0-9> go to the position where Vim was last exited
`` go to the position before the last jump
`" go to the position when last editing this file
`[ go to the start of the previously operated or put text
`] go to the end of the previously operated or put text
`< go to the start of the (previous) Visual area
`> go to the end of the (previous) Visual area
'<a-zA-Z0-9[]'"<>> same as `, but on the first non-blank in the line
:marks print the active marks
N CTRL-O go to N older position in jump list
N CTRL-I go to N newer position in jump list
:ju[mps] print the jump list

Various motions

% find the next brace, bracket, comment or #if/ #else/#endif in this line and go to its match
N H go to the Nth line in the window, on the first non-blank
M M go to the middle line in the window, on the first non-blank
N L go to the Nth line from the bottom, on the first non-blank

Using tags

:ta[g][!] {tag} Jump to tag {tag}
CTRL-] Jump to the tag under cursor, unless changes have been made
N CTRL-T Jump back from N older tag in tag list
:[count]po[p][!] Jump back from [count] older tag in tag list
:[count]ta[g][!] Jump to [count] newer tag in tag list
:tags Print tag list

Scrolling

N CTRL-E window N lines downwards (default 1)
N CTRL-D window N lines Downwards (default 1/2 window)
N CTRL-F window N pages Forwards (downwards)
N CTRL-Y window N lines upwards (default 1)
N CTRL-U window N lines Upwards (default 1/2 window)
N CTRL-B window N pages Backwards (upwards)
z<CR> or zt redraw, current line at top of window
z. or zz redraw, current line at center of window
z- or zb redraw, current line at bottom of window
N zh scroll screen N characters to the right
N zl scroll screen N characters to the left

Inserting text

N a append text after the cursor (N times)
N A append text at the end of the line (N times)
N i insert text before the cursor (N times) (also: <Insert>)
N I insert text before the first non-blank in the line (N times)
N gI insert text in column 1 (N times)
N o open a new line below the current line, append text (N times)
N O open a new line above the current line, append text (N times)

Keys in insert mode

charaction in insert mode
<Esc> end insert mode, back to command mode
CTRL-C like <Esc>, but do not do an abbreviation
CTRL-A insert previously inserted text
CTRL-@ insert previously inserted text and stop insert
CTRL-R <0-9a-z%:> insert contents of register <0-9a-z%:>
<NL> or <CR> or CTRL-M or CTRL-J begin new line
CTRL-E insert the character from below the cursor
CTRL-Y insert the character from above the cursor
CTRL-V insert character literally, or enter decimal byte value
CTRL-N insert next match of identifier before the cursor
CTRL-P insert previous match of identifier before the cursor
CTRL-X ... complete the word before the cursor in one or another way
<BS> or CTRL-H delete the character before the cursor
<Del> delete the character under the cursor
CTRL-W delete word before the cursor
CTRL-U delete all entered characters in the current line
CTRL-T insert one shiftwidth of indent in front of the current line
CTRL-D delete one shiftwidth of indent in front of the current line
0_CTRL-D delete all indent in the current line
^_CTRL-D delete all indent in the current line, restore indent in next line
CTRL-K {char1} {char2} enter digraph (See Digraphs)
{char1} <BS> {char2} enter digraph if 'digraph' option set
CTRL-B toggle 'revins' (reverse insert) option

Special keys in insert mode

cursor keys move cursor left/right/up/down
shift-left/right one word left/right
shift-up/down one screenfull backward/forward
CTRL-O {command} execute {command}
end key cursor after last character in the line
home key cursor to first character in the line

Digraphs

:dig[raphs] show current list of digraphs
:dig[raphs] {char1}{char2} {number} ... add digraph(s) to the list

Special inserts

:r [file] insert the contents of [file] below the cursor
:r! {command} insert the standard output of {command} below the cursor

Deleting text

N x delete N characters under and after the cursor
N <Del> delete N characters under and after the cursor
N X delete N characters before the cursor
N d {motion} delete the text that is moved over with {motion}
{visual}d delete the highlighted text
N dd delete N lines
N D delete to end of line (and N-1 more lines)
N J join N-1 lines (delete newlines)
{visual}J join the highlighted lines
:[range]d [x] delete [range] lines [into register x]

Copying and moving text

"<char> use register <char> for the next delete, yank or put
:reg show the contents of all registers
:reg {arg} show the contents of registers mentioned in {arg}
N y {motion} yank the text moved over with {motion} into a register
{visual}y yank the highlighted text into a register
N yy yank N lines into a register
N Y yank N lines into a register
N p put a register after the cursor position (N times)
N P put a register before the cursor position (N times)
N ]p like p, but adjust indent to current line
N [p like P, but adjust indent to current line

Changing text

N R enter replace mode (repeat the entered text N times)
N c{motion} change the text that is moved over with {motion}
{visual}c change the highlighted text
N cc change N lines
N S change N lines
N C change to end of line (and N-1 more lines)
N s change N characters
N r<char> replace N characters with <char>

N ~ switch case for N characters and advance cursor
{visual}~ switch case for highlighted text
{visual}u make highlighted text lowercase
{visual}U make highlighted text uppercase
g~{motion} switch case for the text that is moved over with {motion}
gu {motion} make the text that is moved over with {motion} lowercase
gU {motion} make the text that is moved over with {motion} uppercase

N CTRL-A add N to the number at or after the cursor
N CTRL-X subtract N from the number at or after the cursor

N < {motion} move the lines that are moved over one shiftwidth left
N << move N lines one shiftwidth left
N > {motion} move the lines that are moved over one shiftwidth right
N >> move N lines one shiftwidth right
N Q {motion} format the lines that are moved over to 'textwidth' length
:[range]ce[nter] [width] center the lines in [range]
:[range]le[ft] [indent] left align the lines in [range] [with indent]
:[range]ri[ght] [width] right align the lines in [range]

Complex changes

N ! {motion}{command}<CR> filter the lines that are moved over through {command}
N !! {command}<CR> filter N lines through {command}
{visual}!!{command}<CR> filter the highlighted lines through {command}
:[range]! {command}<CR> filter [range] lines through {command}
N = {motion} filter the lines that are moved over through "indent"
N == filter N lines through "indent"
{visual}= filter the highlighted lines through "indent"
:[range]s[ubstitute] /{pattern}/{string}/[g][c] substitute {pattern} by {string} in [range] lines; with [g] replace all occurrences of {pattern}; with [c] ask first
:[range]s[ubstitute] [g][c] repeat previous :s with new range and options
& Repeat previous :s on current line without options
:[range]ret[ab][!] [tabstop] set 'tabstop' to new value and adjust white space accordingly

Visual mode

v start highlighting characters move cursor and use operator to affect highlighted text
V start highlighting linewise
CTRL-V start highlighting blockwise
o exchange cursor position with start of highlighting
gv start highlighting on previous visual area
v highlight characters or stop highlighting
V highlight linewise or stop highlighting
CTRL-V highlight blockwise or stop highlighting

Text objects (only in Visual mode or after an operator)

N a Select current word
N A Select current WORD
N s Select current sentence
N p Select current paragraph
N S Select current block (from "[(" to "])")
N P Select current block (from "[{" to "]}")

Copying and moving text

"<char> use register <char> for the next delete, yank or put
:reg show the contents of all registers
:reg {arg} show the contents of registers mentioned in {arg}
N y {motion} yank the text moved over with {motion} into a register
{visual}y yank the highlighted text into a register
N yy yank N lines into a register
N Y yank N lines into a register
N p put a register after the cursor position (N times)
N P put a register before the cursor position (N times)
N ]p like p, but adjust indent to current line
N [p like P, but adjust indent to current line

Repeating commands

N . repeat last change (with count replaced with N)
q<a-z> record typed characters into register <a-z>
q stop recording
N @<a-z> execute the contents of register <a-z> (N times)
N @@ repeat previous @<a-z> (N times)
:@<a-z> execute the contents of register <a-z> as an Ex command
:@@ repeat previous :@<a-z>
:[range]g[lobal] /{pattern}/[cmd] Execute Ex command [cmd] (default :p) on the lines within [range] where {pattern} matches.
:[range]g[lobal]! /{pattern}/[cmd] Execute Ex command [cmd] (default :p) on the lines within [range] where {pattern} does NOT match.
:so[urce] {file} Read Ex commands from {file}.
:so[urce]! {file} Read Vim commands from {file}.
:sl[eep] [N] don't do anything for N seconds
N gs Goto Sleep for N seconds

Key mapping

:ma[p] {lhs} {rhs} Map {lhs} to {rhs} in normal and visual mode.
:ma[p]! {lhs} {rhs} Map {lhs} to {rhs} in insert and command line mode.
:no[remap] [!] {lhs} {rhs} Same as :map, no remapping for this {rhs}
:unm[ap] {lhs} Remove the mapping of {lhs} for normal and visual mode.
:unm[ap]! {lhs} Remove the mapping of {lhs} for insert and command line mode.
:ma[p] [lhs] List mappings (starting with [lhs]) for normal and visual mode. |:map_l! :ma[p]! [lhs] List mappings (starting with [lhs]) for insert and command line mode.
:cmap /:cunmap/:cnoremap like map!/unmap!/noremap! but for command line mode only
:imap /:iunmap/:inoremap like map!/unmap!/noremap! but for insert mode only
:nmap /:nunmap/:nnoremap like map/unmap/noremap but for normal mode only
:vmap /:vunmap/:vnoremap like map/unmap/noremap but for visual mode only
:mk[exrc] [!] [file] write current mappings, abbreviations and settings to [file] (default ".exrc"; use ! to overwrite)
:mkv[imrc] [!] [file] same as :mkexrc, but with default ".vimrc"
:mapc[lear] remove mappings for normal and visual mode
:mapc[lear]! remove mappings for insert and cmdline mode
:imapc[lear] remove mappings for insert mode
:vmapc[lear] remove mappings for visual mode
:nmapc[lear] remove mappings for normal mode
:cmapc[lear] remove mappings for cmdline mode

Abbreviations

:ab[breviate] {lhs} {rhs} add abbreviation for {lhs} to {rhs}
:ab[breviate] {lhs} show abbr's that start with {lhs}
:ab[breviate] show all abbreviations
:una[bbreviate] {lhs} remove abbreviation for {lhs}
:norea[bbrev] [lhs] [rhs] like :ab, but don't remap [rhs]
:iab /:iunab/:inoreab like :ab, but only for insert mode
:cab /:cunab/:cnoreab like :ab, but only for command line
:abc[lear] remove all abbreviations
:cabc[lear] remove all abbr. for cmdline mode
:iabc[lear] remove all abbr. for insert mode

Options

:se[t] Show all modified options.
:se[t] all Show all options.
:se[t] {option} Set toggle option on, show string or number option.
:se[t] no{option} Set toggle option off.
:se[t] inv{option} invert toggle option.
:se[t] {option}={value} Set string or number option to {value}.
:se[t] {option}? Show value of {option}.

:fix[del] Set value of 't_kD' according to value of 't_kb'.

Short explanation of each option:

'aleph' 'al' ASCII code of the letter Aleph (RIGHTLEFT)
'autoindent' 'ai' take indent for new line from previous line
'autowrite' 'aw' automatically write file if changed
'backspace' 'bs' how backspace works at start of line
'backup' 'bk' keep backup file after overwriting a file
'backupdir' 'bdir' list of directories for the backup file
'backupext' 'bex' extension used for the backup file
'binary' 'bin' edit binary file mode
'bioskey' 'bk' MSDOS: use bios calls for input characters
'breakat' 'brk' characters that may cause a line break
'cindent' 'cin' do C program indenting
'cinkeys' 'cink' keys that trigger indent when 'cindent' is set
'cinoptions' 'cino' how to do indenting when 'cindent' is set
'cinwords' 'cinw' words where 'si' and 'cin' add an indent
'cmdheight' 'ch' number of lines to use for the command line
'columns' 'co' number of columns in the display
'comments' 'com' patterns that can start a comment line
'compatible' 'cp' behave vi-compatible as much as possible
'cpoptions' 'cpo' flags for vi-compatible behaviour
'define' 'def' pattern to be used to find a macro definition
'dictionary' 'dict' list of file names used for keyword completion
'digraph' 'dg' enable the entering of digraphs in Insert mode
'directory' 'dir' list of directory names for the swap file
'edcompatible' toggle flags of ":substitute" command
'endofline' 'eol' write end of line for last line in file
'equalalways' 'ea' windows are automatically made the same size
'equalprg' 'ep' external program to use for "=" command
'errorbells' 'eb' ring the bell for error messages
'errorfile' 'ef' name of the error file for the QuickFix mode
'errorformat' 'efm' description of the lines in the error file
'esckeys' 'ek' recognize function keys in insert mode
'expandtab' 'et' use spaces when <Tab> is inserted
'exrc' read .vimrc and .exrc in the current directory
'formatoptions' 'fo' how automatic formatting is to be done
'formatprg' 'fp' name of external program used with "Q" command
'gdefault' 'gd' the ":substitute" flag 'g' is default on
'guifont' 'gfn' GUI: Name(s) of font(s) to be used
'guioptions' 'go' GUI: Which components and options are used
'guipty' GUI: try to use a pseudo-tty for :! commands
'helpfile' 'hf' name of this help file
'helpheight' 'hh' minimal height of a new help window
'hidden' 'hid' don't unload buffer when it is abondoned
'highlight' 'hl' sets highlighting mode for various occasions
'history' 'hi' number of command lines that are remembered
'hkmap' 'hk' Hebrew keyboard mapping (RIGHTLEFT)
'icon' set icon of the window to the name of the file
'ignorecase' 'ic' ignore case in search patterns
'include' 'inc' pattern to be used to find an include file
'incsearch' 'is' highlight match while typing search pattern
'infercase' 'inf' adjust case of match for keyword completion
'insertmode' 'im' start the edit of a file in Insert mode
'isfname' 'isf' characters included in file and path names
'isident' 'isi' characters included in identifiers
'isprint' 'isp' printable characters
'iskeyword' 'isk' characters included in keywords
'joinspaces' 'js' two spaces after a period with a join command
'keywordprg' 'kp' program to use for the "K" command
'langmap' 'lmap' alphabetic characters for other language mode
'laststatus' 'ls' tells when last window has status lines
'linebreak' 'lbr' wrap long lines at a blank
'lines' number of lines in the display
'lisp' automatic indenting for lisp
'list' show <Tab> and end-of-line
'magic' changes special characters in search patterns
'makeprg' 'mp' program to use for the ":make" command
'maxmapdepth' 'mmd' maximum recursive depth for mapping
'maxmem' 'mm' maximum memory (in Kbyte) used for one buffer
'maxmemtot' 'mmt' maximum memory (in Kbyte) used for all buffers
'modeline' 'ml' recognize modelines at start or end of file
'modelines' 'mls' number of modelines recognized
'modified' 'mod' buffer has been modified
'more' pause listings when the whole screen is filled
'mouse' enable the use of mouse clicks
'mousetime' 'mouset' max time between mouse double click
'nestedcomments' 'ncom' patterns starting comments that can be nested
'number' 'nu' print the line number in front of each line
'paragraphs' 'para' nroff macros that separate paragraphs
'paste' allow pasting text
'patchmode' 'pm' UNIX: keep the oldest version of a file
'path' 'pa' list of directories searched with "gf" et.al.
'readonly' 'ro' disallow writing the buffer
'remap' allow mappings to work recursively
'report' threshold for reporting nr. of lines changed
'revins' 'ri' inserting characters will work backwards
'rightleft' 'rl' window is right-to-left oriented (RIGHTLEFT)
'ruler' 'ru' show cursor line and column in the status line
'scroll' lines to scroll with CTRL-U and CTRL-D
'scrolljump' 'sj' minimal number of lines to scroll
'scrolloff' 'so' minimal nr. of lines above and below cursor
'sections' 'sect' nroff macros that separate sections
'secure' secure mode for reading .vimrc in current dir
'shell' 'sh' name of shell to use for external commands
'shellpipe' 'sp' string to put output of ":make" in error file
'shellredir' 'srr' string to put output of filter in a temp file
'shelltype' 'st' Amiga: influences how to use a shell
'shiftround' 'sr' round indent to multiple of shiftwidth
'shiftwidth' 'sw' number of spaces to use for (auto)indent step
'shortmess' 'shm' list of flags, reduce length of messages
'shortname' 'sn' non-MSDOS: file names can be 8+3 characters
'showbreak' 'sbr' string to use at the start of wrapped lines
'showcmd' 'sc' show (partial) command in status line
'showmatch' 'sm' briefly jump to matching bracket if insert one
'showmode' 'smd' message on status line to show current mode
'sidescroll' 'ss' minimal number of columns to scroll horizontal
'smartcase' 'scs' no ignore case when pattern has upper case
'smartindent' 'si' smart autoindenting for C programs
'smarttab' 'sta' use 'shitfwidth' when inserting <Tab>
'splitbelow' 'sb' new window from split is below the current one
'startofline' 'sol' commands move cursor to first blank in line
'suffixes' 'su' suffixes that are ignored with multiple match
'swapsync' 'sws' how to sync swap file
'tabstop' 'ts' number of spaces that <Tab> in file uses
'taglength' 'tl' number of significant characters for a tag
'tagrelative' 'tr' file names in tag file are relative
'tags' list of file names used by the tag command
'term' name of the terminal
'terse' shorten some messages
'textauto' 'ta' set 'textmode' automatically when reading file
'textmode' 'tx' lines are separated by <CR><NL>
'textwidth' 'tw' maximum width of text that is being inserted
'tildeop' 'to' tilde command "~" behaves like an operator
'timeout' time out on mappings and key codes
'ttimeout' time out on mappings
'timeoutlen' 'tm' time out time in milliseconds
'title' set title of window to the name of the file
'ttybuiltin' 'tbi' use builtin termcap before external termcap
'ttyfast' 'tf' indicates a fast terminal connection
'ttyscroll' 'tsl' maximum number of lines for a scroll
'undolevels' 'ul' maximum number of changes that can be undone
'updatecount' 'uc' after this many characters flush swap file
'updatetime' 'ut' after this many milliseconds flush swap file
'viminfo' 'vi' use .viminfo file upon startup and exiting
'visualbell' 'vb' use visual bell instead of beeping
'warn' warn for shell command when buffer was changed
'weirdinvert' 'wi' for terminals that have weird inversion method
'whichwrap' 'ww' allow specified keys to cross line boundaries
'wildchar' 'wc' command line character for wildcard expansion
'winheight' 'wh' minimal number of lines for the current window
'wrap' long lines wrap and continue on the next line
'wrapmargin' 'wm' chars from the right where wrapping starts
'wrapscan' 'ws' searches wrap around the end of the file
'writeany' 'wa' write to file with no need for "!" override
'writebackup' 'wb' make a backup before overwriting a file
'writedelay' 'wd' delay this many msec for each char (for debug)

Undo/Redo commands

N u undo N last changes
N CTRL-R redo N last undone changes
U restore last changed line

External commands

:sh[ell] start a shell
:! {command} execute {command} with a shell
K lookup keyword under the cursor with 'keywordprg' program (default; man)

Quickfix commands

:cc [nr] display error [nr] (default is the same again)
:cn display the next error
:cp display the previous error
:cl list all errors
:cf read errors from the file 'errorfile'
:cq quit without writing and return error code (to the compiler)
:make [args] start make, read errors and jump to first error

Various commands

CTRL-L Clear and redraw the screen.
CTRL-G show current file name (with path) and cursor position
ga show ascii value of character under cursor in decimal, hex and octal
g CTRL-G show cursor column, line and character position
CTRL-C during searches: interrupt the search
<Del> while entering a count: delete last character
:ve[rsion] show exact version number of this VIM
:mode N MSDOS: set screen mode to N (number, C80, C4350, etc.)
:norm[al][!] {commands} Execute normal mode commands.

Command line editing

<Esc> abandon command line (if 'wildchar' is <Esc> type it twice)
CTRL-V {char} insert {char} literally
CTRL-V {number} enter decimal value of character (up to three digits)
CTRL-K {char1} {char2} enter digraph (See X_di)
CTRL-R <0-9a-z%:> insert contents of register <0-9a-z%:>
<Left>/<Right> cursor left/right
<S-Left>/<S-Right> cursor one word left/right
CTRL-B/CTRL-E cursor to begin/end of command line
<BS> delete the character in front of the cursor
<Del> delete the character under the cursor
CTRL-W delete the word in front of the cursor
CTRL-U remove all characters
<Up>/<Down> recall older/newer cmd line from history
<S-Up>/<S-Down> recall older/newer cmd line that starts with current command

Context sensitive completion on the command line:

'wildchar'(default <Tab>) do completion on the pattern in front of the cursor; If there are multiple matches, beep and show the first one, further 'wildchar' will show the next ones.
CTRL-D list all names that match the pattern in front of the cursor
CTRL-A insert all names that match pattern in front of cursor
CTRL-L insert longest common part of names that match pattern
CTRL-N after 'wildchar' with multiple matches: go to next match
CTRL-P after 'wildchar' with multiple matches: go to previous match


Ex ranges

, separates two line numbers
; idem, set cursor to the first line number
{number} an absolute line number
. the current line
$ the last line in the file
% equal to 1,$ (the entire file)
* equal to '<,'> (visual area)
't position of mark t
/{pattern} the next line where {pattern} matches
?{pattern} the previous line where {pattern} matches
+[num] add [num] to the preceding line number (default 1)
-[num] subtract [num] from the preceding line number (default 1)

Special Ex characters

| separates two commands (not for ":global" and ":!")
" begins comment
% current filename (only where filename is expected)
# [number] alternate filename [number] (only where filename is expected)
CTRL-V w word under the cursor (only where filename is expected)
CTRL-V W WORD under the cursor (only where filename is expected) (see WORD)
CTRL-V p path name under the cursor (only where filename is expected)
After "%", "#" or "CTRL-V p":
:p full path
:h head
:t tail
:r root
:e extension

Editing a file

:e[dit] Edit the current file, unless changes have been made.
:e[dit]! Edit the current file always. Discard any changes.
:e[dit] {file} Edit {file}, unless changes have been made.
:e[dit]! {file} Edit {file} always. Discard any changes.
N CTRL-^ Edit alternate file N (equivalent to ":e #N").
gf or ]f Edit the file whose name is under the cursor
:pwd Print the current directory name.
:cd [path] Change the current directory to [path].
:f[ile] Print the current filename and the cursor position.
:f[ile] {name} Set the current filename to {name}.
:files Show alternate file names.

Using the file list

:ar[gs] Print the file list, with the current file in "[]".
:all or :sall Open a window for every file.
:wn[ext][!] Write file and edit next file.
:wn[ext][!] {file} Write to {file} and edit next file, unless {file} exists. With ! overwrite existing files.
:wN[ext] [!] [file] Write file and edit previous file.
in current window in new window
:argu[ment] N :sar[gument] N Edit file N
:n[ext] :sn[ext] Edit next file
:n[ext] {filelist} :sn[ext] {filelist} define new list of files and edit the first one
:N[ext] :sN[ext] Edit previous file
:rew[ind][!] :srew[ind] Edit first file
:last :slast Edit last file

Writing and quitting

:[range]w[rite][!] Write to the current file.
:[range]w[rite]_{file} Write to {file}, unless it already exists.
:[range]w[rite]! {file} Write to {file}. Overwrite an existing file.
:[range]w[rite][!]_>> Append to the current file.
:[range]w[rite][!] >> {file} Append to {file}.
:[range]w[rite]_!{cmd} Execute {cmd} with [range] lines as standard input.
:wall[!] write all changed buffers
:q[uit] Quit, unless changes have been made.
:q[uit]! Quit always, discard any changes.
:qall[!] exit, also when buffers and windows open
:cq Quit without writing and return error code
:wq[!] Write the current file and exit.
:wq[!] {file} Write to {file} and exit.
:x[it] [!] [file] Like ":wq" but write only when changes have been made
ZZ Same as ":x".
:xall [!] or :wqall[!] Write all changed buffers and exit
:st[op] [!] Suspend VIM or start new shell. If 'aw' option is set and [!] not given write the buffer.
CTRL-Z Same as ":stop!"

Starting VIM

vim [options] start editing with an empty buffer
vim [options] {file_..} start editing one or more files
vim [options] -t {tag} edit the file associated with {tag}
vim [options] -e [fname] start editing in QuickFix mode, display the first error

Command line options:

+[num] put the cursor at line [num] (default last line)
+{command} execute {command} after loading the file
+/{pat} {file ..} put the cursor at the first occurrence of {pat}
-v read-only mode (View), implies -n
-R read-only mode, same as -v
-b binary mode
-l lisp mode
-H Hebrew mode ('hkmap' and 'rightleft' are set)
-r without file name: give list of swap files
-r with file name: Recover aborted edit
-n do not create ".swp" file
-o [N] open N windows (default: one for each file)
-x do not restart VIM to open a window (for e.g. mail)
-s {scriptin} first read the commands in the file {scriptin}
-w {scriptout} write all typed characters to the file {scriptout}
-T {terminal} set terminal type
-d {device} open {device} to be used as a console
-u {vimrc} read inits from {vimrc} instead of other inits
-i {viminfo} read info from {viminfo} instead of other files


Automatic Commands

viminfo_file Read registers, marks, history at startup, save when exiting.
:rv[iminfo] [file] Read info from viminfo file [file]
:rv[iminfo]! [file] idem, overwrite exisiting info
:wv[iminfo] [file] Add info to viminfo file [file]
:wv[iminfo]! [file] Write info to viminfo file [file]
modeline Automatic option setting when editing a file
vim:{set-arg}: .. In the first and last lines of the file (see 'ml' option), {set-arg} is given as an argument to :set
autocommand Automatic execution of commands on certain events.
:au[tocmd] List all autocommands
:au {event} List all autocommands for {event}
:au {event} {pat} List all autocommands for {event} and {pat}
:au {event} {pat} {cmd} Enter new autocommands for {event} and {pat}
:au! Remove all autocommands
:au! {event} Remove all autocommands for {event}
:au! {event} {pat} Remove all autocommands for {event} and {pat}
:au! {event} {pat} {cmd} Remove all autocommands for {event} and {pat} and enter new one

Multi window functions

CTRL-W s or :split Split window in two parts
:split {file} Split window and edit {file} in one of them
CTRL-W ] Split window and jump to tag under cursor
CTRL-W f Split window and edit file name under the cursor
CTRL-W CTRL-^ Split window and edit alternate file
CTRL-W n or :new Create new empty window
CTRL-W q or :q[uit] Quit editing and close window
CTRL-W c or :cl[ose] Make buffer hidden and close window
CTRL-W o or :o[nly] Make current window only one on the screen
CTRL-W j Move cursor to window below
CTRL-W k Move cursor to window above
CTRL-W CTRL-W Move cursor to next window (wrap)
CTRL-W t Move cursor to top window
CTRL-W b Move cursor to bottom window
CTRL-W p Move cursor to previous active window
CTRL-W r Rotate windows downwards
CTRL-W R Rotate windows upwards
CTRL-W x Exchange current window with next one
CTRL-W = Make all windows equal height
CTRL-W - decrease current window height
CTRL-W + increase current window height
CTRL-W _ Set current window height (default: very high)

Buffer list functions

:buffers or :files list all known buffer and file names
:ball or :sball edit all args/buffers
:unhide or :sunhide edit all loaded buffers
:bunload[!] [N] unload buffer [N] from memory
:bdelete[!] [N] unload buffer [N] and delete it from the buffer list

in current window in new window
:[N]buffer [N] :[N]sbuffer [N] to arg/buf N
:[N]bnext [N] :[N]sbnext [N] to Nth next arg/buf
:[N]bNext [N] :[N]sbNext [N] to Nth previous arg/buf
:[N]bprevious [N] :[N]sbprevious [N] to Nth previous arg/buf
:brewind :sbrewind to first arg/buf
:blast :sblast to last arg/buf
:[N]bmod [N] :[N]sbmod [N] to Nth modified buf

For the most recent information about Vim:

VIM home page
VIM FAQ

Bug reports:

Bram Moolenaar

Usenet News group where Vim is discussed:

comp.editors

There are three mailing lists for Vim:
vim@prz.tu-berlin.de For discussions about using existing versions of Vim: Useful mappings, questions, answers, where to get a specific version, etc.
vimdev@prz.tu-berlin.de For discussions about changing Vim: New features, porting, etc.
vimannounce@prz.tu-berlin.de Announcements about new versions of Vim, also beta-test versions and ports to different systems.

NOTE: You can only send messages to these lists if you have subscribed! Also: you need to send the messages from the same location as where you subscribed from (yes, Majordome is not flexible).

If you want to join send a message to

majordomo@prz.tu-berlin.de
and put "info" in the body. Then Majordomo will give you a little help.

An archive is kept at:
ftp://ftp.ii.uib.no/pub/vim/mail-archive/vim/maillist.html ftp://ftp.ii.uib.no/pub/vim/mail-archive/vimdev/maillist.html ftp://ftp.ii.uib.no/pub/vim/mail-archive/vimannounce/maillist.html

Credits

Most of Vim was made by Bram Moolenaar. Parts of the documentation come from several Vi manuals, written by: The editor Vim is based on Stevie and includes (ideas from) other software, worked on by the people mentioned here. Other people helped by giving me suggestions and discussing about what is good and bad in Vim.
Tony Andrews Stevie
Gert van Antwerpen changes for DJGPP on MSDOS
Berkeley DB(3) ideas for swap file
Keith Bostic nvi
Ralf Brown SPAWNO library for MSDOS
Robert Colon many useful remarks
Kayhan Demirel sent me news in Uganda
Chris & John Downey xvi (ideas for multi windows version)
Eric Fischer Mac port, 'cindent' and other improvements
Bill Foster Athena GUI port
Loic Grenie xvim (ideas for multi windows version)
Steve Kirkendall Elvis
Sergey Laskavy Vim's help from Moscow
Avner Lottem Edit in right-to-left windows (RIGHTLEFT)
George Reilly Win32 port
Stephen Riehm bug collector
Olaf Seibert DICE version and regexp improvements
Peter da Silva termlib
Henry Spencer regular expressions
Tim Thompson Stevie
G. R. (Fred) Walter Stevie
Robert Webb Command line completion, GUI version and lots of patches
Juergen Weigert Lattice version, AUX improvements, UNIX and MSDOS ports, autoconf
I wish to thank all the people that sent me bug reports and suggestions. The list is too long to mention them all here. Vim would not be the same without the ideas from all these people, they keep Vim alive!
Send feedback on this page to Rajesh Kallingal
For Vim version 3.24. Last modification: 1996 Apr 25