VIM help file index RETURN quit help VIM stands for Vi IMitation. SPACE one page forward Most of VIM was made by Bram Moolenaar. a go to this index VIM is based on Stevie, worked on by: Tim b one page backward Thompson, Tony Andrews, G.R. (Fred) Walter c left-right and up-down motions n key mapping; option commands d word and text object motions o options a-m e pattern searches p options n-s f various motions; using tags q options s-z g scrolling r undo; shell; quickfix; various h inserting text; digraphs s command line editing; Ex characters i insert mode t Ex ranges j changing text u editing files; using the file list k complex changes v writing and quitting l deleting, copying, moving text w starting VIM m repeating commands 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 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 the line with mark , on the first non-blank ch. ` go to mark '' go to the line before the last jump, on the first non-blank `` go to the position before the last jump :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 or bracket in this line, 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. :ta[g]! {tag} Jump to tag {tag} always. Discard any changes. CTRL-] ":ta" to the identifier under cursor. 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 redraw, current line at top of window z. redraw, current line at center of window z- 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[raph] show current list of digraphs :dig[raph] {char1}{char2} {number} ... add digraph(s) to the list char action in insert mode CTRL-[ end insert or replace mode, back to command mode CTRL-A insert previously inserted text CTRL-B <0-9a-z> insert contents of register <0-9a-z> CTRL-@ insert previously inserted text and stop insert CTRL-J begin new line CTRL-M begin new line CTRL-R insert the character which is above the cursor CTRL-E insert the character which is below the cursor CTRL-V insert character literally, or enter decimal byte value CTRL-H 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 {char1} {char2} enter digraph keys that stop insert, do something and get back to insert: cursor keys move cursor left/right/up/down shift-up one screenfull backward shift-down one screenfull forward shift-left one word left shift-right one word right CTRL-O execute one 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} {quote}c change the quoted 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 {quote}~ switch case for quoted text {quote}u make quoted text uppercase {quote}U make quoted text lowercase N CTRL-A add N to the number at or after the cursor N CTRL-S 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 V{motion} format the lines that are moved over to 'textwidth' length Complex changes q start quoting characters } move cursor and use Q start quoting linewise } operator to affect CTRL-Q start quoting blockwise } quoted text o exchange cursor position with start of quoting 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} {quote}d detete the quoted 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) {quote}J join the quoted lines :[range]d ["x] delete [range] lines (into register ["x]) Copying and moving text " put the text from the next delete or yank in register :dis show the register contents N y{motion} yank the text, moved over with {motion}, into a register {quote}y yank the quoted 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 below the current line (N times) N P put a register above the current line (N times) Repeating commands N . repeat last change (with count replaced by N) v record typed characters into register v 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}. Key mapping :ma[p] {lhs} {rhs} Map the key sequence {lhs} to {rhs} in normal mode. :ma[p]! {lhs} {rhs} Map the key sequence {lhs} to {rhs} in insert mode. :unm[ap] {lhs} Remove the mapping of {lhs} for normal mode. :unm[ap]! {lhs} Remove the mapping of {lhs} for insert mode. :map [lhs] List all key mappings (starting with [lhs]) for normal mode. :map! [lhs] List all key mappings (starting with [lhs]) 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}. option (shorthand) type default effect autoindent (ai) toggle off copy indent from previous line when starting a new line in insert mode autowrite (aw) toggle off write the file when starting a new edit backspace (bs) number 0 0: like normal Vi; 1: delete newlines; 2: delete over start of insert backup (bk) toggle on backup a file before overwriting it backupdir (bdir) string "~/" Unix only: Directory for backup files columns number 80 number of columns in the display digraph (dg) toggle off enable digraphs in insert mode directory (dir) string "" directory to put autoscript file 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 expandtab (et) toggle off insert mode: use spaces to enter a tab graphic (gr) toggle off display chars 0x80-0x9f directly helpfile (hf) string "vim:vim.hlp" name of help file history (hi) number 20 number of remembered command lines ignorecase (ic) toggle off ignore case in search patterns isertmode (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 lines number 25 number of lines in the display option (shorthand) type default effect list toggle off display lines in list mode magic toggle on different pattern matching characters modelines (ml) number 5 number of lines checked for set commands number (nu) toggle off display line numbers paragraphs (para) string "IPLPPPQPP LIpplpipbp" nroff macros that separate paragraphs readonly (ro) toggle off overwriting the file not allowed remap toggle on :map command works recursively repdel (rd) toggle on delete char with BS in replace mode report number 2 minimal number of lines for reporting ruler (ru) toggle off show cursor position in status line scroll number 12 scroll size for CTRL-U and CTRL-D scrolljump number 1 minimal number of lines for scrolling sections string "SHNHH HUnhsh" nroff macros that separate sections shell (sh) string "sh" shell to use for ! and :! commands shelltype (st) number 0 how to use the shell shiftround (sr) toggle off round indent to shiftwidth with > and < shiftwidth (sw) number 8 number of spaces to use for (auto)indent 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 (mo) toggle on show insert/replace mode message smartindent (si) toggle off do smart autoindenting suffixes (su) string ".bak.o.h.info.vim" 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 tags string "tags" names of tag files term string "amiga" name of terminal textwidth number 9999 maximum width of a line in insert mode tildeop (to) toggle off tilde behaves like an operator timeout toggle on wait only 1 second for key codes undolevels (ul) number 100 number of changes that can be undone (0 for Vi compatibility) visualbell (vb) toggle off use visual instead of audible beep wrapmargin (wm) number 0 textwidth is set to window width minus 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 external program Quickfix commands :cc [nr] display error [nr] (default is the same again) :cn display the next error :cp display the previous error :cf read errors from the error file :cq quit without writing and return error code (to the compiler) Various commands CTRL-L Clear and redraw the screen. CTRL-G show current file name 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 Command line editing CTRL-V insert character literally, or enter decimal byte value cursor left cursor right cursor one word left cursor one word right delete the character in front of the cursor delete the character under the cursor CTRL-U remove all characters recall older command line from history recall more recent command line from history CTRL-D list filenames that match the pattern in front of the cursor do filename completion on the pattern in front of the cursor CTRL-N only after with multiple matches: go to next match CTRL-P only after with multiple matches: go to previous match Special Ex characters | separates two commands (not for ":global" and ":!") " begins comment # in first column: begins comment #[number] alternate filename [number] (only where filename is expected) % current filename (only where filename is expected) 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) 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"). :cd 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}. Using the file list :ar[gs] Print the file list, with the current file in "[]". :n[ext] Edit next file, unless changes have been made. :n[ext]! Edit next file, discard any changes to the buffer. :n[ext][!] {filelist} Define {filelist} as the new list of files and edit the first one (see :next for [!]). :N[ext][!] Edit previous file (see :next for [!]). :rew[ind][!] Edit first file (see :next for [!]). :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. 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. :q[uit] Quit, unless changes have been made. :wq[!] Write the current file and exit. :cq Quit without writing and return error code :wq[!] {file} Write to {file} and exit. :x[it][!] [file] Like ":wq" but write only when changes have been made ZZ Same as ":x". :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] +[num] {file ..} idem, put the cursor at line [num] (default last line) vim [options] +/{pat} {file ..} idem, put the cursor at the first occurrence of {pat} vim [options] -t {tag} edit the file associated with {tag} vim [options] -e start editing in QuickFix mode, display the first error options -v read-only mode (View), implies -n -r recover aborted edit, using commands from ".vim" file -n do not create autoscript file -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 vi:{set-arg}: .. In the first and last lines of the file (see 'ml' option), {set-arg} is given as an argument to :set