VIM help file index RETURN quit help VIM stands for Vi IMproved. SPACE one page forward Most of VIM was made by Bram Moolenaar. a go to this index b one page backward c left-right and up-down motions q options i-n d word and text object motions r options p-s e pattern searches s options s-t f various motions; using tags t options t-y g scrolling u undo; shell; quickfix; various h inserting text; digraphs v command line editing i insert mode w Ex ranges; Ex special characters j changing text x editing files k complex changes y using the file list l deleting, copying, moving text z writing and quitting m repeating commands A starting VIM n key mapping; abbreviations B multi window functions o option commands, options a-c C buffer list functions p options d-h Read "reference.doc" for a more complete explanation. Left-right motions N h left (same as CTRL-H, BS and cursor-left key) N l right (same as SPACE and cursor-right key) 0 to first character in the line ^ to first non-blank character in the line N $ to the last character in the line (N-1 lines lower) N | to column N N f to the Nth occurrence of to the right N F to the Nth occurrence of to the left N t till before the Nth occurrence of to the right N T till before the Nth occurrence of 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 (same as CTRL-P and cursor-up key) N j down (same as CTRL-J, CTRL-N, LF and cursor-down key) N - up, on the first non-blank character N + down, on the first non-blank char. (same as CTRL-M and CR) N _ N - 1 lines down, on the first non-blank character N G goto line N (default last line), on the first non-blank char. N % goto line N percentage down in the file. Word 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 Text object motions N ) N sentences forward N ( N sentences backward N } N paragraphs forward N { N paragraphs backward N ]] N sections forward N [[ N sections backward N ][ N sections (starting with a <}>) forward N [] N sections (starting with a <}>) backward N [( [{ N times back to unclosed <(> or <{> N ]) ]} N times forward to unclosed <(> or <{> Pattern searches N /{pattern}[/] search forward for the Nth occurrence of {pattern} N ?{pattern}[?] search backward for the Nth occurrence of {pattern} N / repeat last search, in the forward direction N ? 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 special characters in search patterns 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 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 \(\) \(\) Various motions m mark current position with mark ` go to mark `` go to the position before the last jump `[ or `] go to the start or end of the previously operated or put text ' 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 :jumps print the jump list % 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 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}, unless changes have been made CTRL-] Jump to the tag under cursor, unless changes made N CTRL-T Jump to N older tag in tag list :[count]po[p][!] Jump to [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 (N lines Extra) N CTRL-D window N lines Downwards (default half a window) N CTRL-F window N pages Forwards (downwards) N CTRL-Y window N lines upwards N CTRL-U window N lines Upwards (default half a window) N CTRL-B window N pages Backwards (upwards) z 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 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) N I insert text before the first non-blank in the line (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) Special inserts :r [file] insert the contents of [file] below the cursor :r!{command} insert the standard output of {command} below the cursor Digraphs :dig[raphs] show current list of digraphs :dig[raphs] {char1}{char2} {number} ... add digraph(s) to the list char action in insert mode CTRL-[ or end insert or replace mode, back to command mode 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%:> CTRL-J or or CTRL-M or begin new line CTRL-K {char1} {char2} enter digraph CTRL-E / CTRL-Y insert the character which is below/above the cursor CTRL-V insert character literally, or enter decimal byte value CTRL-N / CTRL-P insert next/previous match of identifier before the cursor CTRL-H or or delete the character before 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 the current line CTRL-D delete one shiftwidth of indent in the current line 0 CTRL-D or ^ CTRL-D delete all indent in the current line {char1} {char2} enter digraph if 'dg' option set CTRL-B toggle 'revins' (reverse insert) option keys that stop insert, do something and get back to insert: cursor keys move cursor left/right/up/down shift-up/down one screenfull backward/forward shift-left/right one word left/right CTRL-O {command} execute {command} 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 C change to end of line (and N-1 more lines) N s change N characters N S change N lines N r replace N characters by 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 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 v start highlighting characters } move cursor and use V start highlighting linewise } operator to affect CTRL-V start highlighting blockwise } highlighted text o exchange cursor position with start of highlighting N !{motion}{command} filter the lines that are moved over through {command} N !!{command} filter N lines through {command} :[range]!{command} filter [range] lines through {command} N ={motion}{command} filter the lines that are moved over through "indent" N =={command} filter N 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 Deleting text N x 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 " use register for the next delete, yank or put :dis show the current register contents 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 by N) q record typed characters into register q stop recording N @ execute the contents of register (N times) N @@ repeat previous @ (N times) :@ execute the contents of register as an Ex command :@@ repeat previous :@ :[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 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 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 mode. :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 :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" Abbreviations :ab[breviate] {lhs} {rhs} add abbreviation for {lhs} to {rhs} :ab[breviate] {lhs} show abbreviations that start with {lhs} :ab[breviate] show all abbreviations :una[bbreviate] {lhs} remove abbreviation for {lhs} :iab/:cab/:iunab/:cunab/:noreab/:cnoreab/:inoreab also available! 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}. option (shorthand) type default effect autoindent (ai) toggle off insert mode: copy indent from prev line autowrite (aw) toggle off write the file when starting a new edit backspace (bs) number 0 0 standard Vi, 1 delete NL, 2 delete all backup (bk) toggle on backup a file before overwriting it backupdir (bdir) string "~/" Unix only: Directory for backup files binary (bin) toggle off binary file mode bioskey (bk) toggle on MSDOS: use bios to get characters cmdheight (ch) number 1 number of lines for the command line columns (co) number 80 number of columns in the display compatible (cp) toggle off set options for maximum vi-compatibility option (shorthand) type default effect digraph (dg) toggle off enable digraphs in insert mode directory (dir) string "" directory to put swap file edcompatible toggle off flags for :substitute toggle endofline (eol) toggle on last line has a newline character equalalways (ea) toggle on windows made equal height after open/close equalprg (ep) string "indent" program used for '=' command errorbells (eb) toggle off ring the bell for error messages errorfile (ef) string "AztecC.Err" file for QuickFix option errorformat (efm) string format of error messages from compiler esckeys (ek) toggle on func. keys with work in insert mode expandtab (et) toggle off insert mode: use spaces to enter a tab exrc toggle off read .exrc/.vimrc from current directory formatprg (fp) string "" external program for 'Q' command gdefault (gd) toggle off the 'g' flag is default on for :substitute graphic (gr) toggle off display chars 0x80-0x9f directly helpfile (hf) string "vim:vim.hlp" name of help file hidden (hid) toggle off buffers become hidden when abandoned highlight (hl) string "db,es,hs,rs,vi,si" when to use higlighting history (hi) number 20 number of remembered command lines option (shorthand) type default effect icon toggle off set icon title to file name ignorecase (ic) toggle off ignore case in search patterns insertmode (im) toggle off start editing in insert mode joinspaces (js) toggle on insert two spaces after a '.' with join keywordprg (kp) string "ref" name of program for 'K' command laststatus (ls) number 1 when 0 last window has no status line, when 1 only with multiple windows, when 2 always lines number 25 number of lines in the display list toggle off display lines in list mode magic toggle on different pattern matching characters makeprg (mp) string "make" name of program for ':make' command maxmem (mm) number 512 How may Kbyte to use for one buffer maxmemtot (mmt) number 512 How may Kbyte to use for all buffers modeline (ml) toggle on lines are checked for set commands modelines (mls) number 5 number of lines checked for set commands more toggle on pause with long listings number (nu) toggle off display line numbers option (shorthand) type default effect paragraphs (para) string "IPLPPPQPP LIpplpipbp" nroff macros that separate paragraphs paste toggle off paste mode: insert literally patchmode (pm) string "" extension to use when patching files readonly (ro) toggle off overwriting the file not allowed remap toggle on :map command works recursively report number 2 minimal number of lines for reporting revins (ri) toggle off insert characters right to left ruler (ru) toggle off show cursor position in status line scroll number 12 scroll size for CTRL-U and CTRL-D scrolljump (sj) number 1 minimal number of lines for scrolling sections (sect) string "SHNHH HUnhsh" macros separating sections secure toggle off security checks for .vimrc and .exrc shell (sh) string "sh" shell to use for ! and :! commands shellpipe (sh) string pipe command to be used for :make shelltype (st) number 0 how to use the shell (Amiga only) shiftround (sr) toggle off round indent to shiftwidth with > and < shiftwidth (sw) number 8 number of spaces to use for (auto)indent shortname (sn) toggle off MSDOS-like filesystem being used showcmd (sc) toggle on show command in status line showmatch (sm) toggle off show matching bracket if one is inserted option (shorthand) type default effect showmode (smd) toggle on show insert/replace mode message sidescroll (ss) number 0 minimal nr of columns for horiz. scroll smartindent (si) toggle off do smart autoindenting smarttab (sta) toggle off tab size depends on position splitbelow (sb) toggle off create new windows below current one suffixes (su) string ".bak.o.h.info.swp" suffixes that are ignored when multiple files match a wildcard tabstop (ts) number 8 number of spaces that a TAB counts for taglength (tl) number 0 if non-zero, tags are significant upto this number of characters tagrelative (tr) toggle on file names in tags file are relative tags string "tags" names of tag files term string "amiga" name of terminal terse toggle off make some messages shorter textauto (ta) toggle on detect line separator, (re)set 'textmode' textmode (tx) toggle off use for line separator textwidth (tw) number 0 maximum width of a line in insert mode tildeop (to) toggle off tilde behaves like an operator timeout toggle on wait only 'tm' msec for mappings&key codes option (shorthand) type default effect ttimeout toggle off wait only 'tm' msec for key codes timeoutlen (tm) number 1000 milliseconds to wait for mappings&key codes title toggle on set window title to file name ttyfast (tf) toggle off don't use scroll commands for terminal undolevels (ul) number 100 number of changes that can be undone (0 for Vi compatibility) updatecount (uc) number 200 after this many key hits swap file updated updatetime (ut) number 4000 after this many mil.sec. swap file updated visualbell (vb) toggle off use visual instead of audible beep warn toggle on warn when changes and shell command used weirdinvert (wi) toggle off terminal has a weird invert behaviour whichwrap (ww) number 3 which left/right move commands wrap wildchar (wc) number TAB char used to start filename completion winheight (wh) number 0 minimal number of lines for current window wrap toggle on when off: horizontal scrolling wrapmargin (wm) number 0 wrap text when at (columns - wrapmargin) wrapscan (ws) toggle on searches wrap around the end of the file writeany (wa) toggle off always write file without asking writebackup (wb) toggle on backup a file WHILE overwriting it yankendofline (ye) toggle off 'Y' yanks from cursor to end of line 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 start a shell :!{command} execute {command} with a shell K lookup keyword under the cursor with 'keywordprg' program 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 CTRL-C during searches: interrupt the search while entering a count: delete last character :vers show exact version number of this VIM :mode N MSDOS: set screen mode to N (number, C80, C4350, etc.) Command line editing abandon command line (if 'wildchar' is type it twice) CTRL-V {char} insert {char} literally CTRL-V {number} enter decimal byte value (up to three digits) / cursor left/right / cursor one word left/right CTRL-B/CTRL-E cursor to begin/end of command line delete the character in front of the cursor delete the character under the cursor CTRL-W delete the word in front of the cursor CTRL-U remove all characters / recall older/newer command line from history / recall older/newer command that starts with current command Context sensitive completion 'wildchar' (def. ) do completion on the pattern in front of the cursor 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) '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 #[number] alternate filename [number] (only where filename is expected) % current filename (only where filename is expected) %< or #< idem, but without extension Editing a file :e Edit the current file, unless changes have been made. :e! 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 Options +[num] put the cursor at line [num] (default last line) +/{pat} {file ..} put the cursor at the first occurrence of {pat} -v read-only mode (View), implies -n -b binary mode -r recover aborted edit, using ".swp" file -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 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 Multi window functions CTRL-W s or :split Split window in two parts :split Split window and edit 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 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 around) 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 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 :bunload[!] [N] unload buffer [N] from memory :bdelete[!] [N] unload buffer [N] and delete it from the buffer list