You are on page 1of 20

VIM QUICK REFERENCE GUIDE

By Bram Moolenaar
Left-right motions ........................................................ 1 Up-down motions ......................................................... 1 Text object motions ...................................................... 2 Pattern searches ........................................................... 2 Marks and motions ....................................................... 3 Various motions............................................................ 3 Using tags ...................................................................... 4 Scrolling......................................................................... 4 Inserting text................................................................. 4 Insert mode keys .......................................................... 5 Special keys in Insert mode ......................................... 5 Digraphs ........................................................................ 5 Special inserts ............................................................... 5 Deleting text .................................................................. 5 Copying and moving text ............................................. 6 Changing text ................................................................ 6 Complex changes .......................................................... 7 Visual mode................................................................... 7 Text objects (only in Visual mode or after an operator) . 7 Repeating commands ................................................... 7 Key mapping .................................................................. 8 Abbreviations ................................................................ 8 Options ........................................................................... 8 Undo/Redo commands ............................................... 14 External commands .................................................... 14 Quickfix commands ..................................................... 14 Various commands...................................................... 15 Command-line editing ................................................ 15 Ex ranges...................................................................... 16 Special Ex characters .................................................. 16 Starting VIM ................................................................. 16 Editing a file ................................................................. 17 Using the argument list............................................... 17 Writing and quitting ................................................... 18 Automatic Commands................................................. 18 Multi-window commands........................................... 18 Buffer list commands .................................................. 19 Syntax Highlighting ..................................................... 19 GUI commands ............................................................ 20 Folding ......................................................................... 20

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

Up-down motions
N N N N N N N k j + _ G gg up N down up N down down goto goto lines (also: CTRL-P and <Up>) N lines (also: CTRL-J, CTRL-N, <NL>, and <Down>) lines, on the first non-blank character N lines, on the first non-blank character (also: CTRL-M and <CR>) N-1 lines, on the first non-blank character line N (default: last line), on the first non-blank character line N (default: first line), on the first non-blank character

The Vim user manual and reference manual are Copyright (c) 1988-2003 by Bram Moolenaar. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later. The latest version is presently available at http://www.opencontent.org/openpub/. This document was prepared from http://vimdoc.sourceforge.net/htmldoc/quickref.html with typesetting and minor modifications by Alexander J. Quinn, July 11, 2010 8:44 PM.

Text object motions N N N % gk gj goto line N percentage down in the file. N must be given, otherwise it is the |%| command. up N screen lines (differs from "k" when line wraps) down N screen lines (differs from "j" when line wraps)

Text object motions


N N N N N N N N N N N N N N N N N N N N N N N N N N N N w W e E b B ge gE ) ( } { ]] [[ ][ [] [( [{ [m [M ]) ]} ]m ]M [# ]# [* ]* N words forward N blank-separated |WORD|s forward forward to the end of the Nth word forward to the end of the Nth blank-separated |WORD| N words backward N blank-separated |WORD|s backward backward to the end of the Nth word backward to the end of the Nth blank-separated |WORD| N N N N N N N N N N N N N N N N N N N N sentences forward sentences backward paragraphs forward paragraphs backward sections forward, at start of section sections backward, at start of section sections forward, at end of section sections backward, at end of section times back to unclosed '(' times back to unclosed '{' times back to start of method (for Java) times back to end of method (for Java) times forward to unclosed ')' times forward to unclosed '}' times forward to start of method (for Java) times forward to end of method (for Java) times back to unclosed "#if" or "#else" times forward to unclosed "#else" or "#endif" times back to start of comment "/*" times forward to end of comment "*/"

Pattern searches
N N N N N N N N N N /{pattern}[/[offset]]<CR> search forward for the Nth occurrence of {pattern} ?{pattern}[?[offset]]<CR> search backward for the Nth occurrence of {pattern} /<CR> repeat last search, in the forward direction ?<CR> repeat last search, in the backward direction n repeat last search N repeat last search, in opposite direction * search forward for the identifier under the cursor # search backward for the identifier under the cursor g* like "*", but also find partial matches g# like "#", but also find partial matches gd goto local declaration of identifier under the cursor gD goto global declaration of identifier under the cursor magic nomagic . \. ^ ^ $ $ \< \< \> \> [a-z] \[a-z] [^a-z] \[^a-z] \i \i

Special characters in search patterns meaning matches any single character matches start of line matches <EOL> matches start of word matches end of word matches a single char from the range matches a single char not in the range matches an identifier char

Marks and motions idem but excluding digits matches a keyword character idem but excluding digits matches a file name character idem but excluding digits matches a printable character idem but excluding digits matches a white space character matches a non-white space character matches <Esc> matches <Tab> matches <CR> matches <BS> matches 0 or matches 1 or matches 0 matches 2 more of the preceding atom more of the preceding atom or 1 of the preceding atom to 5 of the preceding atom separates two alternatives group a pattern into an atom \I \k \K \f \F \p \P \s \S \e \t \r \b * \+ \= \{2,5} \| \(\) \I \k \K \f \F \p \P \s \S \e \t \r \b \* \+ \= \{2,5} \| \(\)

offset 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] identical to s[+num] above (mnemonic: begin) b[-num] [num] identical to s[-num] above (mnemonic: begin) ;{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 previously 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 `. go to the position of the last change in this file '{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 Nth older position in jump list N CTRL-I go to Nth newer position in jump list :ju[mps] print the jump list

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

Using tags N go :[range]go[to] [off] go to Nth byte in the buffer go to [off] byte in the buffer

Using tags
:ta[g][!] {tag} :[count]ta[g][!] CTRL-] :ts[elect][!] [tag] :tj[ump][!] [tag] :lt[ag][!] [tag] Jump to tag {tag} Jump to [count]'th newer tag in tag list Jump to the tag under cursor, unless changes have been made List matching tags and select one to jump to Jump to tag [tag] or select from list when there are multiple matches Jump to tag [tag] and add matching tags to the location list.

:tags Print tag list N CTRL-T Jump back from Nth older tag in tag list :[count]po[p][!] Jump back from [count]'th older tag in tag list :[count]tn[ext][!] Jump to [count]'th next matching tag :[count]tp[revious][!] Jump to [count]'th previous matching tag :[count]tr[ewind][!] Jump to [count]'th matching tag :tl[ast][!] Jump to last matching tag :pt[ag] {tag} CTRL-W } :pts[elect] :ptj[ump] :pc[lose] CTRL-W z open a preview window to show tag {tag} like CTRL-] but show tag in preview window like ":tselect" but show tag in preview window like ":tjump" but show tag in preview window close tag preview window close tag preview window

Scrolling
N N N N N N CTRL-E CTRL-D CTRL-F CTRL-Y CTRL-U CTRL-B z<CR> or zt z. or zz zor zb window N lines downwards (default: 1) window N lines Downwards (default: 1/2 window) window N pages Forwards (downwards) window N lines upwards (default: 1) window N lines Upwards (default: 1/2 window) window N pages Backwards (upwards) redraw, current line at top of window redraw, current line at center of window redraw, current line at bottom of window

These only work when 'wrap' is off: N zh scroll screen N characters to the right N zl scroll screen N characters to the left N zH scroll screen half a screenwidth to the right N zL scroll screen half a screenwidth 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) :star[tinsert][!] start Insert mode, append when [!] used :startr[eplace][!] start Replace mode, at EOL when [!] used In Visual block mode: I insert the same text in front of all the selected lines A append the same text after all the selected lines

Insert mode keys

Insert mode keys


Leaving Insert mode: <Esc> CTRL-C CTRL-O {command} Moving around: cursor keys shift-left/right shift-up/down <End> <Home> end Insert mode, back to Normal mode like <Esc>, but do not use an abbreviation execute {command} and return to Insert mode move cursor left/right/up/down one word left/right one screenful backward/forward cursor after last character in the line cursor to first character in the line

Special keys in Insert mode


CTRL-V {char}.. insert character literally, or enter decimal byte value <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-A insert previously inserted text CTRL-@ insert previously inserted text and stop Insert mode CTRL-R {0-9a-z%#:.-="} insert the contents of a register CTRL-N CTRL-P CTRL-X ... <BS> or CTRL-H <Del> CTRL-W CTRL-U CTRL-T CTRL-D 0 CTRL-D ^ CTRL-D insert next match of identifier before the cursor insert previous match of identifier before the cursor complete the word before the cursor in various ways delete delete delete delete insert delete delete delete the character before the cursor the character under the cursor word before the cursor all entered characters in the current line one shiftwidth of indent in front of the current line one shiftwidth of indent in front of the current line all indent in the current line all indent in the current line, restore indent in next line

Digraphs
:dig[raphs] show current list of digraphs :dig[raphs] {char1}{char2} {number} ... add digraph(s) to the list In Insert or Command-line mode: CTRL-K {char1} {char2} enter digraph {char1} <BS> {char2} enter digraph if 'digraph' option set

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

Deleting text
N x N <Del> N X N d{motion} {visual}d N dd N D delete delete delete delete delete delete delete N characters under and after the cursor N characters under and after the cursor N characters before the cursor the text that is moved over with {motion} the highlighted text N lines to the end of the line (and N-1 more lines)

Copying and moving text N J {visual}J N gJ {visual}gJ :[range]d [x] join N-1 lines (delete <EOL>s) join the highlighted lines like "J", but without inserting spaces like "{visual}J", but without inserting spaces delete [range] lines [into register x]

Copying and moving text


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

Changing text
N r{char} replace N characters with {char} N gr{char} replace N characters without affecting layout N R enter Replace mode (repeat the entered text N times) N gR enter virtual Replace mode: Like Replace mode but without affecting layout {visual}r{char} in Visual block mode: Replace each char of the selected text with {char} Note: change means to delete text and enter Insert mode 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 the end of the line (and N-1 more lines) N s change N characters {visual}c in Visual block mode: Change each line with entered text {visual}C in Visual block mode: Change each line until end-of-line with entered text N ~ {visual}~ {visual}u {visual}U g~{motion} gu{motion} gU{motion} {visual}g? g?{motion} N N CTRL-A CTRL-X switch case for N characters and advance cursor switch case for highlighted text make highlighted text lowercase make highlighted text uppercase switch case for the text that is moved over with {motion} make the text that is moved over with {motion} lowercase make the text that is moved over with {motion} uppercase perform rot13 encoding on highlighted text perform rot13 encoding on the text that is moved over with {motion} add N to the number at or after the cursor subtract N from the number at or after the cursor

N <{motion} move the lines that are moved over with {motion} one shiftwidth left N << move N lines one shiftwidth left N >{motion} move the lines that are moved over with {motion} one shiftwidth right N >> move N lines one shiftwidth right N gq{motion} format the lines that are moved over with {motion} 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

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 'equalprg' N == filter N lines through 'equalprg' {visual}= filter the highlighted lines through 'equalprg' :[range]s[ubstitute]/{pattern}/{string}/[g][c] substitute {pattern} by {string} in [range] lines; with [g], replace all occurrences of {pattern}; with [c], confirm each replacement :[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 V CTRL-V o gv v V CTRL-V start highlighting characters } move cursor and use start highlighting linewise } operator to affect start highlighting blockwise } highlighted text exchange cursor position with start of highlighting start highlighting on previous visual area highlight characters or stop highlighting highlight linewise or stop highlighting highlight blockwise or stop highlighting

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


N N N N N N N N N N N N N N N N N N N N N N aw iw aW iW as is ap ip ab ib aB iB a> i> at it a' i' a" i" a` i` Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select Select "a word" "inner word" "a |WORD|" "inner |WORD|" "a sentence" "inner sentence" "a paragraph" "inner paragraph" "a block" (from "[(" to "])") "inner block" (from "[(" to "])") "a Block" (from "[{" to "]}") "inner Block" (from "[{" to "]}") "a <> block" "inner <> block" "a tag block" (from <aaa> to </aaa>) "inner tag block" (from <aaa> to </aaa>) "a single quoted string" "inner single quoted string" "a double quoted string" "inner double quoted string" "a backward quoted string" "inner backward quoted string"

Repeating commands
N . q{a-z} q{A-Z} q N @{a-z} repeat last change (with count replaced with N) record typed characters into register {a-z} record typed characters, appended to register {a-z} stop recording execute the contents of register {a-z} (N times)

Key mapping 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] [sec] Don't do anything for [sec] seconds N gs Goto Sleep for N seconds

Key mapping
:ma[p] {lhs} {rhs} :ma[p]! {lhs} {rhs} :no[remap][!] {lhs} :unm[ap] {lhs} :unm[ap]! {lhs} :ma[p] [lhs] :ma[p]! [lhs] :c[un|nore]map :i[un|nore]map :n[un|nore]map :v[un|nore]map :o[un|nore]map :mapc[lear] :mapc[lear]! :imapc[lear] :vmapc[lear] :omapc[lear] :nmapc[lear] :cmapc[lear] :mk[exrc][!] [file] Map {lhs} to {rhs} in Normal and Visual mode. Map {lhs} to {rhs} in Insert and Command-line mode. {rhs} Same as ":map", no remapping for this {rhs} Remove the mapping of {lhs} for Normal and Visual mode. Remove the mapping of {lhs} for Insert and Command-line mode. List mappings (starting with [lhs]) for Normal and Visual mode. List mappings (starting with [lhs]) for Insert and Command-line mode. like ":[un|nore]map!" but for Command-line mode only like ":[un|nore]map!" but for Insert mode only like ":[un|nore]map" but for Normal mode only like ":[un|nore]map" but for Visual mode only like ":[un|nore]map" but only when operator is pending remove mappings for Normal and Visual mode remove mappings for Insert and Cmdline mode remove mappings for Insert mode remove mappings for Visual mode remove mappings for Operator-pending mode remove mappings for Normal mode remove mappings for Cmdline mode write current mappings, abbreviations, and settings to [file] (default: ".exrc"; use ! to overwrite) :mkv[imrc][!] [file] same as ":mkexrc", but with default ".vimrc" :mks[ession][!] [file] like ":mkvimrc", but store current files, windows, etc. too, to be able to continue this session later.

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

Options
:se[t] :se[t] :se[t] :se[t] :se[t] :se[t] :se[t] :se[t] all termcap {option} no{option} inv{option} {option}={value} {option}+={value} Show all modified options. Show all non-termcap options. Show all termcap options. Set boolean option (switch on), show string or number option. Reset boolean option (switch it off). invert boolean option. Set string/number option to {value}. append {value} to string option, add {value} to number option

Options :se[t] {option}-={value} :se[t] {option}? :se[t] {option}& :setl[ocal] :setg[lobal] :fix[del] :opt[ions] remove {value} from string option, subtract {value} from number option Show value of {option}. Reset {option} to its default value. like ":set" but set the local value for options that have one like ":set" but set the global value of a local option Set value of 't_kD' according to value of 't_kb'. Open a new window to view and set options, grouped by functionality, a one line explanation and links to the help. ASCII code of the letter Aleph (Hebrew) allow CTRL-_ in Insert and Command-line mode for default second language (Farsi/Hebrew) what to do with Unicode chars of ambiguous width Mac OS X: use smooth, antialiased fonts change directory to the file in the current window for Arabic as a default second language do shaping for Arabic characters take indent for new line from previous line autom. read file when changed outside of Vim automatically write file if changed as 'autowrite', but works with more commands "dark" or "light", used for highlight colors how backspace works at start of line keep backup file after overwriting a file make backup as a copy, don't rename the file list of directories for the backup file extension used for the backup file no backup for files that match these patterns delay in mS before a balloon may pop up switch on balloon evaluation expression to show in balloon read/write/edit file in binary mode MS-DOS: use bios calls for input characters prepend a Byte Order Mark to the file characters that may cause a line break which directory to start browsing in what to do when buffer is no longer in window whether the buffer shows up in the buffer list special type of buffer specifies how case of letters is changed list of directories searched with ":cd" key used to open the command-line window expression for character encoding conversion do C program indenting keys that trigger indent when 'cindent' is set how to do indenting when 'cindent' is set words where 'si' and 'cin' add an indent use the clipboard as the unnamed register number of lines to use for the command-line height of the command-line window number of columns in the display patterns that can start a comment line template for comments; used for fold marker behave Vi-compatible as much as possible specify how Insert mode completion works function to be used for Insert mode completion options for Insert mode completion ask what to do about unsaved/read-only files get keys directly from console (MS-DOS only)

Short explanation of each option: 'aleph' 'al' 'allowrevins' 'ari' 'altkeymap' 'akm' 'ambiwidth' 'ambw' 'antialias' 'anti' 'autochdir' 'acd' 'arabic' 'arab' 'arabicshape' 'arshape' 'autoindent' 'ai' 'autoread' 'ar' 'autowrite' 'aw' 'autowriteall' 'awa' 'background' 'bg' 'backspace' 'bs' 'backup' 'bk' 'backupcopy' 'bkc' 'backupdir' 'bdir' 'backupext' 'bex' 'backupskip' 'bsk' 'balloondelay' 'bdlay' 'ballooneval' 'beval' 'balloonexpr' 'bexpr' 'binary' 'bin' 'bioskey' 'biosk' 'bomb' 'breakat' 'brk' 'browsedir' 'bsdir' 'bufhidden' 'bh' 'buflisted' 'bl' 'buftype' 'bt' 'casemap' 'cmp' 'cdpath' 'cd' 'cedit' 'charconvert' 'ccv' 'cindent' 'cin' 'cinkeys' 'cink' 'cinoptions' 'cino' 'cinwords' 'cinw' 'clipboard' 'cb' 'cmdheight' 'ch' 'cmdwinheight' 'cwh' 'columns' 'co' 'comments' 'com' 'commentstring' 'cms' 'compatible' 'cp' 'complete' 'cpt' 'completefunc' 'cfu' 'completeopt' 'cot' 'confirm' 'cf' 'conskey' 'consk'

Options 'copyindent' 'cpoptions' 'cscopepathcomp' 'cscopeprg' 'cscopequickfix' 'cscopetag' 'cscopetagorder' 'cscopeverbose' 'cursorcolumn' 'cursorline' 'debug' 'define' 'delcombine' 'dictionary' 'diff' 'diffexpr' 'diffopt' 'digraph' 'directory' 'display' 'eadirection' 'edcompatible' 'encoding' 'endofline' 'equalalways' 'equalprg' 'errorbells' 'errorfile' 'errorformat' 'esckeys' 'eventignore' 'expandtab' 'exrc' 'fileencoding' 'fileencodings' 'fileformat' 'fileformats' 'filetype' 'fillchars' 'fkmap' 'foldclose' 'foldcolumn' 'foldenable' 'foldexpr' 'foldignore' 'foldlevel' 'foldlevelstart' 'foldmarker' 'foldmethod' 'foldminlines' 'foldnestmax' 'foldopen' 'foldtext' 'formatlistpat' 'formatoptions' 'formatprg' 'formatexpr' 'fsync' 'gdefault' 'grepformat' 'grepprg' 'guicursor' 'guifont' 'ci' 'cpo' 'cspc' 'csprg' 'csqf' 'cst' 'csto' 'csverb' 'cuc' 'cul' 'def' 'deco' 'dict' 'dex' 'dip' 'dg' 'dir' 'dy' 'ead' 'ed' 'enc' 'eol' 'ea' 'ep' 'eb' 'ef' 'efm' 'ek' 'ei' 'et' 'ex' 'fenc' 'fencs' 'ff' 'ffs' 'ft' 'fcs' 'fk' 'fcl' 'fdc' 'fen' 'fde' 'fdi' 'fdl' 'fdls' 'fmr' 'fdm' 'fml' 'fdn' 'fdo' 'fdt' 'flp' 'fo' 'fp' 'fex' 'fs' 'gd' 'gfm' 'gp' 'gcr' 'gfn' make 'autoindent' use existing indent structure flags for Vi-compatible behavior how many components of the path to show command to execute cscope use quickfix window for cscope results use cscope for tag commands determines ":cstag" search order give messages when adding a cscope database highlight the screen column of the cursor highlight the screen line of the cursor set to "msg" to see all error messages pattern to be used to find a macro definition delete combining characters on their own list of file names used for keyword completion use diff mode for the current window expression used to obtain a diff file options for using diff mode enable the entering of digraphs in Insert mode list of directory names for the swap file list of flags for how to display text in which direction 'equalalways' works toggle flags of ":substitute" command encoding used internally write <EOL> for last line in file windows are automatically made the same size external program to use for "=" command ring the bell for error messages name of the errorfile for the QuickFix mode description of the lines in the error file recognize function keys in Insert mode autocommand events that are ignored use spaces when <Tab> is inserted read .vimrc and .exrc in the current directory file encoding for multi-byte text automatically detected character encodings file format used for file I/O automatically detected values for 'fileformat' type of file, used for autocommands characters to use for displaying special items Farsi keyboard mapping close a fold when the cursor leaves it width of the column used to indicate folds set to display all folds open expression used when 'foldmethod' is "expr" ignore lines when 'foldmethod' is "indent" close folds with a level higher than this 'foldlevel' when starting to edit a file markers used when 'foldmethod' is "marker" folding type minimum number of lines for a fold to be closed maximum fold depth for which commands a fold will be opened expression used to display for a closed fold pattern used to recognize a list header how automatic formatting is to be done name of external program used with "gq" command expression used with "gq" command whether to invoke fsync() after file write the ":substitute" flag 'g' is default on format of 'grepprg' output program to use for ":grep" GUI: settings for cursor shape and blinking GUI: Name(s) of font(s) to be used

10

Options 'guifontset' 'guifontwide' 'guiheadroom' 'guioptions' 'guipty' 'guitablabel' 'guitabtooltip' 'helpfile' 'helpheight' 'helplang' 'hidden' 'highlight' 'hlsearch' 'history' 'hkmap' 'hkmapp' 'icon' 'iconstring' 'ignorecase' 'imactivatekey' 'imcmdline' 'imdisable' 'iminsert' 'imsearch' 'include' 'includeexpr' 'incsearch' 'indentexpr' 'indentkeys' 'infercase' 'insertmode' 'isfname' 'isident' 'iskeyword' 'isprint' 'joinspaces' 'key' 'keymap' 'keymodel' 'keywordprg' 'langmap' 'langmenu' 'laststatus' 'lazyredraw' 'linebreak' 'lines' 'linespace' 'lisp' 'lispwords' 'list' 'listchars' 'loadplugins' 'macatsui' 'magic' 'makeef' 'makeprg' 'matchpairs' 'matchtime' 'maxcombine' 'maxfuncdepth' 'maxmapdepth' 'maxmem' 'maxmempattern' 'gfs' 'gfw' 'ghr' 'go' 'gtl' 'gtt' 'hf' 'hh' 'hlg' 'hid' 'hl' 'hls' 'hi' 'hk' 'hkp' 'ic' 'imak' 'imc' 'imd' 'imi' 'ims' 'inc' 'inex' 'is' 'inde' 'indk' 'inf' 'im' 'isf' 'isi' 'isk' 'isp' 'js' 'kmp' 'km' 'kp' 'lmap' 'lm' 'ls' 'lz' 'lbr' 'lsp' 'lw' 'lcs' 'lpl' 'mef' 'mp' 'mps' 'mat' 'mco' 'mfd' 'mmd' 'mm' 'mmp' GUI: Names of multi-byte fonts to be used list of font names for double-wide characters GUI: pixels room for window decorations GUI: Which components and options are used GUI: try to use a pseudo-tty for ":!" commands GUI: custom label for a tab page GUI: custom tooltip for a tab page full path name of the main help file minimum height of a new help window preferred help languages don't unload buffer when it is YXXYabandon|ed sets highlighting mode for various occasions highlight matches with last search pattern number of command-lines that are remembered Hebrew keyboard mapping phonetic Hebrew keyboard mapping let Vim set the text of the window icon string to use for the Vim icon text ignore case in search patterns key that activates the X input method use IM when starting to edit a command line do not use the IM in any mode use :lmap or IM in Insert mode use :lmap or IM when typing a search pattern pattern to be used to find an include file expression used to process an include line highlight match while typing search pattern expression used to obtain the indent of a line keys that trigger indenting with 'indentexpr' adjust case of match for keyword completion start the edit of a file in Insert mode characters included in file names and pathnames characters included in identifiers characters included in keywords printable characters two spaces after a period with a join command encryption key name of a keyboard mapping enable starting/stopping selection with keys program to use for the "K" command alphabetic characters for other language mode language to be used for the menus tells when last window has status lines don't redraw while executing macros wrap long lines at a blank number of lines in the display number of pixel lines to use between characters automatic indenting for Lisp words that change how lisp indenting works show <Tab> and <EOL> characters for displaying in list mode load plugin scripts when starting up Mac GUI: use ATSUI text drawing changes special characters in search patterns name of the errorfile for ":make" program to use for the ":make" command pairs of characters that "%" can match tenths of a second to show matching paren maximum nr of combining characters displayed maximum recursive depth for user functions maximum recursive depth for mapping maximum memory (in Kbyte) used for one buffer maximum memory (in Kbyte) used for pattern search

11

Options 'maxmemtot' 'menuitems' 'mkspellmem' 'modeline' 'modelines' 'modifiable' 'modified' 'more' 'mouse' 'mousefocus' 'mousehide' 'mousemodel' 'mouseshape' 'mousetime' 'mzquantum' 'nrformats' 'number' 'numberwidth' 'omnifunc' 'opendevice' 'operatorfunc' 'osfiletype' 'paragraphs' 'paste' 'pastetoggle' 'patchexpr' 'patchmode' 'path' 'preserveindent' 'previewheight' 'previewwindow' 'printdevice' 'printencoding' 'printexpr' 'printfont' 'printheader' 'printmbcharset' 'printmbfont' 'printoptions' 'pumheight' 'quoteescape' 'readonly' 'redrawtime' 'remap' 'report' 'restorescreen' 'revins' 'rightleft' 'rightleftcmd' 'ruler' 'rulerformat' 'runtimepath' 'scroll' 'scrollbind' 'scrolljump' 'scrolloff' 'scrollopt' 'sections' 'secure' 'selection' 'selectmode' 'sessionoptions' 'shell' 'mmt' 'mis' 'msm' 'ml' 'mls' 'ma' 'mod' maximum memory (in Kbyte) used for all buffers maximum number of items in a menu memory used before |:mkspell| compresses the tree recognize modelines at start or end of file number of lines checked for modelines changes to the text are not possible buffer has been modified pause listings when the whole screen is filled enable the use of mouse clicks 'mousef' keyboard focus follows the mouse 'mh' hide mouse pointer while typing 'mousem' changes meaning of mouse buttons 'mouses' shape of the mouse pointer in different modes 'mouset' max time between mouse double-click 'mzq' the interval between polls for MzScheme threads 'nf' number formats recognized for CTRL-A command 'nu' print the line number in front of each line 'nuw' number of columns used for the line number 'ofu' function for filetype-specific completion 'odev' allow reading/writing devices on MS-Windows 'opfunc' function to be called for |g@| operator 'oft' operating system-specific filetype information 'para' nroff macros that separate paragraphs allow pasting text 'pt' key code that causes 'paste' to toggle 'pex' expression used to patch a file 'pm' keep the oldest version of a file 'pa' list of directories searched with "gf" et.al. 'pi' preserve the indent structure when reindenting 'pvh' height of the preview window 'pvw' identifies the preview window 'pdev' name of the printer to be used for :hardcopy 'penc' encoding to be used for printing 'pexpr' expression used to print PostScript for :hardcopy 'pfn' name of the font to be used for :hardcopy 'pheader' format of the header used for :hardcopy 'pmbcs' CJK character set to be used for :hardcopy 'pmbfn' font names to be used for CJK output of :hardcopy 'popt' controls the format of :hardcopy output 'ph' maximum height of the popup menu 'qe' escape characters used in a string 'ro' disallow writing the buffer 'rdt' timeout for 'hlsearch' and |:match| highlighting allow mappings to work recursively threshold for reporting nr. of lines changed 'rs' Win32: restore screen when exiting 'ri' inserting characters will work backwards 'rl' window is right-to-left oriented 'rlc' commands for which editing works right-to-left 'ru' show cursor line and column in the status line 'ruf' custom format for the ruler 'rtp' list of directories used for runtime files 'scr' lines to scroll with CTRL-U and CTRL-D 'scb' scroll in window as other windows scroll 'sj' minimum number of lines to scroll 'so' minimum nr. of lines above and below cursor 'sbo' how 'scrollbind' should behave 'sect' nroff macros that separate sections secure mode for reading .vimrc in current dir 'sel' what type of selection to use 'slm' when to use Select mode instead of Visual mode 'ssop' options for |:mksession| 'sh' name of shell to use for external commands

12

Options 'shellcmdflag' 'shellpipe' 'shellquote' 'shellredir' 'shellslash' 'shelltemp' 'shelltype' 'shellxquote' 'shiftround' 'shiftwidth' 'shortmess' 'shortname' 'showbreak' 'showcmd' 'showfulltag' 'showmatch' 'showmode' 'showtabline' 'sidescroll' 'sidescrolloff' 'smartcase' 'smartindent' 'smarttab' 'softtabstop' 'spell' 'spellcapcheck' 'spellfile' 'spelllang' 'spellsuggest' 'splitbelow' 'splitright' 'startofline' 'statusline' 'suffixes' 'suffixesadd' 'swapfile' 'swapsync' 'switchbuf' 'synmaxcol' 'syntax' 'tabstop' 'tabline' 'tabpagemax' 'tagbsearch' 'taglength' 'tagrelative' 'tags' 'tagstack' 'term' 'termbidi' 'termencoding' 'terse' 'textauto' 'textmode' 'textwidth' 'thesaurus' 'tildeop' 'timeout' 'timeoutlen' 'title' 'titlelen' 'titleold' 'titlestring' 'shcf' 'sp' 'shq' 'srr' 'ssl' 'stmp' 'st' 'sxq' 'sr' 'sw' 'shm' 'sn' 'sbr' 'sc' 'sft' 'sm' 'smd' 'stal' 'ss' 'siso' 'scs' 'si' 'sta' 'sts' 'spc' 'spf' 'spl' 'sps' 'sb' 'spr' 'sol' 'stl' 'su' 'sua' 'swf' 'sws' 'swb' 'smc' 'syn' 'ts' 'tal' 'tpm' 'tbs' 'tl' 'tr' 'tag' 'tgst' 'tbidi' 'tenc' 'ta' 'tx' 'tw' 'tsr' 'top' 'to' 'tm' flag to shell to execute one command string to put output of ":make" in error file quote character(s) for around shell command string to put output of filter in a temp file use forward slash for shell file names whether to use a temp file for shell commands Amiga: influences how to use a shell like 'shellquote', but include redirection round indent to multiple of shiftwidth number of spaces to use for (auto)indent step list of flags, reduce length of messages non-MS-DOS: Filenames assumed to be 8.3 chars string to use at the start of wrapped lines show (partial) command in status line show full tag pattern when completing tag briefly jump to matching bracket if insert one message on status line to show current mode tells when the tab pages line is displayed minimum number of columns to scroll horizontal min. nr. of columns to left and right of cursor no ignore case when pattern has uppercase smart autoindenting for C programs use 'shiftwidth' when inserting <Tab> number of spaces that <Tab> uses while editing enable spell checking pattern to locate end of a sentence files where |zg| and |zw| store words language(s) to do spell checking for method(s) used to suggest spelling corrections new window from split is below the current one new window is put right of the current one commands move cursor to first non-blank in line custom format for the status line suffixes that are ignored with multiple match suffixes added when searching for a file whether to use a swapfile for a buffer how to sync the swap file sets behavior when switching to another buffer maximum column to find syntax items syntax to be loaded for current buffer number of spaces that <Tab> in file uses custom format for the console tab pages line maximum number of tab pages for |-p| and "tab all" use binary searching in tags files number of significant characters for a tag file names in tag file are relative list of file names used by the tag command push tags onto the tag stack name of the terminal terminal takes care of bi-directionality character encoding used by the terminal shorten some messages obsolete, use 'fileformats' obsolete, use 'fileformat' maximum width of text that is being inserted list of thesaurus files for keyword completion tilde command "~" behaves like an operator time out on mappings and key codes time out time in milliseconds let Vim set the title of the window percentage of 'columns' used for window title old title, restored when exiting string to use for the Vim window title

13

Undo/Redo commands 'toolbar' 'toolbariconsize' 'ttimeout' 'ttimeoutlen' 'ttybuiltin' 'ttyfast' 'ttymouse' 'ttyscroll' 'ttytype' 'undolevels' 'updatecount' 'updatetime' 'verbose' 'verbosefile' 'viewdir' 'viewoptions' 'viminfo' 'virtualedit' 'visualbell' 'warn' 'weirdinvert' 'whichwrap' 'wildchar' 'wildcharm' 'wildignore' 'wildmenu' 'wildmode' 'wildoptions' 'winaltkeys' 'winheight' 'winfixheight' 'winfixwidth' 'winminheight' 'winminwidth' 'winwidth' 'wrap' 'wrapmargin' 'wrapscan' 'write' 'writeany' 'writebackup' 'writedelay' 'tb' 'tbis' 'ttm' 'tbi' 'tf' 'ttym' 'tsl' 'tty' 'ul' 'uc' 'ut' 'vbs' 'vfile' 'vdir' 'vop' 'vi' 've' 'vb' 'wi' 'ww' 'wc' 'wcm' 'wig' 'wmnu' 'wim' 'wop' 'wak' 'wh' 'wfh' 'wfw' 'wmh' 'wmw' 'wiw' 'wm' 'ws' 'wa' 'wb' 'wd' GUI: which items to show in the toolbar size of the toolbar icons (for GTK 2 only) time out on mappings time out time for key codes in milliseconds use built-in termcap before external termcap indicates a fast terminal connection type of mouse codes generated maximum number of lines for a scroll alias for 'term' maximum number of changes that can be undone after this many characters flush swap file after this many milliseconds flush swap file give informative messages file to write messages in directory where to store files with :mkview specifies what to save for :mkview use .viminfo file upon startup and exiting when to use virtual editing use visual bell instead of beeping warn for shell command when buffer was changed for terminals that have weird inversion method allow specified keys to cross line boundaries command-line character for wildcard expansion like 'wildchar' but also works when mapped files matching these patterns are not completed use menu for command line completion mode for 'wildchar' command-line expansion specifies how command line completion is done. when the windows system handles ALT keys minimum number of lines for the current window keep window height when opening/closing windows keep window width when opening/closing windows minimum number of lines for any window minimal number of columns for any window minimal number of columns for current window long lines wrap and continue on the next line chars from the right where wrapping starts searches wrap around the end of the file writing to a file is allowed write to file with no need for "!" override make a backup before overwriting a file delay this many msec for each char (for debug)

14

Undo/Redo commands
N N U u CTRL-R undo last N changes redo last N undone changes restore last changed line

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

Quickfix commands
:cc [nr] :cn :cp :cl :cf display error [nr] (default is the same again) display the next error display the previous error list all errors read errors from the file 'errorfile'

Various commands :cgetb :cg :cgete :caddf :cad :cb :cex :cq :make [args] :gr[ep] [args] like :cbuffer but don't jump to the first error like :cfile but don't jump to the first error like :cexpr but don't jump to the first error add errors from the error file to the current quickfix list add errors from an expression to the current quickfix list read errors from text in a buffer read errors from an expression quit without writing and return error code (to the compiler) start make, read errors, and jump to first error execute 'grepprg' to find matches and jump to the first one.

15

Various commands
CTRL-L CTRL-G ga g8 g CTRL-G CTRL-C CTRL-Break <Del> :ve[rsion] :mode N :norm[al][!] Q Clear and redraw the screen. show current file name (with path) and cursor position show ascii value of character under cursor in decimal, hex, and octal for utf-8 encoding: show byte sequence for character under cursor in hex. show cursor column, line, and character position during searches: Interrupt the search MS-DOS: during searches: Interrupt the search while entering a count: delete last character show version information MS-DOS: set screen mode to N (number, C80, C4350, etc.) {commands} Execute Normal mode commands. switch to "Ex" mode redirect messages to {file} execute {command} silently quit, write, etc., asking about unsaved changes or read-only files. open/read/write file, using a file selection dialog

:redir >{file} :silent[!] {command} :confirm {command} :browse {command}

Command-line editing
<Esc> CTRL-V CTRL-V CTRL-K CTRL-R abandon command-line (if 'wildchar' is <Esc>, type it twice) {char} insert {char} literally {number} enter decimal value of character (up to three digits) {char1} {char2} enter digraph (See |Q_di|) {0-9a-z"%#:-=} insert the contents of a register

<Left>/<Right> cursor left/right <S-Left>/<S-Right> cursor one word left/right CTRL-B/CTRL-E cursor to beginning/end of command-line <BS> <Del> CTRL-W CTRL-U <Up>/<Down> <S-Up>/<S-Down> :his[tory] delete delete delete remove the the the all character in front of the cursor character under the cursor word in front of the cursor characters

recall older/newer command-line that starts with current command recall older/newer command-line from history show older command-lines If

Context-sensitive completion on the command-line: 'wildchar' (default: <Tab>) do completion on the pattern in front of the cursor. 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

16

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

Special Ex characters
| " % #[num] separates two commands (not for ":global" and ":!") begins comment current file name (only where a file name is expected) alternate file name [num] (only where a file name is expected)

Note: The next five are typed literally; these are not special keys! <cword> word under the cursor (only where a file name is expected) <cWORD> WORD under the cursor (only where a file name is expected) (see |WORD|) <cfile> file name under the cursor (only where a file name is expected) <afile> file name for autocommand (only where a file name is expected) <sfile> file name of a ":source"d file, within that file (where a file name is expected) After "%", "#", "<cfile>", "<sfile>" or "<afile>" :p full path :h head (file name removed) :t tail (file name only) :r root (extension removed) :e extension :s/{pat}/{repl}/ substitute {pat} with {repl}

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

Most useful Vim arguments (for full list see |startup-options|) -g start GUI (also allows other 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 Vi mode, start ex in Normal mode -e Ex mode, start vim in Ex mode -R Read-only mode, implies -n -m modifications not allowed (resets 'write' option) -d diff mode |diff| -b binary mode -l lisp mode -A Arabic mode ('arabic' is set) -F Farsi mode ('fkmap' and 'rightleft' are set) -H Hebrew mode ('hkmap' and 'rightleft' are set)

Editing a file -V -C -N -r -r {file} .. -n -o [num] -f -s {scriptin} -w {scriptout} -W {scriptout} -T {terminal} -d {device} -u {vimrc} -U {gvimrc} -i {viminfo} ---help --version Verbose, give informative messages Compatible, set the 'compatible' option Nocompatible, reset the 'compatible' option give list of swap files recover aborted edit session do not create a swap file open [num] windows (default: one for each file) GUI: foreground process, don't fork first read commands from the file {scriptin} write typed chars to file {scriptout} (append) write typed chars to file {scriptout} (overwrite) set terminal name Amiga: open {device} to be used as a console read inits from {vimrc} instead of other inits idem, for when starting the GUI read info from {viminfo} instead of other files end of options, other arguments are file names show list of arguments and exit show version info and exit Read file from stdin.

17

Editing a file
Without !: Fail if changes has been made to the current buffer. With !: Discard any changes to the current buffer. :e[dit][!] {file} Edit {file}. :e[dit][!] Reload the current file. :ene[w][!] Edit a new, unnamed buffer. :fin[d][!] {file} Find {file} in 'path' and edit it. N CTRL-^ gf or ]f :pwd :cd [path] :cd :f[ile] :f[ile] {name} :files Edit alternate file N (equivalent to ":e #N"). Edit the file whose name is under the cursor Print the current directory name. Change the current directory to [path]. Back to previous current directory. Print the current file name and the cursor position. Set the current file name to {name}. Show alternate file names.

Using the argument list


:ar[gs] :all or :sall :wn[ext][!] :wn[ext][!] {file} :wN[ext][!] [file] :argu[ment] N :n[ext] :n[ext] {arglist} :N[ext] :fir[st] :la[st] Print the argument list, with the current file in "[]". Open a window for every file in the arg list. Write file and edit next file. Write to {file} and edit next file, unless {file} exists. overwrite existing file. Write file and edit previous file. in current window :sar[gument] N :sn[ext] :sn[ext] {arglist} :sN[ext] :sfir[st] :sla[st] With !,

in new window Edit file N Edit next file define new arg list and edit first file Edit previous file Edit first file Edit last file

Writing and quitting

18

Writing and quitting


:[range]w[rite][!] :[range]w[rite] {file} :[range]w[rite]! {file} :[range]w[rite][!] >> :[range]w[rite][!] >> {file} :[range]w[rite] !{cmd} :[range]up[date][!] :wa[ll][!] :q[uit] :q[uit]! :qa[ll] :qa[ll]! :cq Write to the current file. Write to {file}, unless it already exists. Write to {file}. Overwrite an existing file. Append to the current file. Append to {file}. Execute {cmd} with [range] lines as standard input. write to current file if modified write all changed buffers

Quit current buffer, unless changes have been made. Exit Vim when there are no other non-help buffers Quit current buffer always, discard any changes. Exit Vim when there are no other non-help buffers Exit Vim, unless changes have been made. Exit Vim always, discard any changes. 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". ZQ Same as ":q!". :xa[ll][!] or :wqall[!] Write all changed buffers and exit :st[op][!] CTRL-Z Suspend VIM or start new shell. given write the buffer. Same as ":stop" If 'aw' option is set and [!] not

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

Multi-window commands
CTRL-W s or :split :split {file} :vsplit {file} :vertical {cmd} Split window into two parts Split window and edit {file} in one of them Same, but split vertically Make {cmd} split vertically

Buffer list commands :sf[ind] {file} CTRL-W ] CTRL-W f CTRL-W ^ CTRL-W n or :new CTRL-W q or :q[uit] CTRL-W c or :cl[ose] CTRL-W o or :on[ly] CTRL-W CTRL-W CTRL-W CTRL-W CTRL-W CTRL-W CTRL-W j k CTRL-W W t b p Split window, find {file} in 'path' and edit it. Split window and jump to tag under cursor Split window and edit file name under the cursor Split window and edit alternate file Create new empty window Quit editing and close window Make buffer hidden and close window Make current window only one on the screen Move Move Move Move Move Move Move cursor cursor cursor cursor cursor cursor cursor to to to to to to to window below window above window below (wrap) window above (wrap) top window bottom window previous active window

19

CTRL-W r CTRL-W R CTRL-W x CTRL-W CTRL-W CTRL-W CTRL-W = + _

Rotate windows downwards Rotate windows upwards Exchange current window with next one Make all windows equal height Decrease current window height Increase current window height Set current window height (default: very high)

Buffer list commands


:buffers :ball :unhide or or or :files :sball :sunhide list all known buffer and file names edit all args/buffers edit all loaded buffers

:badd {fname} :bunload[!] [N] :bdelete[!] [N] window :[N]buffer [N] :[N]bnext [N] :[N]bNext [N] :[N]bprevious [N] :bfirst :blast :[N]bmod [N]

add file name {fname} to the list unload buffer [N] from memory unload buffer [N] and delete it from the buffer list in current in new window :[N]sbuffer [N] :[N]sbnext [N] :[N]sbNext [N] :[N]sbprevious [N] :sbfirst :sblast :[N]sbmod [N] to to to to to to arg/buf N Nth next arg/buf Nth previous arg/buf Nth previous arg/buf first arg/buf last arg/buf

to Nth modified buf

Syntax Highlighting
:syntax on :syntax off :syntax :syntax :syntax :syntax :syntax :syntax start using syntax highlighting stop using syntax highlighting add a syntax keyword item add syntax match item add syntax region item tell syntax how to sync keyword {group-name} {keyword} .. match {group-name} {pattern} ... region {group-name} {pattern} ... sync [ccomment | lines {N} | ...] [list] list current syntax items clear clear all syntax info

:highlight clear clear all highlight info :highlight {group-name} {key}={arg} .. set highlighting for {group-name} :filetype on switch on file type detection, without syntax highlighting :filetype plugin indent on turn on file type detection, with auto indenting and settings

GUI commands

20

GUI commands
:gui :gui {fname} .. UNIX: start the GUI idem, and edit {fname} .. :menu list all menus :menu {mpath} list menus starting with {mpath} :menu {mpath} {rhs} add menu {mpath}, giving {lhs} :menu {pri} {mpath} {rhs} idem, with priorities {pri} :menu ToolBar.{name} {rhs} add toolbar item, giving {lhs} :tmenu {mpath} {text} add tooltip to menu {mpath} :unmenu {mpath} remove menu {mpath}

Folding
set set set set set foldmethod=manual foldmethod=indent foldmethod=expr foldmethod=syntax foldmethod=marker manual folding folding by indent folding by 'foldexpr' folding by syntax regions folding by 'foldmarkers' operator: Define a fold manually define a fold for {range} lines delete one fold under the cursor delete all folds under the cursor open one fold under the cursor open all folds under the cursor close one fold under the cursor close all folds under the cursor fold more: decrease 'foldlevel' close all folds: make 'foldlevel' zero reduce folding: increase 'foldlevel' open all folds: make 'foldlevel' max. fold none: reset 'foldenable' fold normal set 'foldenable' invert 'foldenable'

zf{motion} :{range}fold zd zD zo zO zc zC zm zM zr zR zn zN zi

You might also like