home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / amiga / vim46bin.lha / vim-4.6 / doc / vim_ref.txt < prev    next >
Encoding:
Text File  |  1997-03-12  |  429.3 KB  |  10,363 lines

  1. *vim_ref.txt*   For Vim version 4.6.  Last modification: 1997 Mar 12
  2.  
  3.  
  4.                  VIM REFERENCE MANUAL
  5.  
  6.                   By Bram Moolenaar
  7.  
  8.  
  9.  
  10. There is a contents listing at the end of this document. |reference_contents|
  11.  
  12. This manual mostly assumes that there is only one window.  The commands and
  13. options for multiple windows and buffers are explained in |vim_win.txt|.
  14.  
  15. This manual describes running Vim from a normal terminal or with a terminal
  16. emulator in a window.  See |vim_gui.txt| for the GUI version.
  17.  
  18. You can use tags to jump to the explanation of a subject.  Position the cursor
  19. on an item name between bars (e.g., |intro|) or an option name in single
  20. quotes (e.g., 'textwidth') and hit CTRL-].  This mostly also works on a
  21. command in double quotes (e.g., ":buf").  Three special characters in the
  22. names of the tags are not allowed.  They have been replaced with letters:
  23. "bar" for '|', "star" for '*', and "quote" for '"'.
  24.  
  25.                    tag starts with    example
  26.        Normal and Visual mode    nothing        |x|
  27.                   Visual mode    "v_"        |v_u|
  28.               Insert mode    "i_"        |i_<Esc>|
  29.     Command line commands    ":"        |:quit|
  30.      Command line editing    "c_"        |c_<Del>|
  31.       Vim command options    "-"        |-r|
  32.           Vim options    "'"        |'shell'|
  33.  
  34.  
  35. 1. Introduction                        *intro*
  36. ===============
  37.  
  38. Vim stands for Vi IMproved.  It used to be Vi IMitation, but there are so many
  39. improvements that a name change was appropriate.  Vim is a text editor which
  40. includes almost all the commands from the Unix program "Vi" and a lot of new
  41. ones.  It is very useful for editing programs and other 8-bit ASCII text.  All
  42. commands are given with the keyboard.  This has the advantage that you can
  43. keep your fingers on the keyboard and your eyes on the screen.  For those who
  44. want it, there is mouse support and a GUI version with scrollbars and menus
  45. (see |vim_gui.txt|).
  46.  
  47. Throughout this manual the differences between Vi and Vim are mentioned in
  48. curly braces.  See |vim_diff.txt| for a summary of the differences.
  49.  
  50. This manual refers to Vim on various machines.  There may be small differences
  51. between different computers and terminals.  Besides the remarks given in this
  52. document, there is a separate document for each supported system:
  53.       system                see
  54.     Amiga                |vim_ami.txt|
  55.     Archimedes            |vim_arch.txt|
  56.     Atari MiNT                  |vim_mint.txt|
  57.     Macintosh            |vim_mac.txt|
  58.     MS-DOS                |vim_dos.txt|
  59.     OS/2                |vim_os2.txt|
  60.     Unix                |vim_unix.txt|
  61.     Win32: Windows NT / Windows 95    |vim_w32.txt|
  62.  
  63. This manual is a reference for all the Vim commands and options.  This is not
  64. an introduction to the use of Vim.  There are many books on vi that contain a
  65. section for beginners.
  66.  
  67. A summary of this manual can be found in the file "vim_help.txt",
  68. |vim_help.txt|.  It can be accessed from within Vim with the <Help> or <F1>
  69. key and with the command ":help", |:help|.  The 'helpfile' option can be set
  70. to the name of the help file, so you can put it in any place you like.
  71.  
  72.  
  73. 2. Notation                        *notation*
  74. ===========
  75.  
  76. []        Characters in square brackets are optional.
  77.  
  78.                             *count* *[count]*
  79. [count]        An optional number that may precede the command to multiply
  80.         or iterate the command.  If no number is given, a count of one
  81.         is used, unless otherwise noted.  Note that in this manual the
  82.         [count] is not mentioned in the description of the command,
  83.         but only in the explanation.  This was done to make the
  84.         commands easier to lookup.  If the "sc" option is on
  85.         (|'showcmd'|), the (partially) entered count is shown at the
  86.         bottom of the window.  You can use <Del> to erase the last
  87.         digit (|N<Del>|).
  88.  
  89.                             *[quotex]*
  90. ["x]        An optional register designation where text can be stored.
  91.         See |registers|.  The x is a single character between 'a' and
  92.         'z' or 'A' and 'Z' or '"', and in some cases (with the put
  93.         command) between '0' and '9', '%', ':', or '.'.  The uppercase
  94.         and lowercase letters designate the same register, but the
  95.         lowercase letter is used to overwrite the previous register
  96.         contents, while the uppercase letter is used to append to the
  97.         previous register contents.  Without the ""x" or with """",
  98.         the stored text is put into the unnamed register.
  99.  
  100.                             *{}*
  101. {}        Curly braces denote parts of the command which must appear,
  102.         but which can take a number of different values.  The
  103.         differences between Vim and Vi are also given in curly braces
  104.         (this will be clear from the context).
  105.  
  106.                             *{motion}*
  107. {motion}    A command that moves the cursor.  See the list in chapter 6,
  108.         |cursor_motions|.  This is used after an operator command
  109.         |operator| to move over the text that is to be operated upon.
  110.         If the motion includes a count and the operator also had a
  111.         count, the two counts are multiplied.  For example: "2d3w"
  112.         deletes six words.  The motion can also be a mouse click.  The
  113.         mouse is currently only supported for MS-DOS, Win32 and xterm
  114.         under Unix.
  115.  
  116.                             *{Visual}*
  117. {Visual}    A piece of text that is started with the "v", "V", or CTRL-V
  118.         command and ended by the cursor position.  This is used
  119.         before an operator command |operator| to highlight the text
  120.         that is to be operated upon.  See the chapter on Visual mode
  121.         |Visual_mode|.
  122.  
  123.                             *<character>*
  124. <character>    A special character from the table below or a single ASCII
  125.         character.
  126.  
  127.                             *'character'*
  128. 'character'    A single ASCII character.
  129.  
  130.                             *<char1-char2>*
  131. <char1-char2>    A single character from the range <char1> to <char2>.  For
  132.         example: <a-z> is a lowercase letter.  Multiple ranges may be
  133.         concatenated.  For example, <a-zA-Z0-9> is any alphanumeric
  134.         character.
  135.  
  136.                             *CTRL-{char}*
  137. CTRL-{char}    {char} typed as a control character; that is, typing {char}
  138.         while holding the CTRL key down.  The case of {char} does not
  139.         matter; thus CTRL-A and CTRL-a are equivalent.  But on some
  140.         terminals, using the SHIFT key will produce another code,
  141.         don't use it then.
  142.  
  143.                             *'option'*
  144. 'option'    An option, or parameter, that can be set to a value, is
  145.         enclosed in single quotes.  See chapter 19, |options|.
  146.  
  147.                             *quotecommandquote*
  148. "command"    In examples, the commands you can type are enclosed in double
  149.         quotes.
  150.  
  151.                             *key_notation*
  152. notation    meaning            equivalent    decimal value(s)
  153. -----------------------------------------------------------------------
  154. <Nul>        zero            CTRL-@      0 (stored as 10) *<Nul>*
  155. <BS>        backspace        CTRL-H      8    *backspace*
  156. <Tab>        tab            CTRL-I      9    *tab*
  157.                             *linefeed*
  158. <NL>        linefeed        CTRL-J     10 (used for <Nul>)
  159. <CR>        carriage return        CTRL-M     13    *carriage_return*
  160. <Esc>        escape            CTRL-[     27    *escape* *<Esc>*
  161. <Space>        space                 32    *space*
  162. <Del>        delete                127
  163.  
  164. <Up>        cursor-up            *cursor-up* *cursor_up*
  165. <Down>        cursor-down            *cursor-down* *cursor_down*
  166. <Left>        cursor-left            *cursor-left* *cursor_left*
  167. <Right>        cursor-right            *cursor-right* *cursor_right*
  168. <S-Up>        shift-cursor-up
  169. <S-Down>    shift-cursor-down
  170. <S-Left>    shift-cursor-left
  171. <S-Right>    shift-cursor-right
  172. <F1> - <F12>    function keys 1 to 12        *function_key* *function-key*
  173. <S-F1> - <S-F12> shift-function keys 1 to 12    *<S-F1>*
  174. <Help>        help key
  175. <Undo>        undo key
  176. <Insert>    insert key
  177. <Home>        home                *home*
  178. <End>        end                *end*
  179. <PageUp>    page-up                *page_up* *page-up*
  180. <PageDown>    page-down            *page_down* *page-down*
  181. <kHome>        keypad home (upper left)    *keypad_home*
  182. <kEnd>        keypad end (lower left)        *keypad_end*
  183. <kPageUp>    keypad page-up (upper right)    *keypad_page_up*
  184. <kPageDown>    keypad page-down (lower right)    *keypad_page_down*
  185. <S-...>        shift-key            *shift*
  186. <C-...>        control-key            *control* *ctrl*
  187. <M-...>        alt-key or meta-key        *meta* *alt*
  188. <t_xx>        key with "xx" entry in termcap
  189. -----------------------------------------------------------------------
  190.  
  191. Note: The shifted cursor keys, the help key, and the undo key are only
  192. available on a few terminals.  On the Amiga, shifted function key 10 produces
  193. a code (CSI) that is also used by key sequences.  It will be recognized only
  194. after typing another key.
  195.  
  196. Note: There are two codes for the delete key.  127 is the decimal ASCII value
  197. for the delete key, which is always recognized.  Some delete keys send another
  198. value, in which case this value is obtained from the termcap entry "kD".  Both
  199. values have the same effect.  Also see |:fixdel|.
  200.  
  201. Note: The keypad keys are used in the same way as the corresponding "normal"
  202. keys.  For example, <kHome> has the same effect as <Home>.  If a keypad key
  203. sends the same raw key code as it non-keypad equivalent, it will be recognized
  204. as the non-keypad code.  For example, when <kHome> sends the same code as
  205. <Home>, when pressing <kHome> Vim will think <Home> was pressed.  Mapping
  206. <kHome> will not work then.
  207.  
  208.                                 *<>*
  209. Some of the examples are given in the <> notation.  The rules are:
  210.  1.  Any printable characters are typed directly, except backslash and '<'
  211.  2.  A backslash is represented with "\\", double backslash.
  212.  3.  A real '<' is represented with "\<".
  213.  4.  "<key>" means the special key typed.  This is the notation explained in
  214.      the table above.  A few examples:
  215.        <Esc>        Escape key
  216.        <C-G>        CTRL-G
  217.        <Up>            cursor up key
  218.        <C-LeftMouse>    Control- left mouse click
  219.        <S-F11>        Shifted function key 11
  220.        <M-a>        Meta- a  ('a' with bit 8 set)
  221.        <M-A>        Meta- A  ('A' with bit 8 set)
  222.        <t_kd>        "kd" termcap entry (cursor down key)
  223.  
  224. If you want to use the full <> notation in Vim, you have to remove the 'B'
  225. flag from 'cpoptions' and make sure the '<' flag is excluded (it already is by
  226. default).
  227.     :set cpo=ceFs
  228. If you have the 'B' flag in 'cpoptions', then <> notation mostly still works,
  229. but you can't escape the special meaning of key names in <> with a backslash.
  230. To distinguish using <> with and without the 'B' flag, it's called full <>
  231. notation if the 'B' flag is excluded.
  232. For mapping, abbreviation and menu commands you can then copy-paste the
  233. examples and use them directly.  Or type them literally, including the '<' and
  234. '>' characters.  This does NOT work for other commands, like ":set" and
  235. ":autocmd"!
  236.  
  237.  
  238. 3. Starting Vim                        *starting*
  239. ===============
  240.  
  241. 3.1 Vim arguments                    *vim_arguments*
  242.  
  243. Most often, Vim is started to edit a single file with the command
  244.  
  245.     vim file                    *-vim*
  246.  
  247. More generally, Vim is started with:
  248.  
  249.     vim [options] [arglist]
  250.  
  251. If the arglist is missing, the editor will start with an empty buffer.
  252. Otherwise exactly one out of the following three may be used to choose one
  253. or more files to be edited.
  254.  
  255.                             *-file* *--*
  256. file ..        A list of file names.  The first one will be the current file
  257.         and read into the buffer.  The cursor will be positioned on
  258.         the first line of the buffer.  To avoid a file name starting
  259.         with a '-' being interpreted as an option, precede the arglist
  260.         with "--", e.g.:
  261.             Vim -- -filename
  262.  
  263.                             *-t* *-tag*
  264. -t {tag}    A tag.  "tag" is looked up in the tags file, the associated
  265.         file becomes the current file, and the associated command is
  266.         executed.  Mostly this is used for C programs.  In that case,
  267.         "tag" should be a function name.  The effect is that the file
  268.         containing that function becomes the current file and the
  269.         cursor is positioned on the start of the function (see the
  270.         section on tags, |tags|).
  271.  
  272.                             *-e* *-qf*
  273. -e [errorfile]    QuickFix mode.  The file with the name [errorfile] is read
  274.         and the first error is displayed.  If [errorfile] is not
  275.         given, the 'errorfile' option is used for the file name
  276.         (default "AztecC.Err" for the Amiga, "errors.vim" for other
  277.         systems).  See section 5.5: "using the QuickFix mode",
  278.         |quickfix|.  {not in Vi}
  279.  
  280.                             *startup-options*
  281. The options, if present, must precede the arglist.  The options may be given
  282. in any order.  Single-letter options can be combined after one dash.
  283.  
  284.                             *-+*
  285. +[num]        The cursor will be positioned on line "num" for the first
  286.         file being edited.  If "num" is missing, the cursor will be
  287.         positioned on the last line.
  288.  
  289.                             *-+/*
  290. +/{pat}        The cursor will be positioned on the first line containing
  291.         "pat" in the first file being edited (see the section
  292.         "pattern searches" for the available search patterns,
  293.         |search_pattern|).
  294.  
  295. +{command}                        *-+c* *-c*
  296. -c {command}    "command" will be executed after the first file has been
  297.         read (and after autocommands and modelines for that file have
  298.         been processed).  "command" is interpreted as an Ex command.
  299.         If the "command" contains spaces, it must be enclosed in
  300.         double quotes (this depends on the shell that is used).
  301.         Example: vim "+set si" main.c
  302.  
  303.         Note: You can use only one "+" or "-c" argument in a Vim
  304.         command.
  305.  
  306.                             *-r*
  307. -r        Recovery mode.  Without a file name argument, a list of
  308.         existing swap files is given.  With a file name, a swap file
  309.         is read to recover a crashed editing session.  See the
  310.         chapter "Recovery after a crash", |crash_recovery|.
  311.  
  312.                             *-L*
  313. -L        Same as -r.  {only in some versions of Vi: "List recoverable
  314.         edit sessions"}
  315.  
  316.                             *-v*
  317. -v        View mode.  The 'readonly' option will be set for all the
  318.         files being edited.  You can still edit the buffer, but will
  319.         be prevented from accidentally overwriting a file.  If you
  320.         forgot that you are in View mode and did make some changes,
  321.         you can overwrite a file by adding an exclamation mark to
  322.         the Ex command, as in ":w!".  The 'readonly' option can be
  323.         reset with ":set noro" (see the options chapter, |options|).
  324.         Subsequent edits will not be done in readonly mode.  Calling
  325.         the executable "view" has the same effect as the -v option.
  326.         If your system does not support links and you do not want to
  327.         have the executable twice, you could make an alias: "alias
  328.         view vim -v".  The 'updatecount' option will be set to 10000,
  329.         meaning that the swap file will not be updated automatically
  330.         very often.  {Vi: "ex -v" means to start ex in vi mode.
  331.         "vi -v" does nothing}
  332.  
  333.                             *-R*
  334. -R        Readonly mode.  Same as -v.
  335.  
  336.                             *-b*
  337. -b        Binary mode.  The 'textauto', 'textmode', and 'expandtab'
  338.         options will be reset.  The 'textwidth' option is set to 0.
  339.         'modeline' is reset.  The 'binary' option is set.  This is
  340.         done after reading the vimrc/exrc files but before reading
  341.         any file in the arglist.  See also 5.6:
  342.         "Editing binary files", |edit_binary|.  {not in Vi}
  343.  
  344.                             *-l*
  345. -l        Lisp mode.  Sets the 'lisp' and 'showmatch' options on.
  346.  
  347.                             *-H*
  348. -H        Hebrew mode.  Sets the 'hkmap' and 'rightleft' options on.
  349.         (Only when compiled with LEFTRIGHT defined, otherwise Vim
  350.         gives an error message and exits).  {not in Vi}
  351.  
  352.                             *-n*
  353. -n        No swap file will be used.  Recovery after a crash will be
  354.         impossible.  Handy if you want to view or edit a file on a
  355.         very slow medium (e.g., a floppy).  Can also be done with
  356.         ":set updatecount=0".  You can switch it on again by setting
  357.         the 'updatecount' option to some value, e.g., ":set uc=100".
  358.         {not in Vi}
  359.  
  360.                             *-o*
  361. -o[N]        Open N windows.  If [N] is not given, one window is opened
  362.         for every file given as argument.  If there is not enough
  363.         room, only the first few files get a window.  If there are
  364.         more windows than arguments, the last few windows will be
  365.         editing an empty file.  {not in Vi}
  366.  
  367.                             *-T*
  368. -T {terminal}    Set the terminal type to "terminal".  This influences the
  369.         codes that Vim will send to your terminal.  This is normally
  370.         not needed, because Vim will be able to find out what type
  371.         of terminal you are using (See chapter 20, |terminal_info|).
  372.         {not in Vi}
  373.  
  374.                             *-d*
  375. -d {device}    Amiga only: The "device" is opened to be used for editing.
  376.         Normally you would use this to set the window position and
  377.         size: "-d con:x/y/width/height", e.g.,
  378.         "-d con:30/10/600/150".  But you can also use it to start
  379.         editing on another device, e.g., AUX:.  {not in Vi}
  380.  
  381.                             *-x*
  382. -x        Amiga only: Do not restart Vim to open a new window.  This
  383.         option should be used when Vim is started by a program that
  384.         will wait for the edit session to finish (e.g., mail or
  385.         readnews).  See section 3.3, |amiga_window|.  {not in Vi}
  386.  
  387.                             *-f*
  388. -f        GUI only: Do not disconnect from the program that started Vim.
  389.         'f' stands for "foreground".  If omitted, the GUI forks a new
  390.         process and exits the current one.  "-f" should be used when
  391.         gvim is started by a program that will wait for the edit
  392.         session to finish (e.g., mail or readnews).  If you want gvim
  393.         never to fork, include 'f' in 'guioptions'.  Careful: You can
  394.         use "-gf" to start the GUI in the foreground, but "-fg" is
  395.         used to specify the foreground color.  {not in Vi} |gui_fork|
  396.  
  397.                             *-u*
  398. -u {vimrc}    The file "vimrc" is read for initializations.  Other
  399.         initializations are skipped; see |initialization|.  This can
  400.         be used to start Vim in a special mode, with special
  401.         mappings and settings.  A shell alias can be used to make
  402.         this easy to use.  For example:
  403.             "alias vimc vim -u ~/.c_vimrc !*".
  404.         Also consider using autocommands; see |autocommand|.
  405.         When {vimrc} is equal to "NONE" (all uppercase), all
  406.         initializations from files and environment variables are
  407.         skipped.  {not in Vi}
  408.  
  409.                             *-i*
  410. -i {viminfo}    The file "viminfo" is used instead of the default viminfo
  411.         file.  If the name "NONE" is used (all uppercase), no viminfo
  412.         file is read or written, even if 'viminfo' is set or when
  413.         ":rv" or ":wv" are used.  See also |viminfo_file|.  {not in Vi}
  414.  
  415.                             *-s*
  416. -s {scriptin}    The script file "scriptin" is read.  The characters in the
  417.         file are interpreted as if you had typed them.  The same can
  418.         be done with the command ":source! {scriptin}".  If the end
  419.         of the file is reached before the editor exits, further
  420.         characters are read from the keyboard.  See also the section
  421.         "complex repeats", |complex_repeat|.  {not in Vi}
  422.  
  423.                             *-w*
  424. -w {scriptout}    All the characters that you type are recorded in the file
  425.         "scriptout", until you exit Vim.  This is useful if you want
  426.         to create a script file to be used with "vim -s" or
  427.         ":source!".  When the "scriptout" file already exists, new
  428.         characters are appended.  See also the section "complex
  429.         repeats", |complex_repeat|.  {not in Vi}
  430.  
  431.                             *-W*
  432. -W {scriptout}    Like -w, but do not append, overwrite an existing file.  {not
  433.         in Vi}
  434.  
  435.                             *-w_nr*
  436. -w{number}    Does nothing.  This was included for Vi-compatibility.  In Vi
  437.         it sets the 'window' option, which is not implemented in Vim.
  438.  
  439. Example for using a script file to change a name in several files:
  440.     Create a file "subs.vi" containing substitute commands and a :wq
  441.     command:
  442.  
  443.         :%s/Jones/Smith/g
  444.         :%s/Allen/Peter/g
  445.         :wq
  446.  
  447.     Execute Vim on all files you want to change:
  448.  
  449.         foreach i ( *.let ) vim -s subs.vi $i
  450.  
  451. If the executable is called "view", Vim will start in Readonly mode.  This is
  452. useful if you can make a hard or symbolic link from "view" to "vim".
  453. Starting in Readonly mode can also be done with "vim -v".
  454.  
  455.  
  456. 3.2 Workbench (Amiga only)                *workbench*
  457.  
  458. Vim can be started from the workbench by clicking on its icon twice.  It will
  459. then start with an empty buffer.
  460.  
  461. Vim can be started to edit one or more files by using a "Project" icon.  The
  462. "Default Tool" of the icon must be the full pathname of the Vim executable.
  463. The name of the ".info" file must be the same as the name of the text file.
  464. By clicking on this icon twice, Vim will be started with the filename as
  465. current filename, which will be read into the buffer (if it exists).  You can
  466. edit multiple files by pressing the shift key while clicking on icons, and
  467. clicking twice on the last one.  The "Default Tool" for all these icons must
  468. be the same.
  469.  
  470. It is not possible to give arguments to Vim, other than filenames, from the
  471. workbench.
  472.  
  473.  
  474. 3.3 Vim window (Amiga only)                *amiga_window*
  475.  
  476. Vim will run in the CLI window where it was started.  If Vim was started with
  477. the "run" or "runback" command, or if Vim was started from the workbench, it
  478. will open a window of its own.
  479.  
  480. Technical detail:
  481.     To open the new window a little trick is used.  As soon as Vim
  482.     recognizes that it does not run in a normal CLI window, it will
  483.     create a script file in "t:".  This script file contains the same
  484.     command as the one Vim was started with, and an "endcli" command.  This
  485.     script file is then executed with a "newcli" command (the "c:run" and
  486.     "c:newcli" commands are required for this to work).  The script file
  487.     will hang around until reboot, or until you delete it.  This method
  488.     is required to get the ":sh" and ":!" commands to work correctly.
  489.     But when Vim was started with the -e option (Quickfix mode) or with
  490.     the -x option, this method is not used.  The reason for this is that
  491.     when a compiler starts Vim with the -e option it will wait for a
  492.     return code.  With the script trick, the compiler cannot get the
  493.     return code.  The -x option can be used when Vim is started by a mail
  494.     program which also waits for the edit session to finish.  As a
  495.     consequence, the ":sh" and ":!" commands are not available when the
  496.     -e or -x option is used.
  497.  
  498. Vim will automatically recognize the window size and react to window
  499. resizing.  Under Amiga DOS 1.3, it is advised to use the fastfonts program,
  500. "FF", to speed up display redrawing.
  501.  
  502.  
  503. 3.4 Initialization                *initialization* *startup*
  504.  
  505. This section is about the non-GUI version of Vim.  See |gui_fork| for
  506. additional initialization when starting the GUI.
  507.  
  508. At startup, Vim checks environment variables and files and sets values
  509. accordingly.  Vim proceeds in this order:
  510.  
  511. 1. Setting the 'shell' option                *SHELL* *COMSPEC*
  512.     The environment variable SHELL, if it exists, is used to set the
  513.     'shell' option.  On MS-DOS and Win32, the COMPSPEC variable is used
  514.     if SHELL is not set.
  515.  
  516. 2. Setting the 'term' option                *TERM*
  517.     The environment variable TERM, if it exists, is used to set the 'term'
  518.     option.
  519.  
  520. 3. Reading Ex commands from environment variables and/or files
  521.     An environment variable is read as one Ex command line, where multiple
  522.     commands must be separated with '|' or "<NL>".
  523.                                 *vimrc* *exrc*
  524.     A file that contains initialization commands is called a "vimrc" file.
  525.     Each line in a vimrc file is executed as an Ex command line.  It is
  526.     sometimes also referred to as "exrc" file.  They are the same type of
  527.     file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
  528.     name.
  529.  
  530.     If Vim was started with "-u filename", the file "filename" is used.
  531.     All following initializations until 4. are skipped.
  532.     "vim -u NONE" can be used to skip these initializations.  |-u|
  533.  
  534.      a. For Unix the system vimrc file is read for initializations.  The path
  535.     of this file is shown with the ":version" command.
  536.  
  537.               *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc*
  538.      b. Four places are searched for initializations.  The first that exists
  539.     is used, the others are ignored.
  540.     -  The environment variable VIMINIT
  541.     -  The user vimrc file:
  542.             "~/.vimrc"       (for Unix and OS/2)
  543.             "s:.vimrc"     (for Amiga)
  544.             "$VIM\_vimrc"  (for MS-DOS and Win32)
  545.         Note: For Unix, OS/2 and Amiga, when ".vimrc" does not exist,
  546.         "_vimrc" is also tried, in case an MS-DOS compatible file
  547.         system is used.  For MS-DOS and Win32 ".vimrc" is checked
  548.         after "_vimrc", in case long file names are used.
  549.         If $VIM is not set, $HOME is used.
  550.     -  The environment variable EXINIT
  551.     -  The user exrc file:
  552.             "~/.exrc"      (for Unix and OS/2)
  553.                 "s:.exrc"      (for Amiga)
  554.             "$VIM\_exrc"   (for MS-DOS and Win32).
  555.  
  556.      c. If the 'exrc' option is on (which is not the default), the current
  557.     directory is searched for three files.  The first that exists is used,
  558.     the others are ignored.
  559.     -  The file ".vimrc" (for Unix, Amiga and OS/2)
  560.                 "_vimrc" (for MS-DOS and Win32)
  561.     -  The file "_vimrc" (for Unix, Amiga and OS/2)
  562.                 ".vimrc" (for MS-DOS and Win32)
  563.     -  The file ".exrc"  (for Unix, Amiga and OS/2)
  564.                 "_exrc"  (for MS-DOS and Win32)
  565.  
  566. 4. Setting 'shellpipe' and 'shellredir'
  567.     The 'shellpipe' and 'shellredir' options are set according to the
  568.     value of the 'shell' option, unless they have been set before.
  569.     This means that Vim will figure out the values of 'shellpipe' and
  570.     'shellredir' for you, unless you have set them yourself.
  571.  
  572. 5. GUI initializations
  573.     Only when starting "gvim", the GUI initializations will be done.  See
  574.     |gui_init|.
  575.  
  576. 6. Read the viminfo file
  577.     If the 'viminfo' option is not empty, the viminfo file is read.  The
  578.     default is empty, so 'viminfo' must have been set by one of the
  579.     previous initializations.  See |viminfo_file|.
  580.  
  581. 7. Set binary options.
  582.     If the "-b" flag was given to Vim, the options for binary editing will
  583.     be set now.  See |-b|.
  584.  
  585. Some hints on using initializations:
  586.  
  587. Standard setup:
  588. Create a vimrc file to set the default settings and mappings for all your edit
  589. sessions.  Put it in a place so that it will be found by 3b:
  590.     ~/.vimrc    (Unix and OS/2)
  591.     s:.vimrc    (Amiga)
  592.     $VIM\_vimrc    (MS-DOS and Win32)
  593.  
  594. Local setup:
  595. Put all commands that you need for editing a specific directory only into a
  596. vimrc file and place it in that directory under the name ".vimrc" ("_vimrc"
  597. for MS-DOS and Win32).  NOTE: To make Vim look for these special files you
  598. have to turn on the option 'exrc'.  See |trojan_horse| too.
  599.  
  600. System setup:
  601. This only applies if you are managing a Unix system with several users and
  602. want to set the defaults for all users.  Create a vimrc file with commands
  603. for default settings and mappings and put it in the place that is given with
  604. the ":version" command.
  605.  
  606. Saving the current state of Vim to a file:
  607. Whenever you have changed values of options or when you have created a
  608. mapping, then you may want to save them in a vimrc file for later use.  See
  609. |save_settings| about saving the current state of settings to a file.
  610.  
  611. Avoiding setup problems for Vi users:
  612. Vi uses the variable EXINIT and the file "~/.exrc".  So if you do not want to
  613. interfere with Vi, then use the variable VIMINIT and the file "vimrc" instead.
  614.  
  615. Amiga environment variables:
  616. On the Amiga, two types of environment variables exist.  The ones set with the
  617. DOS 1.3 (or later) setenv command are recognized.  See the AmigaDos 1.3
  618. manual.  The environment variables set with the old Manx Set command (before
  619. version 5.0) are not recognized.
  620.  
  621. MS-DOS line separators:
  622. On MS-DOS-like systems (MS-DOS itself, Win32, and OS/2), Vim assumes that all
  623. the vimrc files have <CR> <NL> pairs as line separators.  This will give
  624. problems if you have a file with only <NL>s and have a line like
  625. ":map xx yy^M".  The trailing ^M will be ignored.
  626.  
  627. Avoiding trojan horses:                    *trojan_horse*
  628. While reading the "vimrc" or the "exrc" file in the current directory, some
  629. commands can be disabled for security reasons by setting the 'secure' option.
  630. This is always done when executing the command from a tags file.  Otherwise it
  631. would be possible that you accidentally use a vimrc or tags file that somebody
  632. else created and contains nasty commands.  The disabled commands are the ones
  633. that start a shell, the ones that write to a file, and ":autocmd".  The ":map"
  634. commands are echoed, so you can see which keys are being mapped.
  635.     If you want Vim to execute all commands in a local vimrc file, you
  636. can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
  637. in the global "exrc" or "vimrc" file.  This is not possible in "vimrc" or
  638. "exrc" in the current directory, for obvious reasons.
  639.     On Unix systems, this only happens if you are not the owner of the
  640. vimrc file.  Warning: If you unpack an archive that contains a vimrc or exrc
  641. file, it will be owned by you.  You won't have the security protection.  Check
  642. the vimrc file before you start Vim in that directory, or reset the 'exrc'
  643. option.  Some Unix systems allow a user to do "chown" on a file.  This makes
  644. it possible for another user to create a nasty vimrc and make you the owner.
  645. Be careful!
  646.     When using tag search commands, executing the search command (the last
  647. part of the line in the tags file) is always done in secure mode.  This works
  648. just like executing a command from a vimrc/exrc in the current directory.
  649.  
  650.                             *slow_start*
  651. If Vim takes a long time to start up, there may be a few causes:
  652. - If the Unix version was compiled with the GUI and/or X11 (check the output
  653.   of ":version" for "+GUI" and "+X11"), it may need to load shared libraries
  654.   and connect to the X11 server.  Try compiling a version with GUI and X11
  655.   disabled.  This also should make the executable smaller.
  656. - If you have "viminfo" enabled, the loading of the viminfo file may take a
  657.   while.  You can find out if this is the problem by disabling viminfo for a
  658.   moment (use the Vim argument "-i NONE", |-i|).  Try reducing the number of
  659.   lines stored in a register with ":set viminfo='20\"50".
  660.                               |viminfo_file|.
  661.  
  662.  
  663. 3.5 Suspending                        *suspend*
  664.  
  665.                             *CTRL-Z* *v_CTRL-Z*
  666. CTRL-Z            On Unix systems: Suspend Vim.  On other systems:
  667.             start a new shell (like ":sh").  Same as ":stop".
  668.             Works in Normal and in Visual mode.  In Insert and
  669.             Command-line mode, the CTRL-Z is inserted as a normal
  670.             character.
  671.  
  672.  
  673. :sus[pend][!]    or            *:sus* *:suspend* *:st* *:stop*
  674. :st[op][!]        Suspend the editor.  If the '!' is not given, the
  675.             buffer was changed, 'autowrite' is set, and a filename
  676.             is known, the buffer will be written.
  677.  
  678. On many Unix systems, it is possible to suspend Vim with CTRL-Z.  This is only
  679. possible in Normal and Visual mode (see next chapter, |vim_modes|).  Vim will
  680. continue if you make it the foreground job again.  On other systems, CTRL-Z
  681. will start a new shell.  This is the same as the ":sh" command.  Vim will
  682. continue if you exit from the shell.
  683.  
  684.  
  685. 3.6 The viminfo file                    *viminfo_file*
  686.  
  687. The viminfo file is used to store:
  688. - The command line history.
  689. - The search string history.
  690. - Contents of registers.
  691. - Marks for several files.
  692. - File marks, pointing to locations in files.
  693. - Last search/substitute pattern (for 'n' and '&').
  694.  
  695. The viminfo file is only supported when Vim has been compiled with VIMINFO
  696. defined.  If the output of ":version" contains "+viminfo" then it was; if it
  697. contains "-viminfo" then it wasn't.  By default, VIMINFO is defined in
  698. feature.h.
  699.  
  700.                             *viminfo_read*
  701. When Vim is started and the 'viminfo' option is non-empty, the contents of
  702. the viminfo file are read and the info can be used in the appropriate places.
  703. The marks are not read in at startup (but file marks are).  See
  704. |initialization| for how to set the 'viminfo' option upon startup.
  705.  
  706.                             *viminfo_write*
  707. When Vim exits and 'viminfo' is non-empty, the info is stored in the viminfo
  708. file (it's actually merged with the existing one, if one exists).  The
  709. 'viminfo' option is a string containing information about what info should be
  710. stored, and contains limits on how much should be stored (see 'viminfo').
  711.  
  712. Notes for Unix:
  713. - The file protection for the viminfo file will be set to prevent other users
  714.   from being able to read it, because it may contain any text or commands that
  715.   you have worked with.
  716. - If you want to share the viminfo file with other users (e.g. when you "su"
  717.   to another user), you can make the file writable for the group or everybody.
  718.   Vim will preserve this when writing new viminfo files.  Be careful, don't
  719.   allow just anybody to read and write your viminfo file!
  720. - Vim will not overwrite a viminfo file that is not writable by the current
  721.   "real" user.  This helps for when you did "su" to become root, but your
  722.   $HOME is still set to a normal user's home directory.  Otherwise Vim would
  723.   create a viminfo file owned by root that nobody else can read.
  724.  
  725. Marks are stored for each file separately.  When a file is read and 'viminfo'
  726. is non-empty, the marks for that file are read from the viminfo file.  NOTE:
  727. The marks are only written when exiting Vim, which is fine because marks are
  728. remembered for all the files you have opened in the current editing session,
  729. unless ":bdel" is used.  If you want to save the marks for a file that you are
  730. about to abandon with ":bdel", use ":wv".  The '[' and ']' marks are not
  731. stored, but the '"' mark is.  The '"' mark is very useful for jumping to the
  732. cursor position when the file was last exited.  No marks are saved for files
  733. that start with any string given with the "r" flag in 'viminfo'.  This can be
  734. used to avoid saving marks for files on removable media (for MS-DOS you would
  735. use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:").
  736.  
  737.                             *viminfo_file_marks*
  738. Uppercase marks ('A to 'Z) are stored when writing the viminfo file.  The
  739. numbered marks ('0 to '9) are a bit special.  When the viminfo file is written
  740. (when exiting or with the ":wviminfo" command), '0 is set to the current cursor
  741. position and file.  The old '0 is moved to '1, '1 to '2, etc.  This
  742. resembles what happens with the "1 to "9 delete registers.  If the current
  743. cursor position is already present in '0 to '9, it is moved to '0, to avoid
  744. having the same position twice.  The result is that with "'0", you can jump
  745. back to the file and line where you exited Vim.
  746.  
  747. Viminfo file name:
  748. - The default name of the viminfo file is "$HOME/.viminfo" for Unix,
  749.   "s:.viminfo" for Amiga, "$VIM\viminfo" for MS-DOS and Win32.
  750. - The 'n' flag in the 'viminfo' option can be used to specify another viminfo
  751.   filename |'viminfo'|.
  752. - The "-i" Vim argument can be used to set another file name, |-i|.  When the
  753.   file name given is "NONE" (all uppercase), no viminfo file is ever read or
  754.   written.  Also not for the commands below!
  755. - For the commands below, another file name can be given, overriding the
  756.   default and the name given with 'viminfo' or "-i" (unless it's NONE).
  757.  
  758. Two commands can be used to read and write the viminfo file manually.  This
  759. can be used to exchange registers between two running Vim programs: First
  760. type ":wv" in one and then ":rv" in the other.  Note that if the register
  761. already contained something, then ":rv!" would be required.  Also note
  762. however that this means everything will be overwritten with information from
  763. the first Vim, including the command line history, etc.
  764.  
  765. The viminfo file itself can be edited by hand too, although we suggest you
  766. start with an existing one to get the format right.  It is reasonably
  767. self-explanatory once you're in there.  This can be useful in order to
  768. create a second file, say "~/.my_viminfo" which could contain certain
  769. settings that you always want when you first start Vim.  For example, you
  770. can preload registers with particular data, or put certain commands in the
  771. command line history.  A line in your .vimrc file like
  772.     rviminfo! ~/.my_viminfo
  773. can be used to load this information.  You could even have different viminfos
  774. for different types of files (e.g., C code) and load them based on the file
  775. name, using the ":autocmd" command (see |:autocmd|).
  776.  
  777.                             *viminfo_errors*
  778. When Vim detects an error while reading a viminfo file, it will not overwrite
  779. that file.  If there are more than 10 errors, Vim stops reading the viminfo
  780. file.  This was done to avoid accidently destroying a file when the filename
  781. of the viminfo file is wrong.  This could happen when accidently typing "vim
  782. -i file" when you wanted "vim -v file" (yes, somebody accidently did that!).
  783. If you want to overwrite a viminfo file with an error in it, you will either
  784. have to fix the error, or delete the file (while Vim is running, so most of
  785. the information will be restored).
  786.  
  787.                            *:rv* *:rviminfo*
  788. :rv[iminfo][!] [file]    Read from viminfo file [file] (default: see above).
  789.             If [!] is given, then any information that is
  790.             already set (registers, marks, etc.) will be
  791.             overwritten.  {not in Vi}
  792.  
  793.                            *:wv* *:wviminfo*
  794. :wv[iminfo][!] [file]    Write to viminfo file [file] (default: see above).
  795.             The information in the file is first read in to make
  796.             a merge between old and new info.  When [!] is used,
  797.             the old information is not read first, only the
  798.             internal info is written.  If 'viminfo' is empty, marks
  799.             for up to 100 files will be written.  {not in Vi}
  800.  
  801.  
  802. 4. Modes                        *vim_modes*
  803. ========
  804.  
  805. 4.1 Introduction
  806.  
  807. Vim has four BASIC modes:
  808.  
  809. Normal mode        In Normal mode you can enter all the editor
  810.             commands.  If you start the editor you are in this
  811.             mode (unless you have set the 'insertmode' option,
  812.             see below).  This is also known as command mode.
  813.  
  814. Visual mode        This is like Normal mode, but the movement commands
  815.             extend a highlighted area.  When a non-movement
  816.             command is used, it is executed for the highlighted
  817.             area.  See |Visual_mode|.
  818.  
  819. Insert mode        In Insert mode the text you type is inserted into the
  820.             buffer.  If the 'showmode' option is on (which is
  821.             default), the string "-- INSERT --" is shown at the
  822.             bottom of the window.  |mode_ins_repl|
  823.  
  824. Command-line mode    In Command-line mode you can enter one line of text
  825.             at the bottom of the window.  This is for the Ex
  826.             commands, ":", the pattern search commands, "?" and
  827.             "/", and the filter command, "!".  |mode_cmdline|
  828.  
  829. There are two ADDITIONAL modes:
  830.  
  831. Replace mode        Replace mode is a special case of Insert mode.  You
  832.             can do the same things as in Insert mode, but for
  833.             each character you enter, one character of the existing
  834.             text is deleted.  If the 'showmode' option is on,
  835.             (which is the default), the string "-- REPLACE --" is
  836.             shown at the bottom of the window.  |replace_mode|
  837.  
  838. Insert command mode    Entered when CTRL-O given in Insert mode.  This is
  839.             like Normal mode, but after executing one command Vim
  840.             returns to Insert mode.  The string "-- (insert) --"
  841.             is shown at the bottom of the window.
  842.  
  843. 4.2 Switching from mode to mode                *mode_switching*
  844.  
  845. If for any reason you do not know which mode you are in, you can always get
  846. back to Normal mode by typing <Esc> twice.  You will know you are back in
  847. Normal mode when you see the screen flash or hear the bell after you type
  848. <Esc>.
  849.  
  850. - go from Normal mode to Visual mode by giving one of the commands "vV^V"
  851. - go from Normal mode to Insert mode by giving one of the commands
  852.   "iIaAoOcCsS".
  853. - go from Normal mode to Replace mode with the "R" command (not the "r"
  854.   command!).
  855. - go from Normal mode to Command-line mode with the one of the commands
  856.   ":/?!".
  857.  
  858.                             *i_esc*
  859. - go from Insert or Replace mode to Normal mode with <Esc> (twice in some
  860.   rare cases).
  861. - go from Visual mode to Normal mode by giving a non-movement command, which
  862.   causes the command to be executed, or by hitting <Esc> or 'v', which does
  863.   nothing.
  864. - go from Command-line mode to Normal mode by:
  865.    - hitting <CR> or <NL>, which causes the entered command to be executed
  866.    - deleting the complete line (e.g., with CTRL-U) and giving a final <BS>
  867.    - hitting CTRL-C or <Esc>, which quits the command line without executing
  868.      the command.
  869.   In the last case <Esc> may be the character defined with the 'wildchar'
  870.   option, in which case it will start command line completion.  You can ignore
  871.   that and type <Esc> again.  {Vi: when hitting <Esc> the command line is
  872.   executed.  This is unexpected for most people; therefore it was changed in
  873.   Vim.  But when the <Esc> is part of a mapping, the command line is executed.
  874.   If you want the Vi behaviour also when typing <Esc>, use ":cmap ^V<Esc>
  875.   ^V^M"}
  876.  
  877. - go from Insert mode to Replace mode by hitting <Insert>.
  878. - go from Replace mode to Insert mode by hitting <Insert>.
  879. - go from Visual mode to Command-line mode by hitting ':'.  The line numbers
  880.   of the highlighted area will be inserted in the command line.
  881.  
  882. If the 'insertmode' option is on, editing a file will start in Insert mode.
  883.  
  884.  
  885. 4.3 Insert and Replace mode                *mode_ins_repl*
  886.  
  887. If you are working in a special language mode when inserting text, see the
  888. 'langmap' option, |'langmap'|, on how to avoid switching this mode on and off
  889. all the time.
  890.  
  891. 4.3.1 special keys                    *ins_special_keys*
  892.  
  893. In Insert and Replace mode, the following characters have a special meaning;
  894. other characters are inserted directly.  To insert one of these special
  895. characters into the buffer, precede it with CTRL-V.  To insert a <Nul>
  896. character use "CTRL-V CTRL-@" or "CTRL-V 000".  On some systems, you have to
  897. use "CTRL-V 003" to insert a CTRL-C.
  898.  
  899. char        action
  900. -----------------------------------------------------------------------
  901.                         *i_CTRL-[* *i_<Esc>*
  902. <Esc> or CTRL-[    End insert or Replace mode, go back to Normal mode.  Finish
  903.         abbreviation.
  904.                         *i_CTRL-C*
  905. CTRL-C        Quit insert mode, go back to Normal mode.  Do not check for
  906.         abbreviations.
  907.  
  908.                         *i_CTRL-@*
  909. CTRL-@        Insert previously inserted text and stop insert.  {Vi: only
  910.         when typed as first char, only up to 128 chars}
  911.                         *i_CTRL-A*
  912. CTRL-A        Insert previously inserted text.  {not in Vi}
  913.  
  914.                         *i_CTRL-H* *i_<BS>*
  915. <BS> or CTRL-H    Delete the character before the cursor (see below).
  916.         See |:fixdel| if your <BS> does not do what you want.
  917.         {Vi: does not delete autoindents}
  918.                         *i_<Del>*
  919. <Del>        Delete the character under the cursor.  If the cursor is at
  920.         the end of the line, and the 'backspace' option is non-zero,
  921.         delete the newline; the next line is appended after the
  922.         current one.  See |:fixdel| if your <Del> key does not do what
  923.         you want.  {not in Vi}
  924.                         *i_CTRL-W*
  925. CTRL-W        Delete the word before the cursor (see below).  See the
  926.         section "word motions", |word_motions|, for the definition of
  927.         a word.
  928.                         *i_CTRL-U*
  929. CTRL-U        Delete all entered characters in the current line (see
  930.         below).
  931.  
  932.                         *i_CTRL-I* *i_<Tab>*
  933. <Tab> or CTRL-I Insert a tab.  If the 'expandtab' option is on, the
  934.         equivalent number of spaces is inserted (use CTRL-V <Tab> to
  935.         avoid the expansion).  See also the 'smarttab' option and
  936.         section 4.3.4, |ins_expandtab|.
  937.                         *i_CTRL-J* *i_<NL>*
  938. <NL> or CTRL-J    Begin new line.
  939.                         *i_CTRL-M* *i_<CR>*
  940. <CR> or CTRL-M    Begin new line.
  941.                         *i_CTRL-K*
  942. CTRL-K {char1} {char2}
  943.         Enter digraph (see 4.7, |digraphs|).  When {char1} is a special
  944.         key, the code for that key is inserted.  Neither char is
  945.         considered for mapping.  {not in Vi}
  946.  
  947. CTRL-N        Find next keyword (see 4.3.6, |i_CTRL-N|).  {not in Vi}
  948. CTRL-P        Find previous keyword (see 4.3.6, |i_CTRL-P|).  {not in Vi}
  949.  
  950. CTRL-R <0-9a-z"%:.->                *i_CTRL-R*
  951.         Insert the contents of register.  Between typing CTRL-R and
  952.         the second character '"' will be displayed to indicate that
  953.         you are expected to enter the name of a register.
  954.         The text is inserted as if you typed it, but mappings and
  955.         abbreviations are not used.  If you have options like
  956.         'textwidth', 'formatoptions', or 'autoindent' set, this will
  957.         influence what will be inserted.  This is different from what
  958.         happens with the "p" command and pasting with the mouse.
  959.         Special registers:
  960.             '"'    the unnamed register, containing the text of
  961.                 the last delete or yank
  962.             '%'    the current file name
  963.             ':'    the last command line
  964.             '.'    the last inserted text
  965.             '-'    the last small (less than a line) delete
  966.         See |registers| about registers.  {not in Vi}
  967.  
  968.                         *i_CTRL-T*
  969. CTRL-T        Insert one shiftwidth of indent at the start of the current
  970.         line.  The indent is always rounded to a 'shiftwidth' (this is
  971.         vi compatible).  {Vi: only when in indent}
  972.                         *i_CTRL-D*
  973. CTRL-D        Delete one shiftwidth of indent at the start of the current
  974.         line.  The indent is always rounded to a 'shiftwidth' (this is
  975.         vi compatible).  {Vi: CTRL-D works only when used after
  976.         autoindent}
  977.                         *i_0_CTRL-D*
  978. 0 CTRL-D    Delete all indent in the current line.  {Vi: CTRL-D works
  979.         only when used after autoindent}
  980.                         *i_^_CTRL-D*
  981. ^ CTRL-D    Delete all indent in the current line.  The indent is
  982.         restored in the next line.  This is useful when inserting a
  983.         label.  {Vi: CTRL-D works only when used after autoindent}
  984.  
  985.                         *i_CTRL-V*
  986. CTRL-V        Insert next non-digit literally.  For special keys, the
  987.         terminal code is inserted.  Up to three digits form the
  988.         decimal value of a single byte (see below |i_CTRL-V_digit|.
  989.         The non-digit and the three digits are not considered for
  990.         mapping.  {Vi: no decimal byte entry}
  991.  
  992.                         *i_CTRL-Q*
  993. CTRL-Q        Same as CTRL-V.
  994.  
  995. CTRL-X        Enter CTRL-X mode.  This is a sub-mode where commands can
  996.         be given to complete words or scroll the window. See below,
  997.         |i_CTRL-X|, and in 4.3.6, |ins_completion|. {not in Vi}
  998.  
  999.                         *i_CTRL-E*
  1000. CTRL-E        Insert the character which is below the cursor.  {not in Vi}
  1001.                         *i_CTRL-Y*
  1002. CTRL-Y        Insert the character which is above the cursor.  {not in Vi}
  1003.  
  1004.                         *i_CTRL-B*
  1005. CTRL-B        Toggle the 'revins' option (B for Backwards).  Only if
  1006.         compiled with RIGHTLEFT (which is not the default).  See
  1007.         |ins_reverse|.  {not in Vi}
  1008.                         *i_CTRL-_*
  1009. CTRL-_        This key is only available if Vim was compiled with RIGHTLEFT.
  1010.         Its purpose is to switch between languages while in insert
  1011.         mode, as follows:
  1012.         -  When in a rightleft window, revins and nohkmap are toggled,
  1013.            since English will likely be inserted in this case.
  1014.         -  When in a norightleft window, revins and hkmap are toggled,
  1015.            since Hebrew will likely be inserted in this case.
  1016.  
  1017.         CTRL-_ moves the cursor to the end of the typed text, unlike
  1018.         CTRL-B which leaves the cursor in the same place.
  1019.  
  1020.         Please refer to |vim_rlh.txt| for more information about
  1021.         right-to-left mode.  {not in Vi}
  1022.  
  1023.                         *i_<Insert>*
  1024. <Insert>    Toggle between insert and replace mode.  {not in Vi}
  1025. -----------------------------------------------------------------------
  1026.  
  1027. The effect of the <BS>, CTRL-W, and CTRL-U depend on the 'backspace' option
  1028. (unless 'revins' is set):
  1029.  
  1030. backspace    action
  1031.  option
  1032.    0       delete stops in column 1 and start position of insert
  1033.    1       delete stops at start position of insert
  1034.    2       delete always; CTRL-W and CTRL-U stop once at start position of
  1035.        insert
  1036.  
  1037. If the 'backspace' option is non-zero and the cursor is in column 1 when one
  1038. of the three keys is used, the current line is joined with the previous
  1039. line.  This effectively deletes the newline in front of the cursor.  {Vi: does
  1040. not cross lines, does not delete past start position of insert}
  1041.  
  1042.                         *i_CTRL-V_digit*
  1043. With CTRL-V followed by one, two, or three digits, you can enter the decimal
  1044. value of any byte, except 10.  Normally CTRL-V is followed by three digits.
  1045. The formed byte is inserted as soon as you type the third digit.  If you type
  1046. only one or two digits and then a non-digit, the decimal value of those one
  1047. or two digits form the byte.  After that the non-digit is dealt with in the
  1048. normal way.  If you enter a value of 10, it will end up in the file as a 0.
  1049. The 10 is a <NL>, which is used internally to represent the <Nul> character.
  1050. When writing the buffer to a file, the <NL> character is translated into
  1051. <Nul>.  The <NL> character is written at the end of each line.  Thus if you
  1052. want to insert a <NL> character in a file you will have to make a line
  1053. break.  The maximum value that can be entered is 255.
  1054.  
  1055.                         *i_CTRL-X* *insert_expand*
  1056. CTRL-X enters a sub-mode where several commands can be used.  Most of these
  1057. commands do keyword completion; see 4.3.6, |ins_completion|.  These are only
  1058. available when Vim was compiled with INSERT_EXPAND defined.  If ":version"
  1059. shows "+insert_expand" then it was; if it shows "-insert_expand" then these
  1060. commands are not available.  Two commands can be used to scroll the window up
  1061. or down, without exiting insert mode:
  1062.  
  1063.                         *i_CTRL-X_CTRL-E*
  1064. CTRL-X CTRL-E        scroll window one line up.
  1065.  
  1066.                         *i_CTRL-X_CTRL-Y*
  1067. CTRL-X CTRL-Y        scroll window one line down.
  1068.  
  1069. After CTRL-X is pressed, each CTRL-E (CTRL-Y) scrolls the window up (down) by
  1070. one line unless that would cause the cursor to move from its current position
  1071. in the file.  As soon as another key is pressed, CTRL-X mode is exited and
  1072. that key is interpreted as in Insert mode.
  1073.  
  1074.  
  1075. 4.3.2 special special keys                *ins_special_special*
  1076.  
  1077. The following keys are special.  They stop the current insert, do something,
  1078. and then restart insertion.  This means you can do something without getting
  1079. out of Insert mode.  This is very handy if you prefer to use the Insert mode
  1080. all the time, just like editors that don't have a separate Normal mode.  You
  1081. may also want to set the 'backspace' option to 2 and set the 'insertmode'
  1082. option.  You can use CTRL-O if you want to map a function key to a command.
  1083.  
  1084. The changes (inserted or deleted characters) before and after these keys can
  1085. be undone separately.  Only the last change can be redone and always behaves
  1086. like an "i" command.
  1087.  
  1088. char        action
  1089. -----------------------------------------------------------------------
  1090. <Up>        cursor one line up                 *i_<Up>*
  1091. <Down>        cursor one line down                 *i_<Down>*
  1092. <Left>        cursor one character left             *i_<Left>*
  1093. <Right>        cursor one character right             *i_<Right>*
  1094. <S-Left>    cursor one word back (like "b" command)         *i_<S-Left>*
  1095. <S-Right>    cursor one word forward (like "w" command)   *i_<S-Right>*
  1096. <Home>        cursor to first char in the line         *i_<Home>*
  1097. <End>        cursor to after last char in the line         *i_<End>*
  1098. <C-Home>    cursor to first char in the file         *i_<C-Home>*
  1099. <C-End>        cursor to after last char in the file         *i_<C-End>*
  1100. <LeftMouse>    cursor to position of mouse click         *i_<LeftMouse>*
  1101. <S-Up>        move window one page up                 *i_<S-Up>*
  1102. <PageUp>    move window one page up                 *i_<PageUp>*
  1103. <S-Down>    move window one page down             *i_<S-Down>*
  1104. <PageDown>    move window one page down             *i_<PageDown>*
  1105. CTRL-O        execute one command, return to Insert mode   *i_CTRL-O*
  1106. -----------------------------------------------------------------------
  1107.  
  1108. The CTRL-O command sometimes has one side effect: If the cursor was beyond the
  1109. end of the line, it will be put on the last character in the line.
  1110. The shifted cursor keys are not available on all terminals.
  1111.  
  1112. When the 'whichwrap' option is set appropriately, the <Left> and <Right>
  1113. keys on the first/last character in the line make the cursor wrap to the
  1114. previous/next line.
  1115.  
  1116.  
  1117. 4.3.3 'textwidth' and 'wrapmargin' options        *ins_textwidth*
  1118.  
  1119. The 'textwidth' option can be used to automatically break a line before it
  1120. gets too long.  Set the 'textwidth' option to the desired maximum line
  1121. length.  If you then type more characters (not spaces or tabs), the
  1122. last word will be put on a new line (unless it is the only word on the
  1123. line).  If you set 'textwidth' to 0, this feature is disabled.
  1124.  
  1125. The 'wrapmargin' option does almost the same.  The difference is that
  1126. 'textwidth' has a fixed width while 'wrapmargin' depends on the width of the
  1127. screen.  When using 'wrapmargin' this is equal to using 'textwidth' with a
  1128. value equal to (columns - 'wrapmargin'), where columns is the width of the
  1129. screen.
  1130.  
  1131. When 'textwidth' and 'wrapmargin' are both set, 'textwidth' is used.
  1132.  
  1133. The line is only broken automatically when using insert mode, or when
  1134. appending to a line.  When in replace mode and the line length is not
  1135. changed, the line will not be broken.
  1136.  
  1137. Long lines are broken if you enter a non-white character after the margin.
  1138. The situations where a line will be broken can be restricted by adding
  1139. characters to the 'formatoptions' option:
  1140. "l"  Only break a line if it was not longer than 'textwidth' when the insert
  1141.      started.
  1142. "v"  Only break at a white character that has been entered during the
  1143.      current insert command.  This is mostly Vi-compatible.
  1144. "lv" Only break if the line was not longer than 'textwidth' when the insert
  1145.      started and only at a white character that has been entered during the
  1146.      current insert command.  Only differs from "l" when entering non-white
  1147.      characters while crossing the 'textwidth' boundary.
  1148.  
  1149. If you want to format a block of text, you can use the "gq" operator.  Type
  1150. "gq" and a movement command to move the cursor to the end of the block.  In
  1151. many cases, the command "gq}" will do what you want (format until the end of
  1152. paragraph).  Alternatively, you can use "gqp", which will format the whole
  1153. paragraph, no matter where the cursor currently is.  Or you can use Visual
  1154. mode: hit "v", move to the end of the block, and hit "gq".  See also |gq|.
  1155.  
  1156.  
  1157. 4.3.4 'expandtab' and 'smarttab' options        *ins_expandtab*
  1158.  
  1159. If the 'expandtab' option is on, spaces will be used to fill the amount of
  1160. whitespace of the tab.  If you want to enter a real <Tab>, type CTRL-V first.
  1161. The 'expandtab' option is off by default.  Note that in Replace mode, a single
  1162. character is replaced with several spaces.  The result of this is that the
  1163. number of characters in the line increases.  Backspacing will delete one
  1164. space at a time.  The original character will be put back for only one space
  1165. that you backspace over (the last one).  {Vi does not have the 'expandtab'
  1166. option}
  1167.  
  1168.                             *ins_smarttab*
  1169. When the 'smarttab' option is on, a <Tab> inserts 'shiftwidth' positions at
  1170. the beginning of a line and 'tabstop' positions in other places.  This means
  1171. that often spaces instead of a <Tab> character are inserted.  When 'smarttab
  1172. is off, a <Tab> always inserts 'tabstop' positions, and 'shiftwidth' is only
  1173. used for ">>" and the like.  {not in Vi}
  1174.  
  1175.  
  1176. 4.3.5 Replace mode                    *replace_mode*
  1177.  
  1178. In Replace mode, one character in the line is deleted for every character you
  1179. type.  If there is no character to delete (at the end of the line), the
  1180. typed character is appended (as in Insert mode).  Thus the number of
  1181. characters in a line stays the same until you get to the end of the line.
  1182. If a <NL> is typed, a line break is inserted and no character is deleted.
  1183.  
  1184. Be careful with <Tab> characters.  If you type a normal printing character in
  1185. its place, the number of characters is still the same, but the number of
  1186. columns will become smaller.
  1187.  
  1188. If you delete characters in Replace mode (with <BS>, CTRL-W, or CTRL-U), what
  1189. happens is that you delete the changes.  The characters that were replaced
  1190. are restored.  If you had typed past the existing text, the characters you
  1191. added are deleted.  This is effectively a character-at-a-time undo.
  1192.  
  1193. If the 'expandtab' option is on, a <Tab> will replace one character with
  1194. several spaces.  The result of this is that the number of characters in the
  1195. line increases.  Backspacing will delete one space at a time.  The original
  1196. character will be put back for only one space that you backspace over (the
  1197. last one).  {Vi does not have the 'expandtab' option}
  1198.  
  1199.  
  1200. 4.3.6 Insert mode completion                *ins_completion*
  1201.  
  1202. In Insert and Replace modes, there are several commands to complete part of a
  1203. keyword or line that has been typed.  This is useful if you are using
  1204. complicated keywords (e.g., function names with capitals and underscores).
  1205. Completion can be done for:
  1206.  
  1207. 1. Whole lines                        |i_CTRL-X_CTRL-L|
  1208. 2. keywords in the current file                |i_CTRL-N|
  1209. 3. keywords in 'dictionary'                |i_CTRL-X_CTRL-K|
  1210. 4. keywords in the current and included files        |i_CTRL-X_CTRL-I|
  1211. 5. tags                            |i_CTRL-X_CTRL-]|
  1212. 6. file names                        |i_CTRL-X_CTRL-F|
  1213. 7. definitions or macros                |i_CTRL-X_CTRL-D|
  1214.  
  1215. All these (except 2) are done in CTRL-X mode.  This is a sub-mode of Insert
  1216. and Replace modes.  You enter CTRL-X mode by typing CTRL-X and one of the
  1217. CTRL-X commands.  You exit CTRL-X mode by typing a key that is not a valid
  1218. CTRL-X mode command.  Valid keys are the CTRL-X command itself, CTRL-N (next),
  1219. and CTRL-P (previous).
  1220.  
  1221. Also see the 'infercase' option if you want to adjust the case of the match.
  1222.  
  1223. Note: The keys that are valid in CTRL-X mode are not mapped.  This allows for
  1224. ":map ^F ^X^F" to work (where ^F is CTRL-F and ^X is CTRL-X).  The key that
  1225. ends CTRL-X mode (any key that is not a valid CTRL-X mode command) is mapped.
  1226.  
  1227. The following mappings are suggested to make typing the completion commands
  1228. a bit easier (although they will hide other commands):
  1229.     :inoremap ^] ^X^]
  1230.     :inoremap ^F ^X^F
  1231.     :inoremap ^D ^X^D
  1232.     :inoremap ^L ^X^L
  1233.  
  1234.  
  1235. Completing whole lines                    *compl_whole_line*
  1236.  
  1237.                             *i_CTRL-X_CTRL-L*
  1238. CTRL-X CTRL-L        Search backwards for a line that starts with the
  1239.             same characters as in the current line before the
  1240.             cursor.  Indent is ignored.  The found line is
  1241.             inserted in front of the cursor.
  1242.     CTRL-L    or
  1243.     CTRL-P        Search backwards for next matching line.  This line
  1244.             replaces the previous matching line.
  1245.  
  1246.     CTRL-N        Search forward for next matching line.  This line
  1247.             replaces the previous matching line.
  1248.  
  1249. Completing keywords in current file            *compl_current*
  1250.  
  1251.                             *i_CTRL-P*
  1252.                             *i_CTRL-N*
  1253. The keys CTRL-N and CTRL-P can be used to complete the keyword that is in
  1254. front of the cursor.  This is useful if you are writing a program that has
  1255. complicated variable names, and you want to copy a name from the text before
  1256. or after the cursor.
  1257.  
  1258. If there is a keyword in front of the cursor (a name made out of alphabetic
  1259. characters and characters in 'iskeyword'), it is used as the search pattern,
  1260. with "\<" prepended (meaning: start of a word).  Otherwise "\<\k\k" is used
  1261. as search pattern (start of any keyword of at least two characters).
  1262.  
  1263. With CTRL-N (next), the search goes forward; with CTRL-P (previous), the
  1264. search goes backward.  The first time the search starts where the cursor is.
  1265. Subsequently, the search starts at the last found position.  If you type any
  1266. other character than CTRL-P or CTRL-N, the current text is accepted and the
  1267. search pattern is forgotten.
  1268.  
  1269. If the search found a match, it is inserted at the cursor position.  Any
  1270. previous match is replaced.  If no match was found, Vim will beep.
  1271.  
  1272. In Replace mode, the number of characters that are replaced depends on the
  1273. length of the matched string.  This works like typing the characters of the
  1274. matched string in Replace mode.
  1275.  
  1276. If there is not a valid keyword character before the cursor, any keyword of
  1277. at least two characters is matched.
  1278.     e.g., to get:
  1279.         printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);
  1280.     just type:
  1281.         printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);
  1282.  
  1283. Multiple repeats of the same completion are skipped; thus a different match
  1284. will be inserted at each CTRL-N and CTRL-P (unless there is only one
  1285. matching keyword).
  1286.  
  1287. If there is only one completion found, then a second CTRL-P or CTRL-N will
  1288. give the message 'No other matches'.
  1289.  
  1290. If the only match in the file is an exact match, where no extra characters
  1291. would be typed, then the message 'Exact match only' is given (this is also
  1292. useful for checking that you typed the word correctly).
  1293.  
  1294. The mode "-- INSERT --" is shown, unless there is another more important
  1295. message (e.g., "Pattern not found").  This other message will stay until
  1296. another key is hit, and then the mode is shown again.
  1297.  
  1298. Single character matches are never included, as they usually just get in
  1299. the way of what you were really after.
  1300.     e.g., to get:
  1301.         printf("name = %s\n", name);
  1302.     just type:
  1303.         printf("name = %s\n", n^P);
  1304.     or even:
  1305.         printf("name = %s\n", ^P);
  1306. The 'n' in '\n' is skipped.
  1307.  
  1308.  
  1309. Completing keywords in 'dictionary'            *compl_dictionary*
  1310.  
  1311.                             *i_CTRL-X_CTRL-K*
  1312. CTRL-X CTRL-K        Search the files given with the 'dictionary' option
  1313.             for words that start with the keyword in front of the
  1314.             cursor.  This is like CTRL-N, but only the dictionary
  1315.             files are searched, not the current file.  The found
  1316.             keyword is inserted in front of the cursor.  This
  1317.             could potentially be pretty slow, since all matches
  1318.             are found before the first match is used.  By default,
  1319.             the 'dictionary' option is empty.
  1320.  
  1321.     CTRL-K    or
  1322.     CTRL-N        Search forward for next matching keyword.  This
  1323.             keyword replaces the previous matching keyword.
  1324.  
  1325.     CTRL-P        Search backwards for next matching keyword.  This
  1326.             keyword replaces the previous matching keyword.
  1327.  
  1328.  
  1329. Completing keywords in the current and included files    *compl_keyword*
  1330.  
  1331. The 'include' option is used to specify a line that contains an include file
  1332. name.  The 'path' option is used to search for include files.
  1333.  
  1334.                             *i_CTRL-X_CTRL-I*
  1335. CTRL-X CTRL-I        Search for the first keyword in the current and
  1336.             included files that starts with the same characters
  1337.             as those before the cursor.  The matched keyword is
  1338.             inserted in front of the cursor.
  1339.  
  1340.     CTRL-N        Search forwards for next matching keyword.  This
  1341.             keyword replaces the previous matching keyword.
  1342.             Note: CTRL-I is the same as <Tab>, which is likely to
  1343.             be typed after a succesful completion, therefore
  1344.             CTRL-I is not used for searching for the next match.
  1345.  
  1346.     CTRL-P        Search backward for previous matching keyword.  This
  1347.             keyword replaces the previous matching keyword.
  1348.  
  1349.  
  1350. Completing tags                        *compl_tag*
  1351.                             *i_CTRL-X_CTRL-]*
  1352. CTRL-X CTRL-]        Search for the first tag that starts with the same
  1353.             characters as before the cursor.  The matching tag is
  1354.             inserted in front of the cursor.  Alphabetic
  1355.             characters and characters in 'iskeyword' are used
  1356.             to decide which characters are included in the tag
  1357.             name (same as for a keyword).  See also |CTRL-]|.
  1358.     CTRL-]    or
  1359.     CTRL-N        Search forwards for next matching tag.  This tag
  1360.             replaces the previous matching tag.
  1361.  
  1362.     CTRL-P        Search backward for previous matching tag.  This tag
  1363.             replaces the previous matching tag.
  1364.  
  1365.  
  1366. Completing file names                    *compl_filename*
  1367.                             *i_CTRL-X_CTRL-F*
  1368. CTRL-X CTRL-F        Search for the first file name that starts with the
  1369.             same characters as before the cursor.  The matching
  1370.             file name is inserted in front of the cursor.
  1371.             Alphabetic characters and characters in 'isfname'
  1372.             are used to decide which characters are included in
  1373.             the file name.  Note: the 'path' option is not used
  1374.             here (yet).
  1375.     CTRL-F    or
  1376.     CTRL-N        Search forwards for next matching file name.  This
  1377.             file name replaces the previous matching file name.
  1378.  
  1379.     CTRL-P        Search backward for previous matching file name.
  1380.             This file name replaces the previous matching file
  1381.             name.
  1382.  
  1383.  
  1384. Completing definitions or macros            *compl_define*
  1385.  
  1386. The 'define' option is used to specify a line that contains a definition.
  1387. The 'include' option is used to specify a line that contains an include file
  1388. name.  The 'path' option is used to search for include files.
  1389.  
  1390.                             *i_CTRL-X_CTRL-D*
  1391. CTRL-X CTRL-D        Search in the current and included files for the
  1392.             first definition (or macro) name that starts with
  1393.             the same characters as before the cursor.  The found
  1394.             definition name is inserted in front of the cursor.
  1395.     CTRL-D    or
  1396.     CTRL-N        Search forwards for next matching macro name.  This
  1397.             macro name replaces the previous matching macro
  1398.             name.
  1399.  
  1400.     CTRL-P        Search backward for previous matching macro name.
  1401.             This macro name replaces the previous matching macro
  1402.             name.
  1403.  
  1404.  
  1405. 4.4 Command-line mode                    *mode_cmdline* *:*
  1406.  
  1407. Command-line mode is used to enter Ex commands (":"), search patterns
  1408. ("/" and "?"), and filter commands ("!").
  1409.  
  1410.  
  1411. 4.4.1 Command line editing                *cmdline_editing*
  1412.  
  1413. Normally characters are inserted in front of the cursor position.  You can
  1414. move around in the command line with the left and right cursor keys.  With the
  1415. <Insert> key, you can toggle between inserting and overstriking characters.
  1416. {Vi: can only alter the last character in the line}
  1417.  
  1418. Note that if your keyboard does not have working cursor keys or any of the
  1419. other special keys, you can use ":cnoremap" to define another key for them.
  1420. For example, to define tcsh style editing keys:        *tcsh-style*
  1421.     :cnoremap <C-A> <Home>
  1422.     :cnoremap <C-F> <Right>
  1423.     :cnoremap <C-B> <Left>
  1424.     :cnoremap <Esc>b <S-Left>
  1425.     :cnoremap <Esc>f <S-Right>
  1426. (<> notation |<>|; type all this literally)
  1427.  
  1428.                             *cmdline_history*
  1429. The command lines that you enter are remembered in a history table.  You can
  1430. recall them with the up and down cursor keys.  There are actually two history
  1431. tables: one for ':' commands, one for search strings.  These are completely
  1432. separate.  The search strings history can be accessed only when entering a
  1433. search string, the ':' history only when entering a command line for the ":"
  1434. command.  Use the 'history' option to set the number of lines that are
  1435. remembered (default: 20).  Note that when you enter a command line that is
  1436. excactly the same as an older one, the old one is removed (to avoid repeated
  1437. commands moving older commands out of the history).  Only commands that are
  1438. typed are remembered.  Ones that come from mappings are not put in the history
  1439. (detail: the decision is made from the last key that was typed for the line,
  1440. normally <CR>).  All searches are put in the search history, including the ones
  1441. that come from commands like "*" and "#".  {Vi: no history}
  1442.  
  1443. There is an automatic completion of names on the command line; see 4.4.2,
  1444. |cmdline_completion|.
  1445.  
  1446.                             *c_CTRL-V*
  1447. CTRL-V        Insert next non-digit literally.  Up to three digits form the
  1448.         decimal value of a single byte.  The non-digit and the three
  1449.         digits are not considered for mapping.  This works the same
  1450.         way as in Insert mode (see above, |i_CTRL-V|).
  1451.                             *c_CTRL-Q*
  1452. CTRL-Q        Same as CTRL-V.
  1453.  
  1454.                             *c_<Left>*
  1455. <Left>        cursor left
  1456.                             *c_<Right>*
  1457. <Right>        cursor right
  1458.                             *c_<S-Left>*
  1459. <S-Left>    cursor one WORD left
  1460.                             *c_<S-Right>*
  1461. <S-Right>    cursor one WORD right
  1462. CTRL-B or <Home>                    *c_CTRL-B* *c_<Home>*
  1463.         cursor to beginning of command line
  1464. CTRL-E or <End>                        *c_CTRL-E* *c_<End>*
  1465.         cursor to end of command line
  1466.  
  1467.                             *c_<LeftMouse>*
  1468. <LeftMouse>    cursor to position of mouse click.
  1469.  
  1470. CTRL-H                            *c_<BS>* *c_CTRL-H*
  1471. <BS>        delete the character in front of the cursor (see |:fixdel| if
  1472.         your <BS> key does not do what you want).
  1473.                             *c_<Del>*
  1474. <Del>        delete the character under the cursor (at end of line:
  1475.         character before the cursor) (see |:fixdel| if your <Del>
  1476.         key does not do what you want).
  1477.                             *c_CTRL-W*
  1478. CTRL-W        delete the word before the cursor
  1479.                             *c_CTRL-U*
  1480. CTRL-U        remove all characters
  1481.  
  1482.         Note: if the command line becomes empty with one of the
  1483.         delete commands, Command-line mode is quit.
  1484.                             *c_<Insert>*
  1485. <Insert>    Toggle between insert and overstrike.  {not in Vi}
  1486.  
  1487. {char1} <BS> {char2}    or                *c_digraph*
  1488. CTRL-K {char1} {char2}                    *c_CTRL-K*
  1489.         enter digraph (see 4.7, |digraphs|).  When {char1} is a special
  1490.         key, the code for that key is inserted.  {not in Vi}
  1491.  
  1492. CTRL-R <0-9a-z"%:->                    *c_CTRL-R*
  1493.         Insert the contents of a numbered or named register.  Between
  1494.         typing CTRL-R and the second character '"' will be displayed
  1495.         to indicate that you are expected to enter the name of a
  1496.         register.  The text is inserted as if you typed it, but
  1497.         mappings and abbreviations are not used.  Special registers:
  1498.             '"'    the unnamed register, containing the text of
  1499.                 the last delete or yank
  1500.             '%'    the current file name
  1501.             ':'    the last command line
  1502.             '-'    the last small (less than a line) delete
  1503.         Note: The '.' register (last inserted text) is not available
  1504.         here.  See |registers| about registers.  {not in Vi}
  1505.  
  1506. CTRL-J                        *c_CTRL-J* *c_<NL>* *c_<CR>*
  1507. <CR> or <NL>    start entered command
  1508.                             *c_<Esc>*
  1509. <Esc>        When typed and 'x' not present in 'cpoptions', quit
  1510.         Command-line mode without executing.  In macros or when 'x'
  1511.         present in 'cpoptions', start entered command.
  1512.                             *c_CTRL-C*
  1513. CTRL-C        quit command line without executing
  1514.  
  1515.                             *c_<Up>*
  1516. <Up>        recall older command line from history, whose beginning
  1517.         matches the current command line (see below).
  1518.                             *c_<Down>*
  1519. <Down>        recall more recent command line from history, whose beginning
  1520.         matches the current command line (see below).
  1521.  
  1522.                             *c_<S-Up>* *c_<PageUp>*
  1523. <S-Up> or <PageUp>
  1524.         recall older command line from history
  1525.                         *c_<S-Down>* *c_<PageDown>*
  1526. <S-Down> or <PageDown>
  1527.         recall more recent command line from history
  1528.  
  1529. CTRL-D        command line completion (see 4.4.2, |cmdline_completion|)
  1530. 'wildchar' option
  1531.         command line completion (see 4.4.2, |cmdline_completion|)
  1532. CTRL-N        command line completion (see 4.4.2, |cmdline_completion|)
  1533. CTRL-P        command line completion (see 4.4.2, |cmdline_completion|)
  1534. CTRL-A        command line completion (see 4.4.2, |cmdline_completion|)
  1535. CTRL-L        command line completion (see 4.4.2, |cmdline_completion|)
  1536.  
  1537.                             *c_CTRL-_*
  1538. CTRL-_        switch between Hebrew and English keyboard mode, which is
  1539.         private to the command line and not related to hkmap.
  1540.         This is useful when Hebrew text entry is required in the
  1541.         command line, searches, abbreviations, etc.  Applies only if
  1542.         Vim is compiled with RIGHTLEFT.  See |vim_rlh.txt|.
  1543.  
  1544. The <Up> and <Down> keys take the current command line as a search string.
  1545. The beginning of the next/previous command lines are compared with this
  1546. string.  The first line that matches is the new command line.  When typing
  1547. these two keys repeatedly, the same string is used again.  For example, this
  1548. can be used to find the previous substitute command: Type ":s" and then <Up>.
  1549. The same could be done by typing <S-Up> a number of times until the desired
  1550. command line is shown.  (Note: the shifted arrow keys do not work on all
  1551. terminals)
  1552.  
  1553.  
  1554. 4.4.2 Command line completion                *cmdline_completion*
  1555.  
  1556. When editing the command line, a few commands can be used to complete the
  1557. word before the cursor.  This is available for:
  1558.  
  1559. - Command names: at the start of the command line.  Works always.
  1560. - tags: only after the ":tag" command.
  1561. - file names: only after a command that accepts a file name or a setting for
  1562.   an option that can be set to a file name.  This is called file name
  1563.   completion.
  1564. - options: only after the ":set" command.
  1565.  
  1566. These are the commands that can be used:
  1567.  
  1568.                             *c_CTRL-D*
  1569. CTRL-D        List names that match the pattern in front of the cursor.
  1570.         When showing file names, directories are highlighted (see
  1571.         'highlight' option)
  1572.                     *c_CTRL-I* *c_wildchar* *c_<Tab>*
  1573. 'wildchar' option
  1574.         A match is done on the pattern in front of the cursor.  The
  1575.         match (if there are several, the first match) is inserted
  1576.         in place of the pattern.  (Note: does not work inside a
  1577.         macro, because <Tab> or <Esc> are mostly used as 'wildchar',
  1578.         and these have a special meaning in some macros.) When typed
  1579.         again and there were multiple matches, the next
  1580.         match is inserted.  After the last match, the first is used
  1581.         again (wrap around).
  1582.                             *c_CTRL-N*
  1583. CTRL-N        After using 'wildchar' which got multiple matches, go to next
  1584.         match.  Otherwise recall more recent command line from history.
  1585. <S-Tab>                            *c_CTRL-P* *c_<S-Tab>*
  1586. CTRL-P        After using 'wildchar' which got multiple matches, go to
  1587.         previous match.  Otherwise recall older command line from
  1588.         history.  <S-Tab> only works with the GUI, on the Amiga and
  1589.         with MS-DOS.
  1590.                             *c_CTRL-A*
  1591. CTRL-A        All names that match the pattern in front of the cursor are
  1592.         inserted.
  1593.                             *c_CTRL-L*
  1594. CTRL-L        A match is done on the pattern in front of the cursor.  If
  1595.         there is one match, it is inserted in place of the pattern.
  1596.         If there are multiple matches the longest common part is
  1597.         inserted in place of the pattern.
  1598.  
  1599. The 'wildchar' option defaults to <Tab> (CTRL-E when compiled with
  1600. COMPATIBLE; in a previous version <Esc> was used).  In the pattern standard
  1601. wildcards '*' and '?' are accepted.  '*' matches any string, '?' matches
  1602. exactly one character.
  1603.  
  1604. If you like tcsh's autolist completion, you can use this mapping:
  1605.     :cnoremap X <C-L><C-D>
  1606. (Where X is the command key to use, <C-L> is CTRL-L and <C-D> is CTRL-D)
  1607. This will find the longest match and then list all matching files.
  1608.  
  1609.                             *suffixes*
  1610. For filename completion you can use the 'suffixes' option to set a priority
  1611. between files with almost the same name.  If there are multiple matches,
  1612. those files with an extension that is in the 'suffixes' option are ignored.
  1613. The default is ".bak,~,.o,.h,.info,.swp", which means that files ending in
  1614. ".bak", "~", ".o", ".h", ".info" and ".swp" are sometimes ignored.  It is
  1615. impossible to ignore suffixes with two dots.  Examples:
  1616.  
  1617. pattern:    files:                match:
  1618. test*        test.c test.h test.o        test.c
  1619. test*        test.h test.o            test.h and test.o
  1620. test*        test.i test.h test.c        test.i and test.c
  1621.  
  1622. If there is more than one matching file (after ignoring the ones matching
  1623. the 'suffixes' option) the first file name is inserted.  You can see that
  1624. there is only one match when you type 'wildchar' twice and the completed
  1625. match stays the same.  You can get to the other matches by entering
  1626. 'wildchar', CTRL-N or CTRL-P.  All files are included, also the ones with
  1627. extensions matching the 'suffixes' option.
  1628.  
  1629. The old value of an option can be obtained by hitting 'wildchar' just after
  1630. the '='.  For example, typing 'wildchar' after ":set dir=" will insert the
  1631. current value of 'dir'.  This overrules filename completion for the options
  1632. that take a file name.
  1633.  
  1634. If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
  1635. your .cshrc:
  1636.     xmodmap -e "keysym Tab = Tab Find"
  1637. And this in your .vimrc:
  1638.     cmap <Esc>[1~ <C-P>        (<C-P> is CTRL-P)
  1639.  
  1640.  
  1641. 4.4.3 Ex command lines                    *cmdline_lines*
  1642.  
  1643. The Ex commands have a few specialties:
  1644.  
  1645.                             *:quote*
  1646. '"' at the start of a line causes the whole line to be ignored.  '"'
  1647. after a command causes the rest of the line to be ignored.  This can be used
  1648. to add comments.  Example:
  1649.     :set ai        "set 'autoindent' option
  1650. It is not possible to add a comment to a shell command ":!cmd" or to the
  1651. ":map" command and friends, because they see the '"' as part of their
  1652. argument.
  1653.  
  1654.                             *:bar*
  1655. '|' can be used to separate commands, so you can give multiple commands in one
  1656. line.  The commands ":global", ":vglobal", ":!", ":r !", ":w !", ":help" and
  1657. ":autocmd" see the '|' as their argument, and can therefore not be followed by
  1658. another command.  If you want '|' to be included in one of the other commands,
  1659. precede it with '\'.  Note that this is confusing (inherited from Vi).   With
  1660. ":g" the '|' is included in the command, with ":s" it is not.
  1661.  
  1662. There is one exception: When the 'b' flag is present in 'cpoptions', with the
  1663. ":map" and ":abbr" commands and friends CTRL-V needs to be used instead of
  1664. '\'.  You can also use "<Bar>" instead.  See also |map_bar|.
  1665.  
  1666. Examples:
  1667.     :!ls | wc        view the output of two commands
  1668.     :r !ls | wc        insert the same output in the text
  1669.     :%g/foo/p|>        moves all matching lines one shiftwidth
  1670.     :%s/foo/bar/|>        moves one line one shiftwidth
  1671.     :map q 10^V|        map "q" to "10|"
  1672.     :map q 10\| map \ l    map "q" to "10\" and map "\" to "l"
  1673.                     (when 'b' is present in 'cpoptions')
  1674.  
  1675. You can also use <NL> to separate commands in the same way as with '|'.  To
  1676. insert a <NL> use CTRL-V CTRL-J.  "^@" will be shown.  Using '|' is the
  1677. preferred method.  But for external commands a <NL> must be used, because a
  1678. '|' is included in the external command.  To avoid the special meaning of <NL>
  1679. it must be preceded with a backslash.  Example:
  1680.     :r !date<NL>-join
  1681. This reads the current date into the file and joins it with the previous line.
  1682.  
  1683. Because of vi compatibility the following strange commands are supported:
  1684.     :|            print current line (like ":p")
  1685.     :3|            print line 3 (like ":3p")
  1686.     :3            goto line 3
  1687.  
  1688. A colon is allowed between the range and the command name.  It is ignored
  1689. (this is vi compatible).  For example ":1,$:s/pat/string".
  1690.  
  1691. When the character '%' or '#' is used where a filename is expected, they are
  1692. expanded to the current and alternate filename (see the chapter "editing
  1693. files" |:_%| |:_#|).
  1694.  
  1695. Embedded spaces in filenames are allowed on the Amiga if one filename is
  1696. expected as argument.  Trailing spaces will be ignored, unless escaped with a
  1697. backslash or CTRL-V.  Note that the ":next" command uses spaces to separate
  1698. file names.  Escape the spaces to include them in a file name.  Example:
  1699.     :next foo\ bar goes\ to school\
  1700. starts editing the three files "foo bar", "goes to" and "school ".
  1701.  
  1702. When you want to use the special characters '"' or '|' in a command, or want
  1703. to use '%' or '#' in a filename, precede them with a backslash.  The backslash
  1704. is not required in a range and in the ":substitute" command.
  1705.  
  1706.                             *:_!*
  1707. The '!' (bang) character after an Ex command makes the command behave in a
  1708. different way.  The '!' should be placed immediately after the command, without
  1709. any blanks in between.  If you insert blanks the '!' will be seen as an
  1710. argument for the command, which has a different meaning.  For example:
  1711.     :w! name    write the current buffer to file "name", overwriting
  1712.             any existing file
  1713.     :w !name    send the current buffer as standard input to command
  1714.             "name"
  1715.  
  1716.  
  1717. 4.4.4 Ex command line ranges            *cmdline_ranges* *[range]*
  1718.  
  1719. Some Ex commands accept a line range in front of them.  This is noted as
  1720. [range].  It consists of one or more line specifiers, separated with ',' or
  1721. ';'.
  1722.  
  1723.                         *:,* *:;*
  1724. When separated with ';' the cursor position will be set to that line
  1725. before interpreting the next line specifier.  This doesn't happen for ','.
  1726. Examples:
  1727.     4,/this line/        from line 4 till match with "this line" after
  1728.                 the cursor line.
  1729.     5;/that line/        from line 5 till match with "that line" after
  1730.                 line 5.
  1731.  
  1732. The default line specifier for most commands is the cursor position, but the
  1733. commands ":write" and ":global" have the whole file (1,$) as default.
  1734.  
  1735. If more line specifiers are given than required for the command, the first
  1736. one(s) will be ignored.
  1737.  
  1738. Line numbers may be specified with:            *:range*
  1739.     {number}    an absolute line number
  1740.     .        the current line              *:.*
  1741.     $        the last line in the file          *:$*
  1742.     %        equal to 1,$ (the entire file)          *:%*
  1743.     *        equal to '<,'> (the Visual area)      *:star*
  1744.     't        position of mark t (lower case)          *:'*
  1745.     /{pattern}[/]    the next line where {pattern} matches      *:/*
  1746.     ?{pattern}[?]    the previous line where {pattern} matches *:?*
  1747.     \/        the next line where the previously used search
  1748.             pattern matches
  1749.     \?        the previous line where the previously used search
  1750.             pattern matches
  1751.     \&        the next line where the previously used substitute
  1752.             pattern matches
  1753.  
  1754. Each may be followed (several times) by '+' or '-' and an optional number.
  1755. This number is added or subtracted from the preceding line number.  If the
  1756. number is omitted, 1 is used.
  1757.  
  1758. The "/" and "?" after {pattern} are required to separate the pattern from
  1759. anything that follows.
  1760.  
  1761. The "/" and "?" may be preceded with another address.  The search starts from
  1762. there.  The difference from using ';' is that the cursor isn't moved.
  1763. Examples:
  1764.     /pat1//pat2/    Find line containing "pat2" after line containing
  1765.             "pat1", without moving the cursor.
  1766.     7;/pat2/    Find line containing "pat2", after line 7, leaving
  1767.             the cursor in line 7.
  1768.  
  1769. The {number} must be between 0 and the number of lines in the file.  A 0 is
  1770. interpreted as a 1, except with the commands tag, pop and read.
  1771.  
  1772. Examples:
  1773.     .+3        three lines below the cursor
  1774.     /that/+1    the line below the next line containing "that"
  1775.     .,$        from current line until end of file
  1776.     0;/that        the first line containing "that"
  1777.  
  1778. Some commands allow for a count after the command.  This count is used as the
  1779. number of lines to be used, starting with the line given in the last line
  1780. specifier (the default is the cursor line).  The commands that accept a count
  1781. are the ones that use a range but do not have a file name argument (because
  1782. a file name can also be a number).
  1783.  
  1784. Examples:
  1785.     :s/x/X/g 5    substitute 'x' by 'X' in the current line and four
  1786.             following lines
  1787.     :23d 4        delete lines 23, 24, 25 and 26
  1788.  
  1789. A range should have the lower line number first.  If this is not the case, Vim
  1790. will ask you if it should swap the line numbers.  This is not done within the
  1791. global command ":g".
  1792.  
  1793.                             *N:*
  1794. When giving a count before entering ":", this is translated into:
  1795.         :.,.+(count - 1)
  1796. In words: The 'count' lines at and after the cursor.  Example: To delete
  1797. three lines:
  1798.         3:d<CR>        is translated into: .,.+2d<CR>
  1799.  
  1800.                             *v_:*
  1801. {Visual}:    Starts a command line with the Visual selected lines as a
  1802.         range.  The code ":'<,'>" is used for this range, which makes
  1803.         it possible to select a similar line from the command line
  1804.         history for repeating a command on different Visually selected
  1805.         lines.
  1806.  
  1807.  
  1808. 4.4.5 Ex special characters                *cmdline_special*
  1809.  
  1810. In Ex commands, at places where a file name can be used, the following
  1811. characters have a special meaning.
  1812.     %       is replaced with the current filename        *:_%*
  1813.     #       is replaced with the alternate filename        *:_#*
  1814.     #n       (where n is a number) is replaced with the filename of
  1815.            buffer n.  "#0" is the same as "#"
  1816.  
  1817. To avoid the special meaning of '%' and '#' insert a backslash before it.
  1818. Detail: The special meaning is always escaped when there is a backslash before
  1819. it, no matter how many backslashes.
  1820.     you type:        result
  1821.        #            alternate.file
  1822.        \#            #
  1823.        \\#            \#
  1824.  
  1825.            *:<cword>* *:<cWORD>* *:<cfile>* *:<afile>* *<afile>* *<cfile>*
  1826. Note: the next four are typed literally, these are not special keys!
  1827.     <cword>    is replaced with the word under the cursor
  1828.     <cWORD>    is replaced with the WORD under the cursor (see |WORD|)
  1829.     <cfile>    is replaced with the path name under the cursor
  1830.     <afile>    when executing autocommands, is replaced with the file name
  1831.            for a file read or write
  1832.  
  1833.         *filename_modifiers* *:_%:* *::p* *::h* *::t* *::r* *::e*
  1834. After "%", "#", "#n", "<cfile>" or "<afile>" modifiers can be given (in this
  1835. order):
  1836.     :p       Make file name a full path.  Must be the first modifier.
  1837.     :h       Head of the file name (the last component and any
  1838.            separators removed).  Cannot be used with :e, :r or :t.
  1839.            Can be repeated to remove several components at the end.
  1840.            When the file name is an absolute path (starts with "/" for
  1841.            Unix; "x:\" for MS-DOS, WIN32, OS/2; "drive:" for Amiga),
  1842.            that part is not removed.  When there is no head (path is
  1843.            relative to current directory) the result is empty.
  1844.     :t       Tail of the file name (last component of the name).  Must
  1845.            precede any :r or :e.
  1846.     :r       Root of the file name (the last extension removed).  When
  1847.            there is only an extension (file name that starts with
  1848.            '.', e.g., ".vimrc"), it is not removed.  Can be repeated to
  1849.            remove several extensions (last one first).
  1850.     :e       Extension of the file name.  Only makes sense when used
  1851.            alone.  When there is no extension the result is empty.
  1852.            When there is only an extension (file name that starts with
  1853.            '.'), the result is empty.  Can be repeated to include more
  1854.            extensions.  If there are not enough extensions (but at
  1855.            least one) as much as possible are included.
  1856.  
  1857. Examples, when the file name is "src/version.c":
  1858.     :p       /home/mool/vim/src/version.c
  1859.     :h              src
  1860.     :p:h       /home/mool/vim/src
  1861.     :p:h:h       /home/mool/vim
  1862.     :t                  version.c
  1863.     :p:t                  version.c
  1864.     :r              src/version
  1865.     :p:r       /home/mool/vim/src/version
  1866.     :t:r                  version
  1867.     :e                      c
  1868.  
  1869. Examples, when the file name is "src/version.c.gz":
  1870.     :p       /home/mool/vim/src/version.c.gz
  1871.     :e                                gz
  1872.     :e:e                                  c.gz
  1873.     :e:e:e                                c.gz
  1874.     :e:e:r                                c
  1875.     :r                        src/version.c
  1876.     :r:e                                  c
  1877.     :r:r                      src/version
  1878.     :r:r:r                    src/version
  1879.  
  1880.                     *extension_removal* *:_%<*
  1881. If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
  1882. name is removed (everything after and including the last '.' in the file
  1883. name).  This is included for backwards compatibility with version 3.0, the
  1884. ":r" form is preferred.  Examples:
  1885.  
  1886.     %        current file name
  1887.     %<        current file name without extension
  1888.     #        alternate file name for current window
  1889.     #<        idem, without extension
  1890.     #31        alternate file number 31
  1891.     #31<        idem, without extension
  1892.     <cword>        word under the cursor
  1893.     <cWORD>        WORD under the cursor (see |WORD|)
  1894.     <cfile>        path name under the cursor
  1895.     <cfile><    idem, without extension
  1896.  
  1897. Note: Where a file name is expected wildcards expansion is done.  On Unix the
  1898. shell is used for this.  Backticks also work, like in 
  1899.     :n `echo *.c`
  1900. But expansion is only done if there are any wildcards before expanding the
  1901. '%', '#', etc..  This avoids expanding wildcards inside a file name.  If you
  1902. want to expand the result of <cfile>, add a wildcard character to it.
  1903. Examples: (alternate filename is "?readme?")
  1904.     command        expands to
  1905.     :e #        :e ?readme?
  1906.     :e `ls #`    :e {files matching "?readme?"}
  1907.     :e #.*        :e {files matching "?readme?.*"}
  1908.     :cd <cfile>    :cd {filename under cursor}
  1909.     :cd <cfile>*    :cd {filename under cursor plus "*" and then expanded}
  1910.  
  1911.                             *filename_backslash*
  1912. For filesystems that use a backslash as directory separator (MS-DOS, Windows,
  1913. OS/2), it's a bit difficult to recognize a backslash that is used to escape
  1914. the special meaning of the next character.  The general rule is: If the
  1915. backslash is followed by a normal filename character, it does not have a
  1916. special meaning.  Therefore "\file\foo" is a valid file name, you don't have
  1917. to type the backslash twice.
  1918.  
  1919. And exception is the '$' sign.  It is a valid character in a filename.  But to
  1920. avoid a filename like "$home" to be interpreted as an environment variable, it
  1921. needs to be preceded by a backslash.  Therefore you need to use "/\$home" for
  1922. the file "$home" in the root directory.  A few examples:
  1923.  
  1924.     filename    interpreted as
  1925.     $home        expanded to value of environment var $home
  1926.     \$home        file "$home" in current directory
  1927.     /\$home        file "$home" in root directory
  1928.     \\$home        file "\\", followed by expanded $home
  1929.  
  1930.  
  1931. 4.5 The window contents                    *window_contents*
  1932.  
  1933. In command and Insert/Replace mode the screen window will show the current
  1934. contents of the buffer: What You See Is What You Get.  There are two
  1935. exceptions:
  1936. - When the 'cpoptions' option contains '$', and the change is within one line,
  1937.   the text is not directly deleted, but a '$' is put at the last deleted
  1938.   character.
  1939. - When inserting text in one window, other windows on the same text are not
  1940.   updated until the insert is finished.
  1941. {Vi: The screen is not always updated on slow terminals}
  1942.  
  1943. Lines longer than the window width will wrap, unless the 'wrap' option is off
  1944. (see below).  The 'linebreak' option can be set to wrap at a blank character.
  1945.  
  1946. The bottom lines in the window may start with one of these two characters:
  1947.  
  1948. '@'    The next line is too long to fit in the window.
  1949. '~'    Below the last line in the buffer.
  1950.  
  1951. If the bottom line is completely filled with '@', the line that is at the
  1952. top of the window is too long to fit in the window.  If the cursor is on this
  1953. line you can't see what you are doing, because this part of the line is not
  1954. shown.  However, the part of the line before the '@'s can be edited normally.
  1955. {Vi: gives an "internal error" on lines that do not fit in the window}
  1956.  
  1957. The 'showbreak' option contains the string to put in front of wrapped lines.
  1958.  
  1959.                             *wrap_off*
  1960. If the 'wrap' option is off, long lines will not wrap.  Only the part that
  1961. fits on the screen is shown.  If the cursor is moved to a part of the line
  1962. that is not shown, the screen is scrolled horizontally.  The advantage of
  1963. this method is that columns are shown as they are and lines that cannot fit
  1964. on the screen can be edited.  The disadvantage is that you cannot see all the
  1965. characters of a line at once.  The 'sidescroll' option can be set to the
  1966. minimal number of columns to scroll.  {Vi: has no 'wrap' option}
  1967.  
  1968. All normal ASCII characters are displayed directly on the screen.  The <Tab>
  1969. is replaced with the number of spaces that it represents.  Other non-printing
  1970. characters are replaced with "^{char}", where {char} is the non-printing
  1971. character with 64 added.  Thus character 7 (bell) will be shown as "^G".
  1972. Characters between 127 and 160 are replaced with "~{char}", where {char} is
  1973. the character with 64 subtracted.  These characters occupy more than one
  1974. position on the screen.  The cursor can only be positioned on the first one.
  1975.  
  1976. If you set the 'number' option, all lines will be preceded with their
  1977. number.  Tip: If you don't like wrapping lines to mix with the line numbers,
  1978. set the 'showbreak' option to eight spaces:
  1979.     ":set showbreak=\ \ \ \ \ \ \ \ "
  1980.  
  1981. If you set the 'list' option, <Tab> characters will not be shown as several
  1982. spaces, but as "^I".  A '$' will be placed at the end of the line, so you can
  1983. find trailing blanks.
  1984.  
  1985. In Command-line mode only the command line itself is shown correctly.  The
  1986. display of the buffer contents is updated as soon as you go back to Command
  1987. mode.
  1988.  
  1989. Some commands hand over the window to external commands (e.g., ":shell" and
  1990. "=").  After these commands are finished the window may be clobbered with
  1991. output from the external command, so it needs to be redrawn.  This is also
  1992. the case if something is displayed on the status line that is longer than
  1993. the width of the window.  If you are expected to have a look at the screen
  1994. before it is redrawn, you get this message:
  1995.  
  1996.     Press RETURN or enter command to continue
  1997.  
  1998. After you type a key the screen will be redrawn and Vim continues.  If you
  1999. type <CR>, <SP> or <NL> nothing else happens.  If you type any other key, it
  2000. will be interpreted as (the start of) a new command.  {Vi: only ":" commands
  2001. are interpreted}
  2002.  
  2003. The last line of the window is used for status and other messages.  The
  2004. status messages will only be used if an option is on:
  2005.  
  2006. status message            option         default    Unix default
  2007. current mode            'showmode'    on        on
  2008. command characters        'showcmd'    on        off
  2009. cursor position            'ruler'        off        off
  2010.  
  2011. The current mode is "-- INSERT --" or "-- REPLACE --", see |'showmode'|.  The
  2012. command characters are those that you typed but were not used yet.  {Vi: does
  2013. not show the characters you typed or the cursor position}
  2014.  
  2015. If you have a slow terminal you can switch off the status messages to speed
  2016. up editing:
  2017.     :set nosc noru nosm
  2018.  
  2019. If there is an error, an error message will be shown for at least one second
  2020. (in reverse video).  {Vi: error messages may be overwritten with other
  2021. messages before you have a chance to read them}
  2022.  
  2023. Some commands show how many lines were affected.  Above which threshold this
  2024. happens can be controlled with the 'report' option (default 2).
  2025.  
  2026. On the Amiga Vim will run in a CLI window.  The name Vim and the full name of
  2027. the current filename will be shown in the title bar.  When the window is
  2028. resized, Vim will automatically redraw the window.  You may make the window as
  2029. small as you like, but if it gets too small not a single line will fit in it.
  2030. Make it at least 40 characters wide to be able to read most messages on the
  2031. last line.
  2032.  
  2033. On most Unix systems window resize works ok.  {Vi: not ok}
  2034.  
  2035.  
  2036. 4.6 Abbreviations                    *abbreviations*
  2037.  
  2038. Abbreviations are used in insert mode, Replace mode and Command-line mode.
  2039. If you enter a word that is an abbreviation, it is replaced with the word it
  2040. stands for.  This can be used to save typing for often used long words.
  2041.  
  2042. There are three types of abbreviations:
  2043.  
  2044. full-id      The "full-id" type consists entirely of keyword characters (letters
  2045.       and characters from 'iskeyword' option).  This is the most common
  2046.       abbreviation.
  2047.  
  2048.       Examples: "foo", "g3", "-1"
  2049.  
  2050. end-id      The "end-id" type ends in a keyword character, but all the other
  2051.       characters are not keyword characters.
  2052.  
  2053.       Examples: "#i", "..f", "$/7"
  2054.  
  2055. non-id      The "non-id" type ends in a non-keyword character, the other
  2056.       characters may be of any type, excluding space and Tab.  {this type
  2057.       is not supported by Vi}
  2058.  
  2059.       Examples: "def#", "4/7$"
  2060.  
  2061. Examples of strings that cannot be abbreviations: "a.b", "#def", "a b", "_$r"
  2062.  
  2063. An abbreviation is only recognized when you type a non-keyword character.
  2064. This can also be the <Esc> that ends insert mode or the <CR> that ends a
  2065. command.  The characters before the cursor must match the abbreviation.  Each
  2066. type has an additional rule:
  2067.  
  2068. full-id      In front of the match is a non-keyword character, or this is where
  2069.       the line or insertion starts.  Exception: When the abbreviation is
  2070.       only one character, it is not recognized if there is a non-keyword
  2071.       character in front of it, other than a space or a <Tab>.
  2072.  
  2073. end-id      In front of the match is a keyword character, or a space or a <Tab>,
  2074.       or this is where the line or insertion starts.
  2075.  
  2076. non-id      In front of the match is a space, <Tab> or the start of the line or
  2077.       the insertion.
  2078.  
  2079. Examples: (<CURSOR> is where you type a non-keyword character)
  2080.     ":ab foo four old otters" (Note that spaces in the <rhs> are allowed
  2081.                   and included in the replacement string.)
  2082.         " foo<CURSOR>"      is expanded to " four old otters"
  2083.         " foobar<CURSOR>" is not expanded
  2084.         "barfoo<CURSOR>"  is not expanded
  2085.  
  2086.     ":ab #i #include"
  2087.         "#i<CURSOR>"      is expanded to "#include"
  2088.         ">#i<CURSOR>"      is not expanded
  2089.  
  2090.     ":ab ;; <endofline>"
  2091.         "test;;"      is not expanded
  2092.         "test ;;"      is expanded to "test <endofline>"
  2093.  
  2094. To avoid the abbreviation in insert mode: Type part of the abbreviation, exit
  2095. insert mode with <Esc>, re-enter insert mode with "a" and type the rest.  Or
  2096. type CTRL-V before the character after the abbreviation.
  2097. To avoid the abbreviation in Command-line mode: Type CTRL-V twice somewhere in
  2098. the abbreviation to avoid it to be replaced.  A CTRL-V in front of a normal
  2099. character is mostly ignored otherwise.
  2100.  
  2101. There are no default abbreviations.
  2102.  
  2103. Abbreviations are never recursive.  You can use ":ab f f-o-o" without any
  2104. problem.  But abbreviations can be mapped.  {some versions of Vi support
  2105. recursive abbreviations, for no apparent reason}
  2106.  
  2107. Abbreviations are disabled if the 'paste' option is on.
  2108.  
  2109.                         *:ab* *:abbreviate*
  2110. :ab[breviate]        list all abbreviations.  The character in the first
  2111.             column indicates the mode where the abbreviation is
  2112.             used: 'i' for insert mode, 'c' for Command-line
  2113.             mode, '!' for both.
  2114.  
  2115. :ab[breviate] <lhs>    list the abbreviations that start with <lhs>
  2116.  
  2117. :ab[breviate] <lhs> <rhs>
  2118.             add abbreviation for <lhs> to <rhs>.  If <lhs> already
  2119.             existed it is replaced with the new <rhs>.  <rhs> may
  2120.             contain spaces.
  2121.  
  2122.                         *:una* *:unabbreviate*
  2123. :una[bbreviate] <lhs>    remove abbreviation for <lhs> from the list
  2124.  
  2125.                         *:norea* *:noreabbrev*
  2126. :norea[bbrev] [lhs] [rhs]
  2127.             same as ":ab", but no remapping for this <rhs> {not
  2128.             in Vi}
  2129.  
  2130.                         *:ca* *:cabbrev*
  2131. :ca[bbrev] [lhs] [rhs]    same as ":ab", but for Command-line mode only.  {not
  2132.             in Vi}
  2133.  
  2134.                         *:cuna* *:cunabbrev*
  2135. :cuna[bbrev] <lhs>    same as ":una", but for Command-line mode only.  {not
  2136.             in Vi}
  2137.  
  2138.                         *:cnorea* *:cnoreabbrev*
  2139. :cnorea[bbrev] [lhs] [rhs]
  2140.             same as ":ab", but for Command-line mode only and no
  2141.             remapping for this <rhs> {not in Vi}
  2142.  
  2143.                         *:ia* *:iabbrev*
  2144. :ia[bbrev] [lhs] [rhs]    same as ":ab", but for Insert mode only.  {not in Vi}
  2145.  
  2146.                         *:iuna* *:iunabbrev*
  2147. :iuna[bbrev] <lhs>    same as ":una", but for insert mode only.  {not in
  2148.             Vi}
  2149.  
  2150.                         *:inorea* *:inoreabbrev*
  2151. :inorea[bbrev] [lhs] [rhs]
  2152.             same as ":ab", but for Insert mode only and no
  2153.             remapping for this <rhs> {not in Vi}
  2154.  
  2155.                             *:abc* *:abclear*
  2156. :abc[lear]        Remove all abbreviations.  {not in Vi}
  2157.  
  2158.                             *:iabc* *:iabclear*
  2159. :iabc[lear]        Remove all abbreviations for Insert mode.  {not in Vi}
  2160.  
  2161.                             *:cabc* *:cabclear*
  2162. :cabc[lear]        Remove all abbreviations for Command-line mode.  {not
  2163.             in Vi}
  2164.  
  2165.                             *using_CTRL-V*
  2166. It is possible to use special characters in the rhs of an abbreviation.
  2167. CTRL-V has to be used to avoid the special meaning of most non printable
  2168. characters.  How many CTRL-Vs need to be typed depends on how you enter the
  2169. abbreviation.  This also applies to mappings.  Let's use an example here.
  2170.  
  2171. Suppose you want to abbreviate "esc" to enter an <Esc> character.  When you
  2172. type the ":ab" command in Vim, you have to enter this: (here ^V is a CTRL-V
  2173. and ^[ is <Esc>)
  2174.  
  2175. You type:   ab esc ^V^V^V^V^V^[
  2176.  
  2177.     All keyboard input is subjected to ^V quote interpretation, so
  2178.     the first, third, and fifth ^V  characters simply allow the second,
  2179.     and fourth ^Vs, and the ^[, to be entered into the command line.
  2180.  
  2181. You see:    ab esc ^V^V^[
  2182.  
  2183.     The command line contains two actual ^Vs before the ^[.  This is
  2184.     how it should appear in your .exrc file, if you choose to go that
  2185.     route.  The first ^V is there to quote the second ^V; the :ab
  2186.     command uses ^V as its own quote character, so you can include quoted
  2187.     whitespace or the | character in the abbreviation.   The :ab command
  2188.     doesn't do anything special with the ^[ character, so it doesn't need
  2189.     to be quoted.  (Although quoting isn't harmful; that's why typing 7
  2190.     [but not 8!] ^Vs works.)
  2191.  
  2192. Stored as:  esc     ^V^[
  2193.  
  2194.     After parsing, the abbreviation's short form ("esc") and long form
  2195.     (the two characters "^V^[") are stored in the abbreviation table.
  2196.     If you give the :ab command with no arguments, this is how the
  2197.     abbreviation will be displayed.
  2198.  
  2199.     Later, when the abbreviation is expanded because the user typed in
  2200.     the word "esc", the long form is subjected to the same type of
  2201.     ^V interpretation as keyboard input.  So the ^V protects the ^[
  2202.     character from being interpreted as the "exit input-mode" character.
  2203.     Instead, the ^[ is inserted into the text.
  2204.  
  2205. Expands to: ^[
  2206.  
  2207. [example given by Steve Kirkendall]
  2208.  
  2209.  
  2210. 4.7 Digraphs                        *digraphs*
  2211.  
  2212.                         *:dig* *:digraphs*
  2213. :dig[raphs]        show currently defined digraphs.  {not in Vi}
  2214.  
  2215. :dig[raphs] {char1}{char2} {number} ...
  2216.             Add digraph {char1}{char2} to the list.  {number} is
  2217.             the decimal representation of the character.
  2218.  
  2219. Digraphs are used to enter characters that normally cannot be entered by
  2220. an ordinary keyboard.  These are mostly accented characters which have the
  2221. eighth bit set.  The digraphs are easier to remember than the decimal number
  2222. that can be entered with CTRL-V (see above).
  2223.  
  2224. Vim must have been compiled with DIGRAPHS defined.  If this wasn't done, the
  2225. ":digraph" command will display an error message.  You can also check this
  2226. with the ":version" command.  If it shows "+digraphs" then it's included,
  2227. "-digraphs" means it's not included.
  2228.  
  2229. There are two methods to enter digraphs:            *i_digraph*
  2230.     CTRL-K {char1} {char2}        or
  2231.     {char1} <BS> {char2}
  2232. The first is always available.  The second only when the 'digraph' option is
  2233. set.
  2234.  
  2235. If a digraph with {char1}{char2} does not exist, a digraph {char2}{char1} is
  2236. searched for.  This will help when you don't remember which character comes
  2237. first.
  2238.  
  2239. Note that when you enter CTRL-K {char1}, where {char1} is a special key, the
  2240. code for that special key is entered.  This is not a digraph.
  2241.  
  2242. Once you have entered the digraph the character is treated like a normal
  2243. character, taking up only one character in the file and on the screen.
  2244. Example:
  2245.     '|' <BS> '|'    will enter the double '|' character (166)
  2246.     'a' <BS> '^'    will enter an 'a' with a hat (226)
  2247.     CTRL-K '-' '-'    will enter a minus sign (173)
  2248.  
  2249. The default digraphs are listed in the file "vim_digr.txt" |digraph_table|.
  2250. There are two sets: One that is used for MS-DOS and one for the international
  2251. standard character set that is mostly used on Unix systems and the Amiga.
  2252. With the wrong character set they will look illogical.
  2253.  
  2254. For CTRL-K there is one general digraph: CTRL-K <Space> {char} will enter
  2255. {char} with the highest bit set.  This can be used to enter meta-characters.
  2256.  
  2257. The <Esc> character cannot be part of a digraph.  When hitting <Esc> the
  2258. entering of the digraph is aborted and Insert mode or command-line mode is
  2259. ended, just like hitting an <Esc>.
  2260.  
  2261. If you accidently typed an 'a' that should be an 'e', you will type 'a' <BS>
  2262. 'e'.  But that is a digraph, so you will not get what you want.  To correct
  2263. this, you will have to type <BS> e again.  To avoid this don't set the
  2264. 'digraph' option and use CTRL-K to enter digraphs.
  2265.  
  2266. You may have problems using Vim with characters which have an ascii value >
  2267. 128.  For example: You insert ue (u-umlaut) and the editor echoes \334 in
  2268. Insert mode.  After leaving the Insert mode everything is fine.  Also fmt
  2269. removes all characters with ascii > 128 from the text being formated.
  2270. On some Unix systems this means you have to define the environment-variable
  2271. LC_CTYPE.  If you are using csh then put in your .cshrc following line:
  2272.     setenv LC_CTYPE iso_8859_1
  2273.  
  2274.  
  2275. 4.8 Using the mouse                    *mouse_using*
  2276.  
  2277. This section is about using the mouse on a terminal or a terminal window.  How
  2278. to use the mouse in a GUI window is explained in |gui_mouse|.  Don't forget to
  2279. do ":set mouse=a", otherwise Vim won't recognize the mouse in all modes (See
  2280. 'mouse').
  2281.  
  2282. Currently the mouse is supported for Unix in an xterm window and for MS-DOS.
  2283. Mouse clicks can be used to position the cursor, select the Visual area and
  2284. paste.  There are no menus, use the GUI version for that.
  2285.  
  2286. The characters in the 'mouse' option tell in which situations the mouse will
  2287. be used by Vim:
  2288.         n    Normal mode
  2289.         v    Visual mode
  2290.         i    Insert mode
  2291.         c    Command-line mode
  2292.         h    all previous modes when in a help file
  2293.         a    all previous modes
  2294.         r    for "Hit return ..." question
  2295.  
  2296. The default for 'mouse' is empty, the mouse is not used.  Normally you would do
  2297.     :set mouse=a
  2298. to start using the mouse (this is equivalent to setting 'mouse' to "nvich").
  2299. If you only want to use the mouse in a few modes or also want to use it for
  2300. the two questions you will have to concatenate the letters for those modes.
  2301. For example:
  2302.     :set mouse=nv
  2303. Will make the mouse work in Normal mode and Visual mode.
  2304.     :set mouse=h
  2305. Will make the mouse work in help files only (so you can use "g<LeftMouse>" to
  2306. jump to tags).
  2307.  
  2308. In an xterm, with the currently active mode included in the 'mouse' option,
  2309. normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key
  2310. pressed go the the xterm.  With the currently active mode not included in
  2311. 'mouse' all mouse clicks go to the xterm.
  2312.  
  2313. Here is how you copy and paste a piece of text:
  2314.  
  2315. Copy/paste with the mouse and Visual mode ('mouse' option must be set, see
  2316. above):
  2317. 1. Press left mouse button on first letter of text, move mouse pointer to last
  2318.    letter of the text and release the button.  This will start Visual mode and
  2319.    highlight the selected area.
  2320. 2. Press "y" to yank the Visual text in the unnamed register.
  2321. 3. Click the left mouse button at the insert position.
  2322. 4. Click the middle mouse button.
  2323.  
  2324. Shortcut: If the insert position is on the screen at the same time as the
  2325. Visual text, you can do 2, 3 and 4 all in one: Click the middle mouse button
  2326. at the insert position.
  2327.  
  2328.                             *xterm_copy_paste*
  2329. Copy/paste in xterm with (current mode NOT included in 'mouse'):
  2330. 1. Press left mouse button on first letter of text, move mouse pointer to last
  2331.    letter of the text and release the button.
  2332. 2. Use normal Vim commands to put the cursor at the insert position.
  2333. 3. Press "a" to start Insert mode.
  2334. 4. Click the middle mouse button.
  2335. 5. Press ESC to end Insert mode.
  2336. (The same can be done with anything in 'mouse' if you keep the shift key
  2337. pressed while using the mouse)
  2338.  
  2339. Note: if you lose the 8th bit when pasting (special characters are translated
  2340. into other characters), you may have to do "stty cs8 -istrip -parenb" in your
  2341. shell before starting Vim.
  2342.  
  2343. Thus in an xterm the shift and ctrl keys cannot be used with the mouse.  To
  2344. make it possible to do the mouse commands that require the ctrl modifier, the
  2345. "g" key can be typed before using the mouse:
  2346.     "g<LeftMouse>"    is "<C-LeftMouse>    (jump to tag under mouse click)
  2347.     "g<RightMouse>" is "<C-RightMouse>    ("CTRL-T")
  2348.  
  2349. A short overview of what the mouse buttons do:
  2350.  
  2351. Normal Mode:
  2352. event          position       Visual      change  action
  2353.            cursor              window
  2354. <LeftMouse>     yes         end        yes
  2355. <C-LeftMouse>   yes         end        yes       "CTRL-]" (2)
  2356. <S-LeftMouse>   yes      no change        yes       "*" (2)    *<S-LeftMouse>*
  2357. <LeftDrag>      yes    start or extend (1) no              *<LeftDrag>*
  2358. <LeftRelease>   yes    start or extend (1) no
  2359. <MiddleMouse>   yes      if not active     no       put
  2360. <MiddleMouse>   yes      if active        no       yank and put
  2361. <RightMouse>    yes    start or extend     yes
  2362. <S-RightMouse>  yes       no change        yes       "#" (2)    *<S-RightMouse>*
  2363. <C-RightMouse>  no            no change        no       "CTRL-T"
  2364. <RightDrag>     yes        extend        no              *<RightDrag>*
  2365. <RightRelease>  yes        extend        no              *<RightRelease>*
  2366.  
  2367. Insert or Replace Mode:
  2368. event          position       Visual      change  action
  2369.            cursor              window
  2370. <LeftMouse>     yes     (cannot be active)  yes
  2371. <C-LeftMouse>   yes     (cannot be active)  yes       "CTRL-O^]" (2)
  2372. <S-LeftMouse>   yes     (cannot be active)  yes       "CTRL-O*" (2)
  2373. <LeftDrag>      yes     start or extend (1) no       like CTRL-O (1)
  2374. <LeftRelease>   yes     start or extend (1) no       like CTRL-O (1)
  2375. <MiddleMouse>   no      (cannot be active)  no       put register
  2376. <RightMouse>    yes     start or extend        yes       like CTRL-O
  2377. <S-RightMouse>  yes     (cannot be active)  yes       "CTRL-O#" (2)
  2378. <C-RightMouse>  no         (cannot be active)  no       "CTRL-O CTRL-T"
  2379.  
  2380. (1) only if mouse pointer moved since press
  2381. (2) only if click is in same buffer
  2382.  
  2383. Clicking the left mouse button causes the cursor to be positioned.  If the
  2384. click is in another window that window is made the active window.  When
  2385. editing the command line the cursor can only be positioned on the
  2386. command line.  When in Insert mode Vim remains in Insert mode.  If 'scrolloff'
  2387. is set, and the cursor is positioned within 'scrolloff' lines from the window
  2388. border, the text is scrolled.
  2389.  
  2390. A Visual area can be selected by pressing the left mouse button on the first
  2391. character, moving the mouse to the last character, then releasing the mouse
  2392. button.  You will not always see the Visual selection until you release the
  2393. button, only in some versions (GUI, MS-DOS, WIN32) will the dragging be shown
  2394. immediately.  Note that you can make the text scroll by moving the mouse at
  2395. least one character in the first/last line in the window when 'scrolloff' is
  2396. non-zero.
  2397.  
  2398. In Normal and Visual mode clicking the right mouse button causes the Visual
  2399. area to be extended.  When clicking in a window which is editing another
  2400. buffer, the Visual mode is stopped.
  2401.  
  2402. Double, triple and quadruple clicks are supported when the GUI is active,
  2403. for MS-DOS and Win32, and for an xterm (if the gettimeofday() function is
  2404. available).  Double clicking may be done to make the selection word-wise,
  2405. triple clicking makes it line-wise, and quadruple clicking makes it
  2406. rectangular block-wise.  For MS-DOS and xterm the time for double clicking can
  2407. be set with the 'mousetime' option.  For the other systems this time is
  2408. defined outside of Vim.
  2409.  
  2410. In Insert mode, when a Visual area is selected, Vim goes into Normal mode
  2411. temporarily.  When Visual mode ends, it returns to Insert mode.  This is like
  2412. using CTRL-O in Insert mode.
  2413.  
  2414.                             *drag_status_line*
  2415. When working with several windows, the size of the windows can be changed by
  2416. dragging the status line with the mouse.  Point the mouse at a status line,
  2417. press the left button, move the mouse to the new position of the status line,
  2418. release the button.  Just clicking the mouse in a status line makes that window
  2419. the current window, without moving the cursor.  If by selecting a window it
  2420. will change position or size, the dragging of the status line will look
  2421. confusing, but it will work (just try it).
  2422.  
  2423. Mouse clicks can be mapped.  The codes for mouse clicks are:
  2424.      code        mouse button          normal action
  2425.  <LeftMouse>     left pressed            set cursor position
  2426.  <LeftDrag>     left moved while pressed   extend Visual area
  2427.  <LeftRelease>     left released            set Visual area end
  2428.  <MiddleMouse>     middle pressed            paste text at cursor position
  2429.  <MiddleDrag>     middle moved while pressed -
  2430.  <MiddleRelease> middle released        -
  2431.  <RightMouse>     right pressed            extend Visual area
  2432.  <RightDrag>     right moved while pressed  extend Visual area
  2433.  <RightRelease>  right released            set Visual area end
  2434.  
  2435. Examples:
  2436.     :noremap <MiddleMouse> <LeftMouse><MiddleMouse>
  2437. Paste at the position of the middle mouse button click (otherwise the paste
  2438. would be done at the cursor position).
  2439.  
  2440.     :noremap <LeftRelease> <LeftRelease>y
  2441. Immediately yank the Visually highlighted text.
  2442.  
  2443. Note the use of ":noremap" instead of "map" to avoid a recursive mapping.
  2444.  
  2445.                         *mouse_swap_buttons*
  2446. To swap the meaning of the left and right mouse buttons:
  2447.     :noremap    <LeftMouse>    <RightMouse>
  2448.     :noremap    <LeftDrag>    <RightDrag>
  2449.     :noremap    <LeftRelease>    <RightRelease>
  2450.     :noremap    <RightMouse>    <LeftMouse>
  2451.     :noremap    <RightDrag>    <LeftDrag>
  2452.     :noremap    <RightRelease>    <LeftRelease>
  2453.     :noremap    g<LeftMouse>    <C-RightMouse>
  2454.     :noremap    g<RightMouse>    <C-LeftMouse>
  2455.     :noremap!    <LeftMouse>    <RightMouse>
  2456.     :noremap!    <LeftDrag>    <RightDrag>
  2457.     :noremap!    <LeftRelease>    <RightRelease>
  2458.     :noremap!    <RightMouse>    <LeftMouse>
  2459.     :noremap!    <RightDrag>    <LeftDrag>
  2460.     :noremap!    <RightRelease>    <LeftRelease>
  2461.  
  2462.  
  2463. 4.9 Online help                    *online_help*
  2464.  
  2465.             *help* *<Help>* *:h* *:help* *<F1>* *i_<F1>* *i_<Help>*
  2466. <Help>        or
  2467. :h[elp]            Split the window and display the help file in
  2468.             read-only mode.  If there is a help window open
  2469.             already, use that one.  {not in Vi}
  2470.  
  2471. :h[elp] {subject}    Like ":help", additionally jump to the tag
  2472.             {subject}.  {subject} can be a pattern |pattern|.
  2473.                :help z.    jump to help for any "z" command
  2474.                :help z\.    jump to the help for "z."
  2475.             If there is no full match for the pattern, or there
  2476.             are several matches, the "best" match will be used.
  2477.             A match is considered to be better when:
  2478.             - if no match with same case is found, a match with
  2479.               ignoring case will be used
  2480.             - the match is after a non-alphanumereic character
  2481.             - it is at near the beginning of the tag
  2482.             - more alphanumeric characters match
  2483.             - the length of the matched is smaller
  2484.             Note that the longer the {subject} you give, the less
  2485.             matches will be found.  You can get an idea how this
  2486.             all works by using commandline completion (type CTRL-D
  2487.             after ":help subject".  {not in Vi}
  2488.  
  2489. The help file name can be set with the 'helpfile' option.  The initial height
  2490. of the help window can be set with the 'helpheight' option (default 20).
  2491. Jump to specific subjects by using tags.  This can be done in two ways:
  2492. - Use the "CTRL-]" command while standing on the name of a command or option.
  2493.   This only works when the tag is a keyword.  "<C-Leftmouse>" and
  2494.   "g<LeftMouse>" work just like "CTRL-]".
  2495. - use the ":ta {subject}" command.  This works with all characters.
  2496.  
  2497. Use "CTRL-T" to jump back.
  2498. Use ":q" to close the help window.
  2499.  
  2500.                             *help_xterm_window*
  2501. If you want to have the help in another xterm window, you could use this
  2502. command:
  2503.     :!xterm -e vim +help &
  2504.  
  2505.                             *doc_files*
  2506. All the help files must be in the same directory.  The files are:
  2507.     vim_help.txt    overview and quick reference          |vim_help.txt|
  2508.     vim_idx.txt    alphabetical index of all commands    |vim_idx.txt|
  2509.     vim_ref.txt    reference manual (this file)          |vim_ref.txt|
  2510.     vim_win.txt    reference manual for windows commands |vim_win.txt|
  2511.     vim_diff.txt    main differences between Vim and Vi   |vim_diff.txt|
  2512.     vim_digr.txt    list of available digraphs          |vim_digr.txt|
  2513.     vim_tips.txt    tips on using Vim              |vim_tips.txt|
  2514.     vim_gui.txt    about the Graphical User Interface    |vim_gui.txt|
  2515.     vim_40.txt    about version 4.0              |vim_40.txt|
  2516.     vim_rlh.txt    about the 'rightleft' option          |vim_rlh.txt|
  2517.  
  2518.     vim_unix.txt    Unix specific remarks              |vim_unix.txt|
  2519.     vim_ami.txt    Amiga specific remarks              |vim_ami.txt|
  2520.     vim_dos.txt    MS-DOS specific remarks              |vim_dos.txt|
  2521.     vim_w32.txt    Windows-NT/95 specific remarks          |vim_w32.txt|
  2522.     vim_os2.txt    OS/2 specific remarks              |vim_os2.txt|
  2523.     vim_arch.txt    Archimedes specific remarks          |vim_arch.txt|
  2524.     vim_mac.txt    Macintosh specific remarks          |vim_mac.txt|
  2525.     vim_mint.txt    Atari MiNT specific remarks           |vim_mint.txt|
  2526.  
  2527.     vim_tags    tags file for documentation
  2528.  
  2529.  
  2530. 5. Editing files                    *edit_files*
  2531. ================
  2532.  
  2533. 5.1 Introduction                    *edit_intro*
  2534.  
  2535. Editing a file with Vim means:
  2536.  
  2537. 1. reading the file into the internal buffer
  2538. 2. changing the buffer with editor commands
  2539. 3. writing the buffer into a file
  2540.  
  2541. As long as you don't write the buffer, the original file remains unchanged.
  2542. If you start editing a file (read a file into the buffer), the file name is
  2543. remembered as the "current filename".
  2544.  
  2545. If there already was a current filename, then that one becomes the alternate
  2546. file name.  All filenames are remembered in the file list.  When you enter a
  2547. filename, for editing (e.g., with ":e filename") or writing (e.g., with (:w
  2548. filename"), the filename is added to the list.  You can use this list to
  2549. remember which files you edited and to quickly switch from one file to
  2550. another with the CTRL-^ command (e.g., to copy text).  First type the number
  2551. of the file and then hit CTRL-^.  {Vi: only one alternate filename}
  2552.  
  2553. CTRL-G        or                *CTRL-G* *:f* *:file*
  2554. :f[ile]            Prints the current filename (as typed), the
  2555.             cursor position (unless the 'ruler' option is set),
  2556.             and the file status (readonly, modified).  See the
  2557.             'shortmess' option about how tho make this message
  2558.             shorter.  {Vi does not include column number}
  2559.  
  2560. {count}CTRL-G        Like CTRL-G, but prints the current filename with full
  2561.             path.  If the count is higher than 1 the current
  2562.             buffer number is also given.  {not in Vi}
  2563.  
  2564.                             *g_CTRL-G*
  2565. g CTRL-G        Prints the current position of the cursor in three
  2566.             ways: Column, Line and Character.  If there are
  2567.             characters in the line that take more than one
  2568.             position on the screen (<Tab> or special character),
  2569.             both the "real" column and the screen column are
  2570.             shown, separated with a dash.  See also 'ruler'
  2571.             option.  {not in Vi}
  2572.  
  2573.                             *:file_f*
  2574. :f[ile] {name}        Sets the current filename to {name}.
  2575.  
  2576. :buffers
  2577. :files
  2578. :ls            List all the currently known file names.  See
  2579.             'vim_win.txt' |:files| |:buffers| |:ls|.  {not in
  2580.             Vi}
  2581.  
  2582. Vim will remember the full path name of a file name that you enter.  In most
  2583. cases when the file name is displayed only the name you typed is shown, but
  2584. the full path name is being used if you used the ":cd" command |:cd|.
  2585.  
  2586.                             *home_replace*
  2587. If the environment variable 'HOME' is set, and the file name starts with that
  2588. string, it is often displayed with HOME replaced with "~".  This was done to
  2589. keep file names short.  When reading or writing files the full name is still
  2590. used, the "~" is only used when displaying file names.  When replacing the
  2591. file name would result in just "~", "~/" is used instead (to avoid confusion
  2592. with 'backupext' set to "~").
  2593.  
  2594. When writing the buffer, the default is to use the current filename.  Thus
  2595. when you give the "ZZ" or ":wq" command, the original file will be
  2596. overwritten.  If you do not want this, the buffer can be written into another
  2597. file by giving a filename argument to the ":write" command.  For example:
  2598.  
  2599.     vim testfile
  2600.     [change the buffer with editor commands]
  2601.     :w newfile
  2602.     :q
  2603.  
  2604. This will create a file "newfile", that is a modified copy of "testfile".
  2605. The file "testfile" will remain unchanged.  Anyway, if the 'backup' option is
  2606. set, Vim renames or copies the original file before it will be overwritten.
  2607. You can use this file if you discover that you need the original file.  See
  2608. also the 'patchmode' option.  The name of the backup file is normally the same
  2609. as the original file with 'backupext' appended.  The default "~" is a bit
  2610. strange to avoid accidently overwriting existing files.  If you prefer ".bak"
  2611. change the 'backupext' option.  Extra dots are replaced with '_' on MS-DOS
  2612. machines, when Vim has detected that an MS-DOS-like filesystem is being used
  2613. (e.g., messydos or crossdos) or when the 'shortname' option is on.  The
  2614. backup file can be placed in another directory by setting 'backupdir'.
  2615.  
  2616.                             *auto_shortname*
  2617. Technical: On the Amiga you can use 30 characters for a file name.  But on an
  2618.        MS-DOS-compatible filesystem only 8 plus 3 characters are
  2619.        available.  Vim tries to detect the type of filesystem when it is
  2620.        creating the .swp file.  If an MS-DOS-like filesystem is suspected,
  2621.        a flag is set that has the same effect as setting the 'shortname'
  2622.        option.  This flag will be reset as soon as you start editing a
  2623.        new file.  The flag will be used when making the filename for the
  2624.        ".swp" and ".~" files for the current file.  But when you are
  2625.        editing a file in a normal filesystem and write to an MS-DOS-like
  2626.        filesystem the flag will not have been set.  In that case the
  2627.        creation of the ".~" file may fail and you will get an error
  2628.        message.  Use the 'shortname' option in this case.
  2629.  
  2630. When you started editing without giving a file name, "No File" is displayed in
  2631. messages.  If the ":write" command is used with a file name argument, the file
  2632. name for the current file is set to that file name.  This only happens when
  2633. the 'F' flag is included in 'cpoptions' (by default it is included).  This is
  2634. useful when entering text in an empty buffer and then writing it to a file.
  2635. If 'cpoptions' contains the 'f' flag (by default it is NOT included) the file
  2636. name is set for the ":read file" command.  This is useful when starting Vim
  2637. without an argument and then doing ":read file" to start editing a file.
  2638. Because the file name was set without really starting to edit that file, you
  2639. are protected from overwriting that file.  This is done by setting the
  2640. "notedited" flag.  You can see if this flag is set with the CTRL-G or ":file"
  2641. command.  It will include "[Not edited]" when the "notedited" flag is set.
  2642. When writing the buffer to the current file name (with ":w!"), the "notedited"
  2643. flag is reset.
  2644.  
  2645. Vim remembers whether you have changed the buffer.  You are protected from
  2646. losing the changes you made.  If you try to quit without writing, or want to
  2647. start editing another file, this will be refused.  In order to overrule this
  2648. protection add a '!' to the command.  The changes will then be lost.  For
  2649. example: ":q" will not work if the buffer was changed, but ":q!" will.  To see
  2650. whether the buffer was changed use the "CTRL-G" command.  The message includes
  2651. the string "[Modified]" if the buffer has been changed.
  2652.  
  2653.  
  2654. 5.2 Editing a file                    *edit_a_file*
  2655.  
  2656.                             *:e* *:edit*
  2657. :e[dit] [+cmd]        Edit the current file, unless changes have been made.
  2658.  
  2659.                             *:edit!*
  2660. :e[dit]! [+cmd]        Edit the current file always.  Discard any changes to
  2661.             the buffer.
  2662.  
  2663.                             *:edit_f*
  2664. :e[dit] [+cmd] {file}    Edit {file}, unless changes have been made.
  2665.  
  2666.                             *:edit!_f*
  2667. :e[dit]! [+cmd] {file}    Edit {file} always.  Discard any changes to the
  2668.             buffer.
  2669.  
  2670. :e[dit] #[count]    Edit the [count]th alternate filename (as shown by
  2671.             :files).  This command does the same as
  2672.             [count] CTRL-^.
  2673.  
  2674.                             *:ex*
  2675. :ex [+cmd] [file]    Same as :edit.  {Vi: go from visual to Ex mode}
  2676.  
  2677.                             *:vi* *:visual*
  2678. :vi[sual] [+cmd] [file]    Same as :edit.  {Vi: go from Ex to visual mode}
  2679.  
  2680.                             *:vie* *:view*
  2681. :vie[w] [+cmd] file    Same as :edit, but set 'readonly' option for this
  2682.             buffer.  {not in Vi}
  2683.  
  2684.                             *CTRL-^*
  2685. [count]CTRL-^        Edit [count]th alternate file (equivalent to ":e
  2686.             #[count]").  Without count this gets you to the
  2687.             previously edited file.  This is a quick way to
  2688.             toggle between two (or more) files.  If the
  2689.             'autowrite' option is on and the buffer was
  2690.             changed, write it.
  2691.  
  2692. ]f                            *]f*
  2693. [f                            *[f* *gf*
  2694. gf            Edit the file whose name is under or after the
  2695.             cursor.  Mnemonic: "goto file".   Uses the 'isfname'
  2696.             option to find out which characters are supposed to be
  2697.             in a file name.  Uses the 'path' variable as a list of
  2698.             directory names to look for the file.  Also looks for
  2699.             the file relative to the current file.  This command
  2700.             fails if the current file cannot be abandoned.  If the
  2701.             name is a hypertext link, that looks like
  2702.             "type://machine/path", only "/path" is used.  For Unix
  2703.             the '~' character is expanded, like in "~user/file".
  2704.             Environment variables are expanded too |expand_env|.
  2705.             {not in Vi}
  2706.  
  2707.                             *:cd*
  2708. :cd            On non-Unix systems: Print the current directory
  2709.             name.  On Unix systems: Change the current directory
  2710.             to the home directory.
  2711.  
  2712. :cd {path}        Change the current directory to {path}.  Does not
  2713.             change the meaning of an already entered file name,
  2714.             because its full path name is remembered.  On MS-DOS
  2715.             this also changes the active drive.
  2716.  
  2717.                             *:chd* *:chdir*
  2718. :chd[ir] [path]        Same as :cd.
  2719.  
  2720.                             *:pw* *:pwd*
  2721. :pw[d]            Print the current directory name.  {Vi: no pwd}
  2722.  
  2723. These commands are used to start editing a single file.  This means that the
  2724. file is read into the buffer and the current filename is set.  You may use the
  2725. ":cd" command to get to another directory, so you will not have to type that
  2726. directory name in front of the filenames.  One warning: After using ":cd" the
  2727. full path name will be used for reading and writing files.  On some networked
  2728. file systems this may cause problems.  The result of using the full path name
  2729. is that the file names currently in use will remain referring to the same
  2730. file.  Example: If you have a file a:test and a directory a:vim the commands
  2731. ":e test" ":cd vim" ":w" will overwrite the file a:test and not write
  2732. a:vim/test.  But if you do ":w test" the file a:vim/test will be written,
  2733. because you gave a new file name and did not refer to a file name before the
  2734. ":cd".
  2735.  
  2736.                             *:filename*
  2737. Note for systems other than Unix and MS-DOS: When using a command that
  2738. accepts a single file name (like ":edit file") spaces in the file name are
  2739. allowed, but trailing spaces are ignored.  This is useful on systems that
  2740. allow file names with embedded spaces (like the Amiga).  Example: The command
  2741. ":e   Long File Name " will edit the file "Long File Name".  When using a
  2742. command that accepts more than one file name (like ":next file1 file2")
  2743. embedded spaces must be escaped with a backslash.
  2744.  
  2745. On Unix you can also use backticks in the file name, for example:
  2746.     :e `find . -name ver\\*.c -print`
  2747. The backslashes before the star are required to prevent "ver*.c" to be
  2748. expanded by the shell before executing the find program.
  2749.  
  2750. You can use the ":e!" command if you messed up the buffer and want to start
  2751. all over again.  The ":e" command is only useful if you have changed the
  2752. current filename.
  2753.  
  2754. Note that ":e file" will fail if there are changes in the current buffer,
  2755. also when the 'autowrite' option is on.  This is illogical, because with
  2756. other commands (e.g., ":next") the current buffer would be written and
  2757. abandoned, but this behaviour is compatible with Vi.  If you encounter this
  2758. problem, you can use CTRL-^ to jump to the file, because the alternate file
  2759. name is set to the argument of the ":e" command.
  2760.  
  2761.                             *:+cmd*
  2762. The [+cmd] can be used to position the cursor in the newly opened file:
  2763.     +        Start at the last line.
  2764.     +{num}        Start at line {num}.
  2765.     +/{pat}        Start at first line containing {pat}.  {pat} must not
  2766.             contain any spaces.
  2767.     +{command}    Execute {command} after opening the new file.
  2768.             {command} is an Ex command.  It must not contain
  2769.             spaces.
  2770.  
  2771.                             *textmode_io*
  2772. When reading a file when the 'textmode' option is off (default for
  2773. non-MS-DOS) the <NL> character is interpreted as end-of-line.  If 'textmode'
  2774. is on (default for MS-DOS), <CR> <NL> is also interpreted as end-of-line.
  2775. Also see |textmode_read|.
  2776.  
  2777. When writing a file when the 'textmode' option is off a <NL> character is
  2778. used to separate lines.  When the 'textmode' option is on <CR> <NL> is used.
  2779. Also see |textmode_write|.
  2780.  
  2781. You can read a file with 'textmode' set and write it with 'textmode' reset.
  2782. This will replace all <CR> <NL> pairs by <NL>.  If you read a file with
  2783. 'textmode' reset and write with 'textmode' set, all <NL> characters will be
  2784. replaced with <CR> <NL>.
  2785.  
  2786. If you start editing a new file and the 'textauto' option is on (which is the
  2787. default), Vim will try to detect whether the lines in the file are separated
  2788. by a single <NL> (as used on Unix and Amiga) or by a <CR> <NL> pair (MS-DOS).
  2789. Only when ALL lines end in <CR> <NL> the 'textmode' option is set, otherwise
  2790. it is reset.  If the 'textmode' option is set on non-MS-DOS systems the
  2791. message "[textmode]" is shown to remind you that something unusual is
  2792. happening.  On MS-DOS systems you get the message "[notextmode]" if the
  2793. 'textmode' option is not set.
  2794.  
  2795. If the 'textauto' option is off and 'textmode' is on, but while reading a file
  2796. some lines did not end in <CR> <NL>, "[CR missing]" will be included in the
  2797. file message.
  2798.  
  2799. Before editing binary, executable or Vim script files you should set the
  2800. 'textmode' and 'textauto' options off.  With 'textmode' on you risk that
  2801. single <NL> characters are unexpectedly replaced with <CR> <NL>.  A simple way
  2802. to do this is by starting Vim with the "-b" option.
  2803.  
  2804.  
  2805. 5.3 The argument list                    *argument_list*
  2806.  
  2807. If you give more than one filename when starting Vim, this list is
  2808. remembered as the argument list.  Do not confuse this with the file list,
  2809. which you can see with the ":files" command |:files|.  The argument list was
  2810. already present in Vi, the file list is new in Vim.  The file names in the
  2811. argument list will also be present in the file list (unless they were
  2812. deleted with ":bdel").
  2813.  
  2814. You can use the argument list with the following commands:
  2815.  
  2816.                             *:ar* *:args*
  2817. :ar[gs]            Print the argument list, with the current file in
  2818.             square brackets.
  2819.  
  2820.                             *:argu* *:argument*
  2821. :[count]argu[ment] [count] [+cmd]
  2822.             Edit file [count] in the argument list, unless
  2823.             changes have been made and the 'autowrite' option is
  2824.             off.  {Vi: no such command}
  2825.  
  2826. :[count]argu[ment]! [count] [+cmd]
  2827.             Edit file [count] in the argument list, discard any
  2828.             changes to the current buffer.  {Vi: no such command}
  2829.  
  2830.                             *:n* *:next*
  2831. :[count]n[ext] [+cmd]    Edit [count] next file, unless changes have been
  2832.             made and the 'autowrite' option is off {Vi: no
  2833.             count}.
  2834.  
  2835. :[count]n[ext]! [+cmd]    Edit [count] next file, discard any changes to the
  2836.             buffer {Vi: no count}.
  2837.  
  2838. :ar[gs] [+cmd] {arglist}
  2839. :n[ext] [+cmd] {arglist}
  2840.             Define {arglist} as the new argument list and edit
  2841.             the first one, unless changes have been made and the
  2842.             'autowrite' option is off.
  2843.  
  2844. :ar[gs]! [+cmd] {arglist}
  2845. :n[ext]! [+cmd] {arglist}                *:next_f*
  2846.             Define {arglist} as the new argument list and edit
  2847.             the first one.  Discard any changes to the buffer.
  2848.  
  2849. :[count]N[ext] [count] [+cmd]                *:Next* *:N*
  2850.             Edit [count] previous file in argument list, unless
  2851.             changes have been made and the 'autowrite' option is
  2852.             off {Vi: no count}.
  2853.  
  2854. :[count]N[ext]! [count] [+cmd]
  2855.             Edit [count] previous file in argument list.  Discard
  2856.             any changes to the buffer {Vi: no count}.
  2857.  
  2858. :[count]prev[ious] [count] [+cmd]            *:prev* *:previous*
  2859.             Same as :Next {Vi: only in some versions}
  2860.  
  2861.                             *:rew* *:rewind*
  2862. :rew[ind] [+cmd]    Start editing the first file in the argument list,
  2863.             unless changes have been made and the 'autowrite'
  2864.             option is off.
  2865.  
  2866. :rew[ind]! [+cmd]    Start editing the first file in the argument list.
  2867.             Discard any changes to the buffer.
  2868.  
  2869.                             *:la* *:last*
  2870. :la[st] [+cmd]        Start editing the last file in the argument list,
  2871.             unless changes have been made and the 'autowrite'
  2872.             option is off.  {not in Vi}
  2873.  
  2874. :la[st]! [+cmd]        Start editing the last file in the argument list.
  2875.             Discard any changes to the buffer.  {not in Vi}
  2876.  
  2877.                             *:wn* *:wnext*
  2878. :[count]wn[ext] [+cmd]    Write current file and start editing the [count]
  2879.             next file.  {not in Vi}
  2880.  
  2881. :[count]wn[ext] [+cmd] {file}
  2882.             Write current file to {file} and start editing the
  2883.             [count] next file, unless {file} already exists and
  2884.             the 'writeany' option is off.  {not in Vi}
  2885.  
  2886. :[count]wn[ext]! [+cmd] {file}
  2887.             Write current file to {file} and start editing the
  2888.             [count] next file.  {not in Vi}
  2889.  
  2890. :[count]wN[ext][!] [+cmd] [file]            *:wN* *:wNext*
  2891. :[count]wp[revous][!] [+cmd] [file]            *:wp* *:wprevious*
  2892.             Same as :wnext, but go to previous file instead of
  2893.             next.  {not in Vi}
  2894.  
  2895. The [count] in the commands above defaults to one.  For some commands it is
  2896. possible to use two counts.  The last one (rightmost one) is used.
  2897.  
  2898. For [+cmd] see 5.2 |edit_a_file|.
  2899.  
  2900. The wildcards in the argument list are expanded and the filenames are sorted.
  2901. Thus you can use the command "vim *.c" to edit all the C files.  From within
  2902. Vim the command ":n *.c" does the same.  On Unix you can also use backticks,
  2903. for example:
  2904.     :n `find . -name \\*.c -print`
  2905. The backslashes before the star are required to prevent "*.c" to be expanded
  2906. by the shell before executing the find program.
  2907.  
  2908.                             *arglist_quit*
  2909. You are protected from leaving Vim if you have not been editing the last file
  2910. in the argument list.  This prevents you from forgetting that you were editing
  2911. one out of several files.  To exit anyway try to exit twice.  If there are
  2912. changes in the current buffer this will fail.  You can exit anyway, and save
  2913. any changes, with the ":wq!" command.  To lose any changes use the ":q!"
  2914. command.
  2915.  
  2916. When there is an argument list you can see which file you are editing in the
  2917. title of the window (if there is one and 'title' is on) and with the file
  2918. message you get with the "CTRL-G" command.  You will see something like
  2919.     (file 4 of 11)
  2920. If 'shortmess' contains 'f' it will be
  2921.     (4 of 11)
  2922. If you are not really editing the file at the current position in the argument
  2923. list it will be
  2924.     (file (4) of 11)
  2925. This means that you are position 4 in the argument list, but not editing the
  2926. fourth file in the argument list.  This happens when you do ":e file".
  2927.  
  2928.  
  2929. 5.4 Writing and quitting            *write_quit* *save_file*
  2930.  
  2931.                             *:w* *:write*
  2932. :[range]w[rite][!]    Write the specified lines to the current file.
  2933.  
  2934.                             *:w_f* *:write_f*
  2935. :[range]w[rite]    {file}    Write the specified lines to {file}, unless it
  2936.             already exists and the 'writeany' option is off.
  2937.  
  2938.                             *:w!*
  2939. :[range]w[rite]! {file}    Write the specified lines to {file}.  Overwrite an
  2940.             existing file.
  2941.  
  2942.                             *:w_a* *:write_a*
  2943. :[range]w[rite][!] >>    Append the specified lines to the current file.
  2944.  
  2945. :[range]w[rite][!] >> {file}
  2946.             Append the specified lines to {file}.  '!' forces the
  2947.             write even if file does not exist.
  2948.  
  2949.                             *:w_c* *:write_c*
  2950. :[range]w[rite] !{cmd}    Execute {cmd} with [range] lines as standard input
  2951.             (note the space in front of the '!').  {cmd} is
  2952.             executed like with ":!{cmd}", any '!' is replaced with
  2953.             the previous command |:!|.
  2954.  
  2955. The default [range] for the ":w" command is the whole buffer (1,$).
  2956. If a file name is given with ":w" it becomes the alternate file.  This can be
  2957. used, for example, when the write fails and you want to try again later with
  2958. ":w #".  This can be switched off by removing the 'A' flag from the
  2959. 'cpoptions' option.
  2960.  
  2961.  
  2962.                             *:q* *:quit*
  2963. :q[uit]            Quit, unless changes have been made or not editing
  2964.             the last file in the argument list.
  2965.  
  2966. :q[uit]!        Quit always, without writing.
  2967.  
  2968. :cq            Quit always, without writing, and return an error
  2969.             code.  Used for Manx's QuickFix mode (see 5.5
  2970.             |quickfix|).
  2971.  
  2972.                             *:wq*
  2973. :wq            Write the current file and exit (unless editing the
  2974.             last file in the argument list or the file is
  2975.             read-only).
  2976.  
  2977. :wq!            Write the current file and exit.
  2978.  
  2979. :wq {file}        Write to {file}.  Exit if not editing the last
  2980.             file in the argument list.
  2981.  
  2982. :wq! {file}        Write to {file} and exit.
  2983.  
  2984. :[range]wq[!] [file]    Same as above, but only write the lines in [range].
  2985.  
  2986.                             *:x* *:xit*
  2987. :[range]x[it][!] [file]
  2988.             Like ":wq", but write only when changes have been
  2989.             made.
  2990.  
  2991.                             *:exi* *:exit*
  2992. :[range]exi[t][!] [file]
  2993.             Same as :xit.
  2994.  
  2995.                             *ZZ*
  2996. ZZ            Write current file, if modified, and exit (same as
  2997.             ":x").  (Note: If there are several windows for the
  2998.             current file, the file is written if it was modified
  2999.             and the window is closed).
  3000.  
  3001.                             *ZQ*
  3002. ZQ            Quit current file and exit (same as ":q!").  (Note: If
  3003.             there are several windows for the current file, only
  3004.             the window is closed).
  3005.  
  3006.                             *timestamp*
  3007. Vim remembers the timestamp of the file when you start editing it.  When you
  3008. write a file the timestamp is checked.  If the file has been changed since you
  3009. started editing it, Vim will ask you if you really want to overwrite the file:
  3010.  
  3011.     WARNING: The file has been changed since reading it!!!
  3012.     Do you really want to write to it (y/n)?
  3013.  
  3014. If you hit 'y' Vim will continue writing the file.  If you hit 'n' the write is
  3015. aborted.  If you used ":wq" or "ZZ" Vim will not exit, you will get another
  3016. chance to write the file.
  3017. The message would normally mean that somebody has written to the file after
  3018. the edit session started.  This could be another person, in which case you
  3019. probably want to check if your changes to the file and the changes from the
  3020. other person should be merged.  Write the file under another name and check for
  3021. differences (the "diff" program can be used for this).
  3022. It is also possible that you modified the file yourself, from another edit
  3023. session or with another command (e.g., a filter command).  Then you will know
  3024. which version of the file you want to keep.
  3025.  
  3026.                             *backup*
  3027. If you write to an existing file (but do not append) while the 'backup',
  3028. 'writebackup' or 'patchmode' option is on, a backup of the original file is
  3029. made.  On Unix systems the file is copied, on other systems the file is
  3030. renamed.  After the file has been successfully written and when the
  3031. 'writebackup' option is on and the 'backup' option is off, the backup file is
  3032. deleted.  When the 'patchmode' option is on the backup file may be renamed.
  3033.  
  3034.                             *backup_table*
  3035. 'backup' 'writebackup'    action
  3036.    off         off    no backup made
  3037.    off         on        backup current file, deleted afterwards (default)
  3038.    on         off    delete old backup, backup current file
  3039.    on         on        delete old backup, backup current file
  3040.  
  3041. When the 'backup' option is on, an old backup file (with the same name as the
  3042. new backup file) will be deleted.  If 'backup' is not set, but 'writebackup' is
  3043. set, an existing backup file will not be deleted.  The backup file that is made
  3044. while the file is being written will have a different name.
  3045.  
  3046. The directories given with the 'backupdir' option is used to put the backup
  3047. file in.  (default: same directory as the written file).
  3048.  
  3049. On Unix systems:
  3050. When you write to an existing file, that file is truncated and then filled
  3051. with the new text.  This means that protection bits, owner and symbolic links
  3052. are unmodified.  The backup file however, is a new file, owned by the user who
  3053. edited the file.  The group of the backup is set to the group of the original
  3054. file.  If this fails, the protection bits for the group are made the same as
  3055. for others.
  3056.  
  3057. If the creation of a backup file fails, the write is not done.  If you want
  3058. to write anyway add a '!' to the command.
  3059.  
  3060.                             *write_fail*
  3061. If the writing of the new file fails, you have to be careful not to lose
  3062. your changes AND the original file.  If there is no backup file and writing
  3063. the new file failed, you have already lost the original file! DON'T EXIT VIM
  3064. UNTIL YOU WRITE OUT THE FILE! If a backup was made, it is put back in place
  3065. of the original file (if possible).  If you exit Vim, and lose the changes
  3066. you made, the original file will mostly still be there.  If putting back the
  3067. original file fails, there will be an error message telling you that you
  3068. lost the original file.
  3069.  
  3070.                             *textmode_write*
  3071. If the 'textmode' option is on <CR> <NL> is used for end-of-line.  This is
  3072. default for MS-DOS, Win32 and OS/2.  On other systems the message "[textmode]"
  3073. is shown to remind you that an usual end-of-line marker was used.  If the
  3074. 'textmode' is not set NL is used for end-of-line.  On MS-DOS, Win32 and OS/2
  3075. the message "[notextmode]" is shown.  See also |textmode_io| and the
  3076. 'textmode' and 'textauto' options.
  3077.  
  3078.  
  3079. 5.5 Using the QuickFix mode                *quickfix*
  3080.  
  3081. Vim has a special mode to speedup the edit-compile-edit cycle.  This is
  3082. inspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
  3083. The idea is to save the error messages from the compiler in a file and use
  3084. Vim to jump to the errors one by one.  You can then examine each problem and
  3085. fix it, without having to remember all the error messages.
  3086.  
  3087. If you are using Manx's Aztec C compiler on the Amiga you should do the
  3088. following:
  3089. - Set the CCEDIT environment variable with the command
  3090.     mset "CCEDIT=vim -e"
  3091. - Compile with the -qf option.  If the compiler finds any errors, Vim is
  3092.   started and the cursor is positioned on the first error.  The error message
  3093.   will be displayed on the last line.  You can go to other errors with the
  3094.   commands mentioned below.  You can fix the errors and write the file(s).
  3095. - If you exit Vim normally the compiler will re-compile the same file.  If you
  3096.   exit with the :cq command, the compiler will terminate.  Do this if you
  3097.   cannot fix the error, or if another file needs to be compiled first.
  3098.  
  3099. If you are using another compiler you should save the error messages in a
  3100. file and start Vim with "vim -e filename".  An easy way to do this is with
  3101. the ":make" command (see below).  The 'errorformat' option should be set to
  3102. match the error messages from your compiler (see below).
  3103.  
  3104. The following commands can be used if you are in QuickFix mode:
  3105.  
  3106.                             *:cc*
  3107. :cc[!] [nr]        Display error [nr].  If [nr] is omitted, the same
  3108.             error is displayed again.  Without [!] this doesn't
  3109.             work when jumping to another buffer, the current buffer
  3110.             has been changed, there is the only window for the
  3111.             buffer and both 'hidden' and 'autowrite' are off.
  3112.             When jumping to another buffer with [!] any changes to
  3113.             the current buffer are lost, unless 'hidden' is set or
  3114.             there is another window for this buffer.  {not in Vi}
  3115.  
  3116.                             *:cn* *:cnext*
  3117. :[count]cn[ext][!]    Display the [count] next error in the list that
  3118.             includes a file name.  If there are no file names at
  3119.             all, go the the [count] next error.  See |:cc| for
  3120.             [!].  {not in Vi}
  3121.  
  3122. :[count]cN[ext][!]            *:cp* *:cprevious* *:cN* *:cNext*
  3123. :[count]cp[revious][!]    Display the [count] previous error in the list that
  3124.             includes a file name.  If there are no file names at
  3125.             all, go the the [count] previous error.  See |:cc| for
  3126.             [!].  {not in Vi}
  3127.  
  3128.                             *:cq* *:cquit*
  3129. :cq[uit]        Quit Vim with an error code, so that the compiler
  3130.             will not compile the same file again.  {not in Vi}
  3131.  
  3132.                             *:cf* *:cfile*
  3133. :cf[ile][!] [errorfile]    Read the error file and jump to the first error.
  3134.             This is done automatically when Vim is started with
  3135.             the -e option.  You can use this command when you
  3136.             keep Vim running while compiling.  If you give the
  3137.             name of the errorfile, the 'errorfile' option will
  3138.             be set to [errorfile].  See |:cc| for [!].  {not in
  3139.             Vi}
  3140.  
  3141.                             *:cl* *:clist*
  3142. :cl[ist]        List all errors that inlcude a file name.  {not in Vi}
  3143.  
  3144. :cl[ist]!        List all errors.  {not in Vi}
  3145.  
  3146.                             *:mak* *:make*
  3147. :mak[e] [arguments]    1. If the 'autowrite' option is on, write any changed
  3148.                buffers
  3149.             2. Any existing 'errorfile' is deleted.
  3150.             3. The program given with the 'makeprg' option is
  3151.                started (default "make") with the optional
  3152.                [arguments] and the output is saved in
  3153.                'errorfile' (for Unix it is also echoed on the
  3154.                screen).
  3155.             4. The 'errorfile' is then read and the first error
  3156.                is jumped to.
  3157.             5. The 'errorfile' is deleted.
  3158.             {not in Vi}
  3159.  
  3160. The name of the file can be set with the 'errorfile' option.  The default is
  3161. "AztecC.Err" for the Amiga and "errors.vim" for other systems.  The format of
  3162. the file from the Aztec compiler is:
  3163.  
  3164.     filename>linenumber:columnnumber:errortype:errornumber:errormessage
  3165.  
  3166.     filename    name of the file in which the error was detected
  3167.     linenumber    line number where the error was detected
  3168.     columnnumber    column number where the error was detected
  3169.     errortype    type of the error, normally a single 'E' or 'W'
  3170.     errornumber    number of the error (for lookup in the manual)
  3171.     errormessage    description of the error
  3172.  
  3173.                             *errorformat*
  3174. Another compiler is likely to use a different format.  You should set the
  3175. 'errorformat' option to a scanf-like string that describes the format.
  3176. First, you need to know how scanf works.  Look in the documentation of your
  3177. C compiler.  Vim will understand eight conversion characters.  Others are
  3178. invalid.
  3179.     %f        file name (finds a string)
  3180.     %l        line number (finds a number)
  3181.     %c        column number (finds a number)
  3182.     %t        error type (finds a single character)
  3183.     %n        error number (finds a number)
  3184.     %m        error message (finds a string)
  3185.     %*<conv>    any scanf non-assignable conversion
  3186.     %%        the single '%' character
  3187.  
  3188. Examples:
  3189. %f>%l:%c:%t:%n:%m"            for the AztecC.Err file
  3190. %f:%l:\ %t%*[^0123456789]%n:\ %m    for Manx/Aztec C error messages
  3191.                     (scanf() doesn't understand [0-9])
  3192. %f\ %l\ %t%*[^0-9]%n:\ %m        for SAS C
  3193. \"%f\"\\,%*[^0-9]%l:\ %m        for generic C compilers
  3194. %f:%l:\ %m                for GCC
  3195. %f(%l)\ :\ %*[^:]:\ %m            old SCO C compiler (pre-OS5)
  3196. %f(%l)\ :\ %t%*[^0-9]%n:\ %m        idem, with error type and number
  3197. %f:%l:\ %m,In\ file\ included\ from\ %f:%l:,\^I\^Ifrom\ %f:%l%m
  3198.                     for GCC, with some extras
  3199.  
  3200. Note the backslash in front of a space and double quote.  It is required for
  3201. the :set command.  There are two backslashes in front of a comma, one for the
  3202. :set command and one to avoid recognizing the comma as a separator of error
  3203. formats.
  3204.  
  3205. The "%f" and "%m" conversions have to detect the end of the string.  They
  3206. should be followed by a character that cannot be in the string.  Everything
  3207. up to that character is included in the string.  Be careful: "%f%l" will
  3208. include everything up to the first '%' in the file name.  If the "%f" or "%m"
  3209. is at the end, everything up to the end of the line is included.
  3210.  
  3211. To be able to detect output from several compilers, several format patterns
  3212. may be put in 'errorformat', separated by commas (note: blanks after the comma
  3213. are ignored).  The first pattern that has a complete match is used.  If no
  3214. match is found, matching parts from the last one will be used, although the
  3215. file name is removed and the error message is set to the whole message.  If
  3216. there is a pattern that may match output from several compilers (but not in a
  3217. right way), put it after one that is more restrictive.  To include a comma in
  3218. a pattern precede it with a backslash (you have to type two in a set command).
  3219. To include a backslash itself give two backslashes (you have to type four in a
  3220. set command).
  3221.  
  3222. If a line is detected that does not completely match the 'errorformat', the
  3223. whole line is put in the error message and the entry is marked "not valid"
  3224. These lines are skipped with the ":cn" and ":cp" commands (unless there is
  3225. no valid line at all).  You can use ":cl!" to display all the error messages.
  3226.  
  3227. If the error format does not contain a file name Vim cannot switch to the
  3228. correct file.  You will have to do this by hand.
  3229.  
  3230. If you have a compiler that produces error messages that do not fit in the
  3231. format string, you could write a program that translates the error messages
  3232. into this format.  You can use this program with the ":make" command by
  3233. changing the 'makeprg' option.  For example:
  3234.     ":set mp=make\ \\\|&\ error_filter".
  3235. The backslashes before the pipe character are required to avoid it to be
  3236. recognized as a command separator.  The backslash before each space is
  3237. required for the set command.
  3238.  
  3239.                         *:make_makeprg*
  3240. The ":make" command executes the command given with the 'makeprg' option.
  3241. This is done by passing the command to the shell given with the 'shell'
  3242. option.  This works almost like typing
  3243.  
  3244.     ":!{makeprg} [arguments] {shellpipe} {errorfile}".
  3245.  
  3246. {makeprg} is the string given with the 'makeprg' option.  Any command can be
  3247. used, not just "make".  Characters '%' and '#' are expanded as usual on a
  3248. command line.  You can use "%<" to insert the current filename without
  3249. extension, for example ":set makeprg=make\ %<.o".
  3250.  
  3251. [arguments] is anything that is typed after ":make".
  3252. {shellpipe} is the 'shellpipe' option.
  3253. {errorfile} is the 'errorfile' option.
  3254.  
  3255. The 'shellpipe' option defaults to ">" for the Amiga, MS-DOS and Win32.  This
  3256. means that the output of the compiler is saved in a file and not shown on the
  3257. screen directly.  For Unix "| tee" is used.  The compiler output is shown on
  3258. the screen and saved in a file the same time.  Depending on the shell used
  3259. "|& tee" or "2>&1| tee" is the default, so stderr output will be included.
  3260.  
  3261. There are some restrictions to the Quickfix mode on the Amiga.  The
  3262. compiler only writes the first 25 errors to the errorfile (Manx's
  3263. documentation does not say how to get more).  If you want to find the others,
  3264. you will have to fix a few errors and exit the editor.  After recompiling,
  3265. up to 25 remaining errors will be found.
  3266.  
  3267. On the Amiga, if Vim was started from the compiler, the :sh and :! commands
  3268. will not work, because Vim is then running in the same process as the
  3269. compiler and these two commands may guru the machine then.
  3270.  
  3271. If you insert or delete lines, mostly the correct error location is still
  3272. found because hidden marks are used (Manx's Z editor does not do this).
  3273. Sometimes, when the mark has been deleted for some reason, the message "line
  3274. changed" is shown to warn you that the error location may not be correct.  If
  3275. you quit Vim and start again the marks are lost and the error locations may
  3276. not be correct anymore.
  3277.  
  3278.  
  3279. 5.6 Editing binary files                *edit_binary*
  3280.  
  3281. Although Vim was made to edit text files, it is possible to edit binary
  3282. files.  The "-b" Vim argument (b for binary) sets some options for
  3283. editing binary files ('binary' on, 'textwidth' to 0, 'textmode' and
  3284. 'textauto' off, 'modeline' off, 'expandtab' off).  Setting the 'binary'
  3285. option has the same effect.  Don't forget to do this before reading the file.
  3286.  
  3287. There are a few things to remember when editing binary files:
  3288. - When editing executable files the number of characters must not change.
  3289.   Use only the "R" or "r" command to change text.  Do not delete characters
  3290.   with "x" or by backspacing.
  3291. - Set the 'textwidth' option to 0.  Otherwise lines will unexpectedly be
  3292.   split in two.
  3293. - When there are not many end-of-line characters, the lines will become very
  3294.   long.  If you want to edit a line that does not fit on the screen reset the
  3295.   'wrap' option.  Horizontal scrolling is used then.  If a line becomes too
  3296.   long (more than about 32767 characters on the Amiga, much more on 32-bit
  3297.   systems, see |limits|) you cannot edit that line.  The line will be split
  3298.   when reading the file.  It is also possible that you get an "out of memory"
  3299.   error when reading the file.
  3300. - Make sure the 'textmode' and 'textauto' options are off before loading the
  3301.   file.  In 'textmode' both <CR> <NL> and <NL> are considered to end a line
  3302.   and when the file is written the <NL> will be replaced with <CR> <NL>.  The
  3303.   'modelines' option should also be off, because there may be a string like
  3304.   ":vi:" in the file that would give unpredictable results.
  3305. - <Nul> characters are shown on the screen as ^@.  You can enter them with
  3306.   "CTRL-V CTRL-@" or "CTRL-V 000" {Vi cannot handle <Nul> characters in the
  3307.   file}
  3308. - To insert a <NL> character in the file split up a line.  When writing the
  3309.   buffer to a file a <NL> will be written for the end of line.
  3310. - Vim normally appends an end-of-line character at the end of the file if
  3311.   there is none.  Setting the 'binary' option prevents this.  If you want to
  3312.   add the final end-of-line, set the 'endofline' option.  You can also read the
  3313.   value of this option to see if there was an end-of-line character for the
  3314.   last line (you cannot see this in the text).
  3315.  
  3316.  
  3317. 5.7 Automatic commands                    *autocommand*
  3318.  
  3319. You can specify commands to be executed automatically for when reading or
  3320. writing a file, when entering or leaving a buffer or window, and when exiting
  3321. Vim.  For example, 'cindent' can be set for files matching *.c, and unset
  3322. otherwise.  Autocommands can be used to edit compressed files.  These commands
  3323. are normally put in your .vimrc or .exrc file.  {All this is not in Vi}
  3324.  
  3325. WARNING: Using autocommands is very powerful, but may lead to unexpected side
  3326. effects.  Be careful not to destroy your text.
  3327. - It's a good idea to first do some testing on a copy of a file first.  For
  3328.   example: If you use autocommands to decompress a file when starting to edit
  3329.   it, make sure that the autocommands for compressing when writing work
  3330.   correctly.
  3331. - Be prepared for an error halfway through (e.g., disk full).  Vim will mostly
  3332.   be able to undo the changes to the buffer, but you may have to clean up the
  3333.   changes to other files by hand (e.g., compress a file that has been
  3334.   decompressed).
  3335. - If the BufRead* events allow you to edit a compressed file, the FileRead*
  3336.   events should do the same (to be able to do recovery in some rare cases).
  3337.   It's a good idea to use the same autocommands for the File* and Buf* events
  3338.   when possible.
  3339.  
  3340. The autocommand feature is only included if Vim has been compiled with AUTOCMD
  3341. defined.  If the output of ":version" contains "+autocmd" it is included (this
  3342. is the default), if it contains "-autocmd" then the autocommand feature
  3343. doesn't work.
  3344.  
  3345. Note: This command cannot be followed by another command, since any '|' is
  3346. considered part of the command.
  3347.  
  3348.                             *:au* *:autocmd*
  3349. :au[tocmd] {event} {pat} {cmd}
  3350.             Add {cmd} to the list of commands that will be
  3351.             automatically executed on {event} for a file matching
  3352.             {pat}.  It is not added if it is already there (as may
  3353.             happen when .vimrc is sourced again).  The order of
  3354.             entering {cmd} and {pat} is important.
  3355.  
  3356. :au[tocmd] {event} {pat}
  3357.             Show the auto-commands associated with {event} and
  3358.             {pat}.
  3359.  
  3360. :au[tocmd] * {pat}    Show the auto-commands associated with {pat} for all
  3361.             events.
  3362.  
  3363. :au[tocmd] {event}    Show all auto-commands for {event}.
  3364.  
  3365. :au[tocmd]        Show all auto-commands.
  3366.  
  3367. :au[tocmd]! {event} {pat} {cmd}
  3368.             Remove all auto-commands associated with {event} and
  3369.             {pat}, and add the command {cmd}.
  3370.  
  3371. :au[tocmd]! {event} {pat}
  3372.             Remove all auto-commands associated with {event} and
  3373.             {pat}.
  3374.  
  3375. :au[tocmd]! * {pat}    Remove all auto-commands associated with {pat} for all
  3376.             events.
  3377.  
  3378. :au[tocmd]! {event}    Remove ALL auto-commands for {event}.
  3379.  
  3380. :au[tocmd]!        Remove ALL auto-commands.
  3381.  
  3382.                             *:do* *:doautocmd*
  3383. :do[autocmd] {event} [fname]
  3384.             Apply the autocommands matching [fname] (default:
  3385.             current file name) for {event} to the current buffer.
  3386.             This can be used when the current file name does not
  3387.             match the right pattern, after changing settings, or
  3388.             to execute autocommands for a certain event.
  3389.             It's possible to use this inside an autocommand too,
  3390.             so you can base the autocommands for one extension on
  3391.             another extension.  Example:
  3392.                 :au Bufenter *.cpp so ~/.vimrc_cpp
  3393.                 :au Bufenter *.cpp doau BufEnter x.c
  3394.             Be careful for endless loops.  The nesting is limited
  3395.             to 10 levels.
  3396.  
  3397.                     *autocommand-events* *{event}*
  3398. These events are recognized.  Case is ignored, for example "BUFread" and
  3399. "bufread" can be used instead of "BufRead".
  3400.  
  3401.                             *BufNewFile*
  3402. BufNewFile            When starting to edit a file that doesn't
  3403.                 exist.  Can be used to read in a skeleton
  3404.                 file.
  3405.                             *BufReadPre*
  3406. BufReadPre            When starting to edit a new buffer, before
  3407.                 reading the file into the buffer.  Not used
  3408.                 when the file doesn't exist.
  3409.                         *BufRead* *BufReadPost*
  3410. BufRead or BufReadPost        When starting to edit a new buffer, after
  3411.                 reading the file into the buffer, before
  3412.                 executing the modelines.  This does NOT work
  3413.                 for ":r file".  Not used when the file doesn't
  3414.                 exist.
  3415.                             *FileReadPre*
  3416. FileReadPre            Before reading a file with a ":read" command.
  3417.                             *FileReadPost*
  3418. FileReadPost            After reading a file with a ":read" command.
  3419.                 Note that the '[ and '] marks are set to the
  3420.                 first and last line of the read, this can be
  3421.                 used to operate on the just read lines.
  3422.                             *FilterReadPre*
  3423. FilterReadPre            Before reading a file from a filter command.
  3424.                 The file name of the current buffer is used to
  3425.                 match with the pattern, not the name of the
  3426.                 temporary file that is the output of the
  3427.                 filter command.
  3428.                             *FilterReadPost*
  3429. FilterReadPost            After reading a file from a filter command.
  3430.                 Like FilterReadPre, the file name of the
  3431.                 current buffer is used.
  3432.                         *BufWrite* *BufWritePre*
  3433. BufWrite or BufWritePre        Before writing the whole buffer to a file.
  3434.                             *BufWritePost*
  3435. BufWritePost            After writing the whole buffer to a file
  3436.                 (should undo the commands for BufWritePre).
  3437.                             *FileWritePre*
  3438. FileWritePre            Before writing to a file, when not writing the
  3439.                 whole buffer.
  3440.                             *FileWritePost*
  3441. FileWritePost            After writing to a file, when not writing the
  3442.                 whole buffer.
  3443.                             *FileAppendPre*
  3444. FileAppendPre            Before appending to a file.
  3445.                             *FileAppendPost*
  3446. FileAppendPost            After appending to a file.
  3447.                             *FilterWritePre*
  3448. FilterWritePre            Before writing a file for a filter command.
  3449.                 The file name of the current buffer is used to
  3450.                 match with the pattern, not the name of the
  3451.                 temporary file that is the input for the
  3452.                 filter command.
  3453.                             *FilterWritePost*
  3454. FilterWritePost            After writing a file for a filter command.
  3455.                 Like FilterWritePre, the file name of the
  3456.                 current buffer is used.
  3457.                             *BufEnter*
  3458. BufEnter            After entering a buffer.  Useful for setting
  3459.                 options for a file type.  Also executed when
  3460.                 starting to edit a buffer, after the
  3461.                 BufReadPost autocommands.
  3462.                             *BufLeave*
  3463. BufLeave            Before leaving to another buffer.  Also when
  3464.                 leaving or closing the current window and the
  3465.                 new current window is not for the same buffer.
  3466.                             *WinEnter*
  3467. WinEnter            After entering another window.  Not done for
  3468.                 the first window, when Vim is just started.
  3469.                 Useful for setting the window height.
  3470.                 If the window is for another buffer, the
  3471.                 BufEnter autocommands are executed after the
  3472.                 WinEnter autocommands.
  3473.                             *WinLeave*
  3474. WinLeave            Before leaving to another window.  If the
  3475.                 window to be entered is for a different
  3476.                 buffer, the BufLeave autocommands are executed
  3477.                 before the WinLeave autocommands.
  3478.                             *VimLeave*
  3479. VimLeave            Before exiting Vim, just before writing the
  3480.                 .viminfo file.  There is no VimEnter event,
  3481.                 because you can use the .vimrc for that.
  3482.  
  3483. For READING FILES there are three possible pairs of events, only one pair is
  3484. used at a time:
  3485. BufNewFile            starting to edit a non-existant file
  3486. BufReadPre    BufReadPost    starting to edit an existing file
  3487. FilterReadPre    FilterReadPost    read the temp file with filter output
  3488. FileReadPre    FileReadPost    any other file read
  3489.  
  3490. Note that the autocommands for the *ReadPre events and all the Filter events
  3491. are not allowed to change the current buffer.  You will get an error message
  3492. if this happens anyway.  This is to prevent the file to be read into the wrong
  3493. buffer.
  3494.  
  3495. Before the *ReadPre event the '[ mark is set to the line just above where the
  3496. new lines will be inserted.
  3497. Before the *ReadPost event the '[ mark is set to the first line that was just
  3498. read, the '] mark to the last line.
  3499. Careful: '[ and '] will change when using commands that change the buffer.
  3500.  
  3501. "<afile>" can be used for the file name that is being read, in commands where
  3502. a file name is expected (where you can also use "%" for the current file
  3503. name) |:<afile>|.
  3504.  
  3505. Examples for reading compressed files:
  3506.   :autocmd! BufReadPre,FileReadPre   *.gz set bin
  3507.   :autocmd  BufReadPost,FileReadPost *.gz '[,']!gunzip
  3508.   :autocmd  BufReadPost,FileReadPost *.gz set nobin
  3509.  
  3510. NOTE: When using the examples given, any existing autocommands for the same
  3511. event/pattern combination will be removed, because of the '!'.
  3512.  
  3513. For WRITING FILES there are four possible pairs of events, only one pair is
  3514. used at a time:
  3515. BufWritePre    BufWritePost    writing the whole buffer
  3516. FilterWritePre    FilterWritePost    writing to the temp file with filter input
  3517. FileAppendPre    FileAppendPost    appending to a file
  3518. FileWritePre    FileWritePost    any other file write
  3519.  
  3520. Note that the *WritePost commands should undo any changes to the buffer that
  3521. were caused by the *WritePre commands, otherwise writing the file will have
  3522. the side effect of changing the buffer.
  3523.  
  3524. Before executing the autocommands, the buffer from where the lines are to be
  3525. written is temporarily made the current buffer.  Unless the autocommands
  3526. change the current buffer, or delete the previously current buffer, the
  3527. previously current buffer is made the current buffer again.
  3528.  
  3529. The *WritePre and *AppendPre autocommands must not delete the buffer from
  3530. where the lines are to be written.
  3531.  
  3532. Before executing the *WritePre and *AppendPre autocommands the '[ mark is set
  3533. to the first line that will be written, the '] mark to the last line.
  3534. Careful: '[ and '] will change when using commands that change the buffer.
  3535.  
  3536. "<afile>" can be used for the file name that is being written, in commands
  3537. where a file name is expected (where you can also use "%" for the current file
  3538. name) |:<afile>|.
  3539.  
  3540.                             *gzip-example*
  3541. Examples for writing compressed files:
  3542.   :autocmd! BufWritePost,FileWritePost    *.gz !mv <afile> <afile>:r
  3543.   :autocmd  BufWritePost,FileWritePost    *.gz !gzip <afile>:r
  3544.  
  3545.   :autocmd! FileAppendPre        *.gz !gunzip <afile>
  3546.   :autocmd  FileAppendPre        *.gz !mv <afile>:r <afile>
  3547.   :autocmd! FileAppendPost        *.gz !mv <afile> <afile>:r
  3548.   :autocmd  FileAppendPost        *.gz !gzip <afile>:r
  3549.  
  3550. ("<afile>:r" is the file name without the extension, see |:_%:|)
  3551.  
  3552. The commands executed for the BufNewFile, BufRead/BufReadPost, BufWritePost,
  3553. FileAppendPost and VimLeave events do not set or reset the changed flag of the
  3554. buffer.  When you decompress the buffer with the BufReadPost autocommands, you
  3555. can still exit with ":q".  When you use ":undo" in BufWritePost to undo the
  3556. changes made by BufWritePre commands, you can still do ":q" (this also makes
  3557. "ZZ" work).
  3558.  
  3559. To execute Normal mode commands from an autocommand, use the ":normal"
  3560. command.  Use with care!  If the Normal mode command is not finished, the user
  3561. needs to type characters (e.g., after ":normal m" you need to type a mark
  3562. name).
  3563.  
  3564. If you want the buffer not to be modified after changing it, reset the
  3565. 'modified' option.  This makes it possible to exit the buffer with ":q"
  3566. instead of ":q!".
  3567.  
  3568. Autocommands do not nest.  If you use ":r" or ":w" in an autocommand, the
  3569. BufRead and BufWrite autocommands are not executed for those commands.  It's
  3570. also not possible to use the ":au" command in an autocommand (that could be a
  3571. self-modifying command!).
  3572.  
  3573. There is currently no way to disable the autocommands.  If you want to write a
  3574. file without executing the autocommands for that type of file, write it under
  3575. another name and rename it with a shell command.
  3576.  
  3577. Note: When reading a file (with ":read file" or with a filter command) and the
  3578. last line in the file does not have an end-of-line character, this is
  3579. remembered.  At the next write (with ":write file" or with a filter command),
  3580. if the same line is written again as the last line in a file AND 'binary' is
  3581. set, no end-of-line character is written.  This makes a filter command on the
  3582. just read lines write the same file as was read, and makes a write command on
  3583. just filtered lines write the same file as was read from the filter.  For
  3584. example, another way to write a compressed file:
  3585.  
  3586.   :autocmd FileWritePre *.gz   set bin|'[,']!gzip
  3587.   :autocmd FileWritePost *.gz  undo|set nobin
  3588.  
  3589.                             *autocommand-pattern*
  3590. Multiple patterns may be given separated by commas.  Here are some examples:
  3591.  
  3592.   :autocmd BufRead   *        set tw=79 nocin ic infercase fo=2croq
  3593.   :autocmd BufRead   .letter    set tw=72 fo=2tcrq
  3594.   :autocmd BufEnter  .letter    set dict=/usr/lib/dict/words
  3595.   :autocmd BufLeave  .letter    set dict=
  3596.   :autocmd BufRead,BufNewFile   *.c,*.h    set tw=0 cin noic
  3597.   :autocmd BufEnter  *.c,*.h    abbr FOR for(i = 0; i < 3; i++)^M{^M}^[O
  3598.   :autocmd BufLeave  *.c,*.h    unabbr FOR
  3599.  
  3600. For makefiles (makefile, Makefile, imakefile, makefile.unix, etc.):
  3601.  
  3602.   :autocmd BufEnter  ?akefile*    set include=^s\=include
  3603.   :autocmd BufLeave  ?akefile*    set include&
  3604.  
  3605. To always start editing C files at the first function:
  3606.  
  3607.   :autocmd BufRead   *.c,*.h    1;/^{
  3608.  
  3609. Without the "1;" above, the search would start from wherever the file was
  3610. entered, rather than from the start of the file.
  3611.  
  3612. To read a skeleton file for new C files:
  3613.  
  3614.   :autocmd BufNewFile  *.c    0r ~/.skeleton.c
  3615.   :autocmd BufNewFile  *.h    0r ~/.skeleton.h
  3616.  
  3617. To insert the current date and time in a *.html file when writing it:
  3618.  
  3619. :autocmd BufWritePre,FileWritePre *.html ks|1,20g/Last modification: /normal f:lD:read !date^MkJ's
  3620.  
  3621. (to insert the ^M type CTRL-V CTRL-M)
  3622. You need to have a line "Last modification: <date time>" in the first 20 lines
  3623. of the file for this to work.  The <date time> (and anything in the same line
  3624. after it) will be replaced with the current date and time.  Explanation:
  3625.     ks        mark current position with mark 's'
  3626.     1,20g/pattern/    find lines that contain the pattern
  3627.     normal f:    find the ':'
  3628.     lD        delete the old date and time
  3629.     !date^M        read the current date and time into the next line
  3630.     kJ        Join the date and time with the previous line
  3631.     's        return the cursor to the old position
  3632.  
  3633. When entering :autocmd on the command line, completion of events and command
  3634. names may be done (with <Tab>, CTRL-D, etc.) where appropriate.
  3635.  
  3636. All matching auto-commands will be executed in the order that they were
  3637. specified.  It is recommended that your first auto-command be used for all
  3638. files by using "*" as the file pattern.  This means that you can define
  3639. defaults you like here for any settings, and if there is another matching
  3640. auto-command it will override these.  But if there is no other matching
  3641. auto-command, then at least your default settings are recovered (if entering
  3642. this file from another for which auto-commands did match).  Note that "*" will
  3643. also match files starting with ".", unlike Unix shells.
  3644.  
  3645. Normally the file pattern is tested for a match against just the tail part of
  3646. the file name (without its leading directory path), but if a path separator
  3647. character (eg '/' on Unix) appears in the pattern, then it will be tested
  3648. against the full file name.  For example:
  3649.  
  3650.   :autocmd BufRead */vim/src/*.c    set wrap
  3651.  
  3652. Note that using ~ in a file name (for home directory) doesn't work.  Use a
  3653. pattern that matches the full path name, for example "*home/user/.cshrc".
  3654.  
  3655.  
  3656. 6. Cursor motions                    *cursor_motions*
  3657. =================
  3658.  
  3659. These commands move the cursor position.  If the new position is off of the
  3660. screen, the screen is scrolled to show the cursor (see also 'scrolljump' and
  3661. 'scrolloff' options).
  3662.  
  3663.                             *operator*
  3664. The motion commands can be used after an operator command, to have the command
  3665. operate on the text that was moved over.  That is the text between the cursor
  3666. position before and after the motion.  Operators are generally used to delete
  3667. or change text.  The following operators are available:
  3668.     |c|    c    change
  3669.     |d|    d    delete
  3670.     |y|    y    yank into register (does not change the text)
  3671.     |~|    ~    swap case (only if 'tildeop' is set)
  3672.     |g~|    g~    swap case
  3673.     |gu|    gu    make lower case
  3674.     |gU|    gU    make upper case
  3675.     |!|    !    filter through an external program
  3676.     |=|    =    filter through 'equalprg' or C-indenting if empty
  3677.     |Q|    Q    text formatting (obsolete)
  3678.     |gq|    gq    text formatting
  3679.     |>|    >    shift right
  3680.     |<|    <    shift left
  3681. If the motion includes a count and the operator also had a count before it,
  3682. the two counts are multiplied.  For example: "2d3w" deletes six words.
  3683.     The operator either affects whole lines, or the characters between the
  3684. start and end position.  Generally, motions that move between lines affect
  3685. lines (are linewise), and motions that move within a line affect characters.
  3686. However, there are some exceptions.
  3687.     A character motion is either inclusive or exclusive. When inclusive,
  3688. the start and end position of the motion are included in the operation.
  3689. When exclusive, the last character towards the end of the buffer is not
  3690. included.  Linewise motions always include the start and end position.
  3691.     Which motions are linewise, inclusive or exclusive is mentioned
  3692. below.  There are however, two general exceptions:
  3693. 1. If the motion is exclusive and the end of the motion is in column 1, the
  3694.    end of the motion is moved to the end of the previous line and the motion
  3695.    becomes inclusive.  Example: "}" ends at the first line after a paragraph,
  3696.    but "V}" will not include that line.
  3697. 2. If the motion is exclusive, the end of the motion is in column 1 and the
  3698.    start of the motion was at or before the first non-blank in the line, the
  3699.    motion becomes linewise.  Example: If a paragraph begins with some blanks
  3700.    and you do "d}" while standing on the first non-blank, all the lines of
  3701.    the paragraph are deleted, including the blanks.  If you do a put now, the
  3702.    deleted lines will be inserted below the cursor position.
  3703.  
  3704. Instead of first giving the operator and then a motion you can use Visual
  3705. mode: mark the start of the text with "v", move the cursor to the end of the
  3706. text that is to be affected and then hit the operator.  The text between the
  3707. start and the cursor position is highlighted, so you can see what text will
  3708. be operated upon.  This allows much more freedom, but requires more key
  3709. strokes and has limited redo functionality.  See the chapter on Visual mode
  3710. |Visual_mode|.
  3711.  
  3712. If you want to know where you are in the file use the "CTRL-G" command
  3713. |CTRL-G| or the "g CTRL-G command |g_CTRL-G|.  If you set the 'ruler' option,
  3714. the cursor position is continuously shown in the status line (which slows down
  3715. Vim a little).
  3716.  
  3717. NOTE: Experienced users prefer the hjkl keys because they are always right
  3718. under their fingers.  Beginners often prefer the arrow keys, because they
  3719. do not know what the hjkl keys do.  The mnemonic value of hjkl is clear from
  3720. looking at the keyboard.  Think of j as an arrow pointing downwards.
  3721.  
  3722.  
  3723. 6.1 Left-right motions                    *left_right_motions*
  3724.  
  3725. h        or                    *h*
  3726. <Left>        or                    *<Left>*
  3727. CTRL-H        or                    *CTRL-H* *<BS>*
  3728. <BS>            [count] characters to the left (exclusive).
  3729.             Note: If you prefer <BS> to delete a character, use
  3730.             the mapping:
  3731.                 :map CTRL-V<BS>        X
  3732.             (to enter "CTRL-V<BS>" type the CTRL-V key, followed
  3733.             by the <BS> key)
  3734.             See |:fixdel| if the <BS> key does not do what you
  3735.             want.
  3736.  
  3737. l        or                    *l*
  3738. <Right>        or                    *<Right>* *<Space>*
  3739. <Space>            [count] characters to the right (exclusive).
  3740.  
  3741.                             *0*
  3742. 0            To the first character of the line (exclusive).  When
  3743.             moving up or down, stay in same screen column (if
  3744.             possible).
  3745.  
  3746.                             *<Home>* *<kHome>*
  3747. <Home>            To the first character of the line (exclusive).  When
  3748.             moving up or down, stay in same text column (if
  3749.             possible).  Works like "1|", which differs from "0"
  3750.             when the line starts with a <Tab>.  {not in Vi}
  3751.  
  3752.                             *^*
  3753. ^            To the first non-blank character of the line
  3754.             (exclusive).
  3755.  
  3756.                             *$* *<End>* *<kEnd>*
  3757. $  or <End>        To the end of line and [count - 1] lines downward
  3758.             (inclusive).
  3759.  
  3760.                             *g0* *g<Home>*
  3761. g0 or g<Home>        When lines wrap ('wrap on): To the first character of
  3762.             the screen line (exclusive).  Differs from "0" when a
  3763.             line is wider than the screen.
  3764.             When lines don't wrap ('wrap' off): To the leftmost
  3765.             character of the current line that is on the screen.
  3766.             Differs from "0" when the first character of the line
  3767.             is not on the screen.  {not in Vi}
  3768.  
  3769.                             *g^*
  3770. g^            When lines wrap ('wrap' on): To the first non-blank
  3771.             character of the screen line (exclusive).  Differs
  3772.             from "^" when a line is wider than the screen.
  3773.             When lines don't wrap ('wrap' off): To the leftmost
  3774.             non-blank character of the current line that is on the
  3775.             screen.  Differs from "^" when the first non-blank
  3776.             character of the line is not on the screen.  {not in
  3777.             Vi}
  3778.  
  3779.                             *g$* *g<End>*
  3780. g$ or g<End>        When lines wrap ('wrap' on): To the last character of
  3781.             the screen line and [count - 1] screen lines downward
  3782.             (inclusive).  Differs from "$" when a line is wider
  3783.             than the screen.
  3784.             When lines don't wrap ('wrap' off): To the righmost
  3785.             character of the current line that is visible on the
  3786.             screen.  Differs from "$" when the last character of
  3787.             the line is not on the screen or when a count is used.
  3788.             {not in Vi}
  3789.  
  3790.                             *bar*
  3791. |            To screen column [count] in the current line
  3792.             (exclusive).
  3793.  
  3794.                             *f*
  3795. f{char}            To [count]'th occurrence of {char} to the right.  The
  3796.             cursor is placed on {char} (inclusive).
  3797.  
  3798.                             *F*
  3799. F{char}            To the [count]'th occurrence of {char} to the left.
  3800.             The cursor is placed on {char} (inclusive).
  3801.  
  3802.                             *t*
  3803. t{char}            Till before [count]'th occurrence of {char} to the
  3804.             right.  The cursor is placed on the character left of
  3805.             {char} (inclusive).
  3806.  
  3807.                             *T*
  3808. T{char}            Till after [count]'th occurrence of {char} to the
  3809.             left.  The cursor is placed on the character right of
  3810.             {char} (inclusive).
  3811.  
  3812.                             *;*
  3813. ;            Repeat latest f, t, F or T [count] times.
  3814.  
  3815.                             *,*
  3816. ,            Repeat latest f, t, F or T in opposite direction
  3817.             [count] times.
  3818.  
  3819. These commands move the cursor to the specified column in the current line.
  3820. They stop at the first column and at the end of the line, except "$", which
  3821. may move to one of the next lines.  See 'whichwrap' option to make some of the
  3822. commands move accross line boundaries.
  3823.  
  3824.  
  3825. 6.2 Up-down motions                    *up_down_motions*
  3826.  
  3827. k        or                    *k*
  3828. <Up>        or                    *<Up>* *CTRL-P*
  3829. CTRL-P            [count] lines upward (linewise).
  3830.  
  3831. j        or                    *j*
  3832. <Down>        or                    *<Down>*
  3833. CTRL-J        or                    *CTRL-J*
  3834. <NL>        or                    *<NL>* *CTRL-N*
  3835. CTRL-N            [count] lines downward (linewise).
  3836.  
  3837. gk        or                    *gk* *g<Up>*
  3838. g<Up>            [count] display lines upward (exclusive).  Differs
  3839.             from 'k' when lines wrap.  {not in Vi}
  3840.  
  3841. gj        or                    *gj* *g<Down>*
  3842. g<Down>            [count] display lines downward (exclusive).  Differs
  3843.             from 'j' when lines wrap.  {not in Vi}
  3844.  
  3845.                             *-*
  3846. -  <minus>        [count] lines upward, on the first non-blank
  3847.             character (linewise).
  3848.  
  3849. +        or                    *+*
  3850. CTRL-M        or                    *CTRL-M* *<CR>*
  3851. <CR>            [count] lines downward, on the first non-blank
  3852.             character (linewise).
  3853.  
  3854.                             *_*
  3855. _  <underscore>        [count] - 1 lines downward, on the first non-blank
  3856.             character (linewise).
  3857.  
  3858. <C-End>        or                    *G* *<C-End>*
  3859. G            Goto line [count], default last line, on the first
  3860.             non-blank character (linewise).  If 'startofline' not
  3861.             set, keep the same column.
  3862.  
  3863. <C-Home>    or                    *gg* *<C-Home>*
  3864. gg            Goto line [count], default first line, on the first
  3865.             non-blank character (linewise).  If 'startofline' not
  3866.             set, keep the same column.
  3867.  
  3868. :[range]        Set the cursor on the (last) specified line number
  3869.             (cannot be used with an operator).
  3870.  
  3871.                             *N%*
  3872. {count}%        Go to {count} percentage in the file, on the first
  3873.             non-blank in the line (linewise).  To compute the new
  3874.             line number this formula is used: {count} *
  3875.             number-of-lines / 100.  See also 'startofline'
  3876.             option.  {not in Vi}
  3877.  
  3878. These commands move to the specified line.  They stop when reaching the first
  3879. or the last line.  The first two commands put the cursor in the same column
  3880. (if possible) as it was after the last command that changed the column,
  3881. except after the "$" command, then the cursor will be put on the last
  3882. character of the line.
  3883.  
  3884.  
  3885. 6.3 Word motions                    *word_motions*
  3886.  
  3887. <S-Right>    or                    *<S-Right>* *w*
  3888. w            [count] words forward (exclusive).
  3889.  
  3890.                             *W*
  3891. W            [count] WORDS forward (exclusive).
  3892.  
  3893.                             *e*
  3894. e            Forward to the end of word [count] (inclusive).
  3895.  
  3896.                             *E*
  3897. E            Forward to the end of WORD [count] (inclusive).
  3898.  
  3899. <S-Left>    or                    *<S-Left>* *b*
  3900. b            [count] words backward (exclusive).
  3901.  
  3902.                             *B*
  3903. B            [count] WORDS backward (exclusive).
  3904.  
  3905.                             *ge*
  3906. ge            Backward to the end of word [count] (inclusive).
  3907.  
  3908.                             *gE*
  3909. gE            Backward to the end of WORD [count] (inclusive).
  3910.  
  3911. These commands move over words or WORDS.
  3912.                             *word*
  3913. A word consists of a sequence of letters, digits and underscores, or a
  3914. sequence of other non-blank characters, separated with white space (spaces,
  3915. tabs, end of line).  This can be changed with the 'iskeyword' option.
  3916.                             *WORD*
  3917. A WORD consists of a sequence of non-blank characters, separated with white
  3918. space.  An empty line is also considered to be a word and a WORD.
  3919.  
  3920. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
  3921. on a non-blank.  This is because "cw" is interpreted as change-word, and a
  3922. word does not include the following white space.  {Vi: "cw" when on a blank
  3923. followed by other blanks changes only the first blank; this is probably a
  3924. bug, because "dw" deletes all the blanks}
  3925.  
  3926. Another special case: When using the "w" motion in combination with an
  3927. operator and the last word moved over is at the end of a line, the end of
  3928. that word becomes the end of the operated text, not the first word in the
  3929. next line.
  3930.  
  3931. The original Vi implementation of "e" is buggy.  For example, the "e" command
  3932. will stop on the first character of a line if the previous line was empty.
  3933. But when you use "2e" this does not happen.  In Vim "ee" and "2e" are the
  3934. same, which is more logical.  However, this causes a small incompatibility
  3935. between Vi and Vim.
  3936.  
  3937.  
  3938. 6.4 Text object motions                    *object_motions*
  3939.  
  3940.                             *(*
  3941. (            [count] sentences backward (exclusive).
  3942.  
  3943.                             *)*
  3944. )            [count] sentences forward (exclusive).
  3945.  
  3946.                             *{*
  3947. {            [count] paragraphs backward (exclusive).
  3948.  
  3949.                             *}*
  3950. }            [count] paragraphs forward (exclusive).
  3951.  
  3952.                             *]]*
  3953. ]]            [count] sections forward or to the next '{' in the
  3954.             first column.  When used after an operator, then the
  3955.             '}' in the first column.  (linewise).
  3956.  
  3957.                             *][*
  3958. ][            [count] sections forward or to the next '}' in the
  3959.             first column (linewise).
  3960.  
  3961.                             *[[*
  3962. [[            [count] sections backward or to the previous '{' in
  3963.             the first column (linewise).
  3964.  
  3965.                             *[]*
  3966. []            [count] sections backward or to the previous '}' in
  3967.             the first column (linewise).
  3968.  
  3969. These commands move over three kinds of text objects.
  3970.  
  3971.                             *sentence*
  3972. A sentence is defined as ending at a '.', '!' or '?' followed by either the
  3973. end of a line, or by a space.  {Vi: two spaces} Any number of closing ')',
  3974. ']', '"' and ''' characters my appear after the '.', '!' or '?' before the
  3975. spaces or end of line.  A paragraph and section boundary is also a sentence
  3976. boundary.  The definition of a sentence cannot be changed.
  3977.  
  3978.                             *paragraph*
  3979. A paragraph begins after each empty line, and also at each of a set of
  3980. paragraph macros, specified by the pairs of characters in the 'paragraphs'
  3981. option.  The default is "IPLPPPQPP LIpplpipbp", which corresponds to the
  3982. macros ".IP", ".LP", etc.  (These are nroff macros, so the dot must be in the
  3983. first column).  A section boundary is also a paragraph boundary.  Note that
  3984. this does not include a '{' or '}' in the first column.
  3985.  
  3986.                             *section*
  3987. A section begins after a form-feed (<C-L>) in the first column and at each of
  3988. a set of section macros, specified by the pairs of characters in the
  3989. 'sections' option.  The default is "SHNHH HUnhsh".
  3990.  
  3991. The "]" and "[" commands stop at the '{' or <}" in the first column.  This is
  3992. useful to find the start or end of a function in a C program.  Note that the
  3993. first character of the command determines the search direction and the
  3994. second character the type of brace found.
  3995.  
  3996.  
  3997. 6.5 Text object selection                *object_select*
  3998.  
  3999.                             *v_a*
  4000. a            select [count] words (see |word|).  {not in Vi}
  4001.  
  4002.                             *v_A*
  4003. A            select [count] WORDS (see |WORD|).  {not in Vi}
  4004.  
  4005.                             *v_s*
  4006. s            select [count] sentences (see |sentence|).  {not in Vi}
  4007.  
  4008.                             *v_p*
  4009. p            select [count] paragraphs (see |paragraph|).  {not in
  4010.             Vi}
  4011.  
  4012.                             *v_S*
  4013. S            select [count] blocks, from "[count] [(" to the
  4014.             matching ')' (see |[(|).  {not in Vi}
  4015.  
  4016.                             *v_P*
  4017. P            select [count] blocks, from "[count] [{" to the
  4018.             matching '}' (see |[{|).  {not in Vi}
  4019.  
  4020. These object selection commands can only be used in Visual mode and after an
  4021. operator.
  4022.  
  4023. When used after an operator:
  4024. For non-block objects:
  4025.     The operator applies to the object and the white space after the
  4026.     object.  If there is no white space after the object or when the
  4027.     cursor was in the white space before the object, the white space
  4028.     before the object is included.
  4029. For a block object:
  4030.     The operator applies to the block excluding the surrounding braces.
  4031.     If the cursor was on one of the braces (or on the indent before '{' or
  4032.     '}) they are included.
  4033.  
  4034. When used in Visual mode:
  4035. When start and end of the Visual area are the same (just after typing "v"):
  4036.     One object is selected, the same as for using an operator.
  4037. When start and end of the Visual area are not the same:
  4038.     For non-block objects the area is extended by one object or the white
  4039.     space up to the next object.  The direction in which this happens
  4040.     depends on which side of the Visual area the cursor is.  For the block
  4041.     objects the block is extended one level outwards.
  4042.  
  4043. For illustration, here is a list of delete commands, grouped from small to big
  4044. objects.  Note that for a single character and a whole line the existing vi
  4045. movement commands are used.
  4046.     "dl"    delete character (alias: "x")        |dl|
  4047.     "da"    delete word                *da*
  4048.     "dA"    delete WORD (see |WORD|)        *dA*
  4049.     "dd"    delete line                |dd|
  4050.     "ds"    delete sentence                *ds*
  4051.     "dS"    delete '(' ')' block            *dS*
  4052.     "dp"    delete paragraph            *dp*
  4053.     "dP"    delete '{' '}' block            *dP*
  4054.  
  4055. Note the difference between using a movement command and an object.  The
  4056. movement command operates from here (cursor position) to where the movement
  4057. takes us.  When using an object the whole object is operated upon, no matter
  4058. where on the object the cursor is.  For example, compare "dw" and "da": "dw"
  4059. deletes from the cursor position to the start of the next word, "da" deletes
  4060. the word under the cursor and the space after or before it.
  4061.  
  4062.  
  4063. 6.6 Pattern searches                    *pattern_searches*
  4064.  
  4065.                             */*
  4066. /{pattern}[/]<CR>    Search forward for the [count]'th occurrence of
  4067.             {pattern} (exclusive).
  4068.  
  4069. /{pattern}/{offset}<CR>    Search forward for the [count]'th occurrence of
  4070.             {pattern} and go {offset} lines up or down (see
  4071.             below).  (linewise).
  4072.  
  4073.                             */<CR>*
  4074. /<CR>            Search forward for the [count]'th latest used
  4075.             pattern with latest used {offset}.
  4076.  
  4077. //{offset}<CR>        Search forward for the [count]'th latest used
  4078.             pattern with new {offset}.  If {offset} is empty no
  4079.             offset is used.
  4080.  
  4081.                             *?*
  4082. ?{pattern}[?]<CR>    Search backward for the [count]'th previous
  4083.             occurrence of {pattern} (exclusive).
  4084.  
  4085. ?{pattern}?{offset}<CR>    Search backward for the [count]'th previous
  4086.             occurrence of {pattern} and go {offset} lines up or
  4087.             down (see below) (linewise).
  4088.  
  4089.                             *?<CR>*
  4090. ?<CR>            Search backward for the [count]'th latest used
  4091.             pattern with latest used {offset}.
  4092.  
  4093. ??{offset}<CR>        Search backward for the [count]'th latest used
  4094.             pattern with new {offset}.  If {offset} is empty no
  4095.             offset is used.
  4096.  
  4097.                             *n*
  4098. n            Repeat the latest "/" or "?" [count] times.  {Vi: no
  4099.             count}
  4100.  
  4101.                             *N*
  4102. N            Repeat the latest "/" or "?" [count] times in
  4103.             opposite direction.  {Vi: no count}
  4104.  
  4105.                             *star*
  4106. *            Search forward for the [count]'th occurrence of the
  4107.             word nearest to the cursor.  The word used for the
  4108.             search is the first of:
  4109.                 1. the keyword under the cursor |'iskeyword'|
  4110.                 2. the first keyword after the cursor, in the
  4111.                    current line
  4112.                 3. the non-blank word under the cursor
  4113.                 4. the first non-blank word after the cursor,
  4114.                    in the current line
  4115.             Only whole keywords are searched for, like with the
  4116.             command "/\<keyword\>".  (exclusive)  {not in Vi}
  4117.  
  4118.                             *#*
  4119. #            Same as "*", but search backward.  The English pound
  4120.             sign (character 163) also works.  If the "#" key works
  4121.             as backspace, try using "stty erase <BS>" before
  4122.             starting Vim (<BS> is CTRL-H or a real backspace).
  4123.             {not in Vi}
  4124.  
  4125.                             *gstar*
  4126. g*            Like "*", but don't put "\<" and "\>" around the word.
  4127.             This makes the search also find matches that are not a
  4128.             whole word.  {not in Vi}
  4129.  
  4130.                             *g#*
  4131. g#            Like "#", but don't put "\<" and "\>" around the word.
  4132.             This makes the search also find matches that are not a
  4133.             whole word.  {not in Vi}
  4134.  
  4135.                             *gd*
  4136. gd            Goto local Declaration.  When the cursor is on a local
  4137.             variable, this command will jump to its declaration.
  4138.             First a search is made for the end of the previous
  4139.             function, just like "[]".  If it is not found the
  4140.             search stops in line 1.  From this position a search is
  4141.             made for the keyword under the cursor, like with "*",
  4142.             but lines that look like a comment are ignored (see
  4143.             'comments' option).  Note that this is not guaranteed
  4144.             to work, Vim does not really check the syntax, it only
  4145.             searches for a match with the keyword.  If included
  4146.             files also need to be searched use the commands listed
  4147.             in |include_search|.  {not in Vi}
  4148.  
  4149.                             *gD*
  4150. gD            Goto global Declaration.  When the cursor is on a
  4151.             global variable that is defined in the file, this
  4152.             command will jump to its declaration.  This works just
  4153.             like "gd", except that the search for the keyword
  4154.             always starts in line 1.  {not in Vi}
  4155.  
  4156.                             *CTRL-C*
  4157. CTRL-C            Interrupt current (search) command.  Use CTRL-Break on
  4158.             MS-DOS |CTRL-Break|.
  4159.  
  4160. While typing the search pattern the current match will be shown if the
  4161. 'incsearch' option is on.  Remember that you still have to finish the search
  4162. command with <CR> to actually position the cursor at the displayed match.  Or
  4163. use <Esc> to abandon the search.
  4164.  
  4165. These commands search for the specified pattern.  With "/" and "?" an
  4166. additional offset may be given.  There are two types of offsets: line offsets
  4167. and character offsets.  {the character offsets are not in Vi}
  4168.  
  4169.                     *search_offset* *{offset}*
  4170. The offset gives the cursor position relative to the found match:
  4171.     [num]    [num] lines downwards, in column 1
  4172.     +[num]    [num] lines downwards, in column 1
  4173.     -[num]    [num] lines upwards, in column 1
  4174.     e[+num]    [num] characters to the right of the end of the match
  4175.     e[-num]    [num] characters to the left of the end of the match
  4176.     s[+num]    [num] characters to the right of the start of the match
  4177.     s[-num]    [num] characters to the left of the start of the match
  4178.     b[+num]    [num] characters to the right of the start (begin) of the match
  4179.     b[-num]    [num] characters to the left of the start (begin) of the match
  4180.  
  4181. If a '-' or '+' is given but [num] is omitted, a count of one will be used.
  4182. When including an offset with 'e', the search becomes inclusive (the
  4183. character the cursor lands on is included in operations).
  4184.  
  4185. Examples:
  4186.  
  4187. pattern            cursor position
  4188. /test/+1        one line below "test", in column 1
  4189. /test/e            on the last t of "test"
  4190. /test/s+2        on the 's' of "test"
  4191. /test/b-3        three characters before "test"
  4192.  
  4193. If one of these commands is used after an operator, the characters between
  4194. the cursor position before and after the search is affected.  However, if a
  4195. line offset is given, the whole lines between the two cursor positions are
  4196. affected.
  4197.  
  4198.                             *//;*
  4199. A very special offset is ';' followed by another search command.  For example:
  4200.  
  4201.     /test 1/;/test
  4202.     /test.*/+1;?ing?
  4203.  
  4204. The first one first finds the next occurence of "test 1", and then the first
  4205. occurence of "test" after that.
  4206.  
  4207. This is like executing two search commands after each other, except that:
  4208. - It can be used as a single motion command after an operator.
  4209. - The direction for a following "n" or "N" command comes from the first
  4210.   search command.
  4211. - When an error occurs the cursor is not moved at all.
  4212.  
  4213. The last used <pattern> and <offset> are remembered.  They can be used to
  4214. repeat the search, possibly in another direction or with another count.  Note
  4215. that two patterns are remembered: one for 'normal' search commands and one
  4216. for the substitute command ":s".  Each time an empty <pattern> is given, the
  4217. previously used <pattern> is used.
  4218.  
  4219. In Vi the ":tag" command sets the last search pattern when the tag is searched
  4220. for.  In Vim this is not done, the previous search pattern is still remembered,
  4221. unless the 't' flag is present in 'cpoptions'.  The search pattern is always
  4222. put in the search history.
  4223.  
  4224. If the 'wrapscan' option is on (which is the default), searches wrap around
  4225. the end of the buffer.  If 'wrapscan' is not set, the backward search stops
  4226. at the beginning and the forward search stops at the end of the buffer.  If
  4227. 'wrapscan' is set and the pattern was not found the error message "pattern
  4228. not found" is given, and the cursor will not be moved.  If 'wrapscan' is not
  4229. set the message becomes "search hit BOTTOM without match" when searching
  4230. forward, or "search hit TOP without match" when searching backward.  If
  4231. wrapscan is set and the search wraps around the end of the file the message
  4232. "search hit TOP, continuing at BOTTOM" or "search hit BOTTOM, continuing at
  4233. TOP" is given when searching backwards or forwards respectively.  This can be
  4234. switched off by setting the 's' flag in the 'shortmess' option.  The highlight
  4235. method 'w' is used for this message (default: standout).
  4236.  
  4237.                             *search_range*
  4238. You cannot limit the search command "/" to a certain range of lines.  A trick
  4239. to do this anyway is to use the ":substitute" command with the 'c' flag.
  4240. Example:
  4241.     :.,300s/Pattern//gc
  4242. This command will search from the cursor position until line 300 for
  4243. "Pattern".  At the match, you will be asked to type a character.  Type 'q' to
  4244. stop at this match, type 'n' to find the next match.
  4245.  
  4246. The "*", "#", "g*" and "g#" commands look for a word near the cursor in this
  4247. order, the first one that is found is used:
  4248. - The keyword currently under the cursor.
  4249. - The first keyword to the right of the cursor, in the same line.
  4250. - The WORD currently under the cursor.  
  4251. - The first WORD to the right of the cursor, in the same line.
  4252. The keyword may only contain letters and characters in 'iskeyword'.
  4253. The WORD may contain any non-blanks (<Tab>s and/or <Space>s).
  4254. Note that if you type with ten fingers, the characters are easy to remember:
  4255. the "#" is under your left hand middle finger (search to the left and up) and
  4256. the "*" is under your right hand middle finger (search to the right and down).
  4257.  
  4258.  
  4259. The definition of a pattern:        *search_pattern* *pattern* *[pattern]*
  4260.                     *regular_expression*
  4261.  
  4262. Patterns may contain special characters, depending on the setting of the
  4263. 'magic' option.
  4264.  
  4265.                             */bar* */\bar*
  4266. 1. A pattern is one or more branches, separated by "\|".  It matches anything
  4267.    that matches one of the branches.  Example: "foo\|beep" matches "foo" and
  4268.    "beep".
  4269.  
  4270. 2. A branch is one or more pieces, concatenated.  It matches a match for the
  4271.    first, followed by a match for the second, etc.  Example: "foo[0-9]beep",
  4272.    first match "foo", then a digit and then "beep".
  4273.  
  4274. 3. A piece is an atom, possibly followed by:
  4275.       magic   nomagic
  4276.                             */star* */\star*
  4277.     *    \*    matches 0 or more of the preceding atom
  4278.                             */\+*
  4279.     \+    \+    matches 1 or more of the preceding atom {not in Vi}
  4280.                             */\=*
  4281.     \=    \=    matches 0 or 1 of the preceding atom {not in Vi}
  4282.  
  4283.     Examples:
  4284.        .*    .\*    matches anything, also empty string
  4285.        ^.\+$    ^.\+$    matches any non-empty line
  4286.        foo\=    foo\=    matches "fo" and "foo"
  4287.  
  4288.  
  4289. 4. An atom can be:
  4290.    - One of these five:
  4291.       magic   nomagic
  4292.     ^    ^    at beginning of pattern, matches start of line    */^*
  4293.     $    $    at end of pattern or in front of "\|",        */$*
  4294.             matches end of line
  4295.     .    \.    matches any single character          */.* */\.*
  4296.     \<    \<    matches the beginning of a word            */\<*
  4297.     \>    \>    matches the end of a word            */\>*
  4298.     \i    \i    matches any identifier character (see        */\i*
  4299.             'isident' option) {not in Vi}
  4300.     \I    \I    like "\i", but excluding digits {not in Vi}    */\I*
  4301.     \k    \k    matches any keyword character (see        */\k*
  4302.             'iskeyword' option) {not in Vi}
  4303.     \K    \K    like "\k", but excluding digits {not in Vi}    */\K*
  4304.     \f    \f    matches any file name character (see        */\f*
  4305.             'isfname' option) {not in Vi}
  4306.     \F    \F    like "\f", but excluding digits {not in Vi}    */\F*
  4307.     \p    \p    matches any printable character (see        */\p*
  4308.             'isprint' option) {not in Vi}
  4309.     \P    \P    like "\p", but excluding digits {not in Vi}    */\P*
  4310.     \e    \e    <Esc>                        */\e*
  4311.     \t    \t    <Tab>                        */\t*
  4312.     \r    \r    <CR>                        */\r*
  4313.     \b    \b    <BS>                        */\b*
  4314.     ~    \~    matches the last given substitute string    */~* */\~*
  4315.     \(\)    \(\)    A pattern enclosed by escaped parentheses      */\(\)*
  4316.             (e.g., "\(^a\)") matches that pattern
  4317.     x    x    A single character, with no special meaning,
  4318.             matches itself
  4319.     \x    \x    A backslash followed by a single character,    */\*
  4320.             with no special meaning, matches the single
  4321.             character
  4322.     []    \[]    A range. This is a sequence of characters    */[]*
  4323.             enclosed in "[]" or "\[]".  It matches any    */\[]*
  4324.             single character from the sequence.  E.g., "[xyz]"
  4325.             matches any 'x', 'y' or 'z'.
  4326.             - If the sequence begins with "^", it matches any
  4327.               single character NOT in the sequence: "[^xyz]"
  4328.               matches anything but 'x', 'y' and 'z'.
  4329.             - If two characters in the sequence are separated by
  4330.               '-', this is shorthand for the full list of ASCII
  4331.               characters between them.  E.g., "[0-9]" matches any
  4332.               decimal digit.
  4333.             - To include a literal ']', '^', '-' or '\' in the
  4334.               sequence, put a backslash before it: "[xyz\]]",
  4335.               "[\^xyz]", "[xy\-z]" and "[xyz\\]".
  4336.               For ']' you can also make it the first character
  4337.               (following a possible "^"):  "[]xyz]" or "[^]xyz]"
  4338.               {not in Vi}.
  4339.               For '-' you can also make it the first or last
  4340.               character: "[-xyz]", "[^-xyz]" or "[xyz-]".
  4341.               For '\' you can also let it be followed by any
  4342.               character that's not in "^]-\etrb".  "[\xyz]"
  4343.               matches '\', 'x', 'y' and 'z'.  It's better to use
  4344.               "\\" though, future expansions may use other
  4345.               characters after '\'.
  4346.             - The following translations are accepted when the 'l'
  4347.               flag is not included in 'cpoptions' {not in Vi}:
  4348.                 \e    <Esc>
  4349.                 \t    <Tab>
  4350.                 \r    <CR>
  4351.                 \b    <BS>
  4352.  
  4353. If the 'ignorecase' option is on, the case of letters is ignored.
  4354.  
  4355. It is impossible to have a pattern that contains a line break (Sorry!).
  4356.  
  4357. Examples:
  4358. ^beep(            Probably the start of the C function "beep".
  4359.  
  4360. [a-zA-Z]$        Any alphabetic character at the end of a line.
  4361.  
  4362. \<\I\i*        or
  4363. \(^\|[^a-zA-Z0-9_]\)[a-zA-Z_][a-zA-Z0-9_]*
  4364.             A C identifier (will stop in front of it).
  4365.  
  4366. \(\.$\|\. \)        A period followed by end-of-line or a space.
  4367.             Note that "\(\. \|\.$\)" does not do the same,
  4368.             because '$' is not end-of-line in front of '\)'.
  4369.             This was done to remain Vi-compatible.
  4370.  
  4371. [.!?][])"']*\($\|[ ]\)    A search pattern that finds the end of a sentence,
  4372.             with almost the same definition as the ")" command.
  4373.  
  4374. Technical detail:
  4375. <Nul> characters in the file are stored as <NL> in memory.  In the display
  4376. they are shown as "^@".  The translation is done when reading and writing
  4377. files.  To match a <Nul> with a search pattern you can just enter CTRL-@ or
  4378. "CTRL-V 000".  This is probably just what you expect.  Internally the
  4379. character is replaced with a <NL> in the search pattern.  What is unusual is
  4380. that typing CTRL-V CTRL-J also inserts a <NL>, thus also searches for a
  4381. <Nul> in the file.  {Vi cannot handle <Nul> characters in the file at all}
  4382.  
  4383.  
  4384. 6.7 Various motions                *various_motions*
  4385.  
  4386.                         *m*
  4387. m<a-zA-Z>        Set mark <a-zA-Z> at cursor position (does not move
  4388.             the cursor, this is not a motion command).
  4389.  
  4390.                         *:ma* *:mark*
  4391. :[range]ma[rk] <a-zA-Z>    Set mark <a-zA-Z> at last line number in [range],
  4392.             column 0.  Default is cursor line.
  4393.  
  4394.                         *:k*
  4395. :[range]k<a-zA-Z>    Same as :mark, but the space before the mark name can
  4396.             be omitted.
  4397.  
  4398.                         *'* *'a*
  4399. '<a-z>            To the first non-blank character on the line with
  4400.             mark <a-z> (linewise).
  4401.                         *'A* *'0*
  4402. '<A-Z0-9>        To the first non-blank character on the line with
  4403.             mark <A-Z0-9> in the correct file (linewise when in
  4404.             same file, not a motion command when in other file).
  4405.             {not in Vi}
  4406.  
  4407.                         *`* *`a*
  4408. `<a-z>            To the mark <a-z> (exclusive).
  4409.                         *`A* *`0*
  4410. `<A-Z0-9>        To the mark <A-Z0-9> in the correct file (exclusive
  4411.             when in same file, not a motion command when in
  4412.             other file).  {not in Vi}
  4413.  
  4414.                         *:marks*
  4415. :marks            List all the current marks (not a motion command).
  4416.             {not in Vi}
  4417.  
  4418. :marks {arg}        List the marks that are mentioned in {arg} (not a
  4419.             motion command).  For example:
  4420.                 :marks aB
  4421.             to list marks 'a' and 'B'.  {not in Vi}
  4422.  
  4423. A mark is not visible in any way.  It is just a position in the file that is
  4424. remembered.  Do not confuse marks with named registers, they are totally
  4425. unrelated.
  4426.  
  4427. 'a - 'z        lowercase marks, valid within one file
  4428. 'A - 'Z        uppercase marks, also called file marks, valid between files
  4429. '0 - '9        numbered marks, set from .viminfo file
  4430.  
  4431. Lowercase marks 'a to 'z are remembered as long as the file remains in the
  4432. buffer list.  If you remove the file from the buffer list, change a character
  4433. in a line or delete a line that contains a mark, that mark is erased.
  4434. Lowercase marks can be used in combination with operators.  For example: "d't"
  4435. deletes the lines from the cursor position to mark 't'.  Hint: Use mark 't' for
  4436. Top, 'b' for Bottom, etc..  Lowercase marks are restored when using undo and
  4437. redo.
  4438.  
  4439. Uppercase marks 'A to 'Z include the file name.  {Vi: no uppercase marks} You
  4440. can use them to jump from file to file.  You can only use an uppercase mark
  4441. with an operator if the mark is in the current file.  The line number of the
  4442. mark remains correct, even if you insert/delete lines or edit another file for
  4443. a moment.  When the 'viminfo' option is not empty, uppercase marks are kept in
  4444. the .viminfo file.  See |viminfo_file_marks|.
  4445.  
  4446. Numbered marks '0 to '9 are quite different.  They can not be set directly.
  4447. They are only present when using a viminfo file |viminfo_file|.  Basically '0
  4448. is the location of the cursor when you last exited Vim, '1 the last but one
  4449. time, etc.  See |viminfo_file_marks|.
  4450.  
  4451.                             *'[*
  4452. '[            To the first non-blank character on the first line
  4453.             of the previously operated, inserted or putted text.
  4454.             {not in Vi}
  4455.  
  4456.                             *`[*
  4457. `[            To the first character of the previously operated,
  4458.             inserted or putted text.  {not in Vi}
  4459.  
  4460.                             *']*
  4461. ']            To the first non-blank character on the last line of
  4462.             the previously operated, inserted  or putted text.
  4463.             {not in Vi}
  4464.  
  4465.                             *`]*
  4466. `]            To the last character of the previously operated,
  4467.             inserted or putted text. {not in Vi}
  4468.  
  4469. After executing an operator the Cursor is put at the beginning of the text
  4470. that was operated upon.  After a put command ("p" or "P") the cursor is
  4471. sometimes placed at the first inserted line and sometimes on the last inserted
  4472. character.  The four commands above put the cursor at either end.  Example:
  4473. After yanking 10 lines you want to go to the last one of them: "10Y']".  After
  4474. inserting several lines with the "p" command you want to jump to the lowest
  4475. inserted line: "p']".  This also works for text that has been inserted.
  4476.  
  4477. Note: After deleting text, the start and end positions are the same, except
  4478. when using blockwise Visual mode.  These commands do not work when no
  4479. operator or put command has been used yet in the current file.
  4480.  
  4481.                             *'<*
  4482. '<            To the first non-blank character on the first line
  4483.             of the last selected Visual area.  {not in Vi}.
  4484.  
  4485.                             *`<*
  4486. `<            To the first character of the last selected Visual
  4487.             area.  {not in Vi}.
  4488.  
  4489.                             *'>*
  4490. '>            To the first non-blank character on the last line
  4491.             of the last selected Visual area.  {not in Vi}.
  4492.  
  4493.                             *`>*
  4494. `>            To the last character of the last selected Visual
  4495.             area.  {not in Vi}.
  4496.  
  4497.                             *''*
  4498. ''            To the first non-blank character of the line where
  4499.             the cursor was before the latest jump (linewise).
  4500.  
  4501.                             *``*
  4502. ``            To the position before latest jump (exclusive).
  4503.  
  4504.                             *'quote*
  4505. '"            To the first non-blank character of the line where
  4506.             the cursor was the last time the current buffer was
  4507.             exited (linewise).  {not in Vi}.
  4508.  
  4509.                             *`quote*
  4510. `"            To the cursor position when last exiting the current
  4511.             buffer (exclusive).  {not in Vi}.
  4512.  
  4513. A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n",
  4514. "N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and
  4515. the commands that start editing a new file.  If you make the cursor "jump"
  4516. with one of these commands, the position of the cursor before the jump is
  4517. remembered.  You can return to that position with the "''" and "``" command,
  4518. unless the line containing that position was changed or deleted.
  4519.  
  4520.                             *CTRL-O*
  4521. CTRL-O            Go to [count] Older cursor position in jump list
  4522.             (not a motion command).  {not in Vi}
  4523.  
  4524. <Tab>        or                    *CTRL-I* *<Tab>*
  4525. CTRL-I            Go to [count] newer cursor position in jump list
  4526.             (not a motion command).  {not in Vi}
  4527.  
  4528.                             *:ju* *:jumps*
  4529. :ju[mps]        Print the jump list (not a motion command).  {not in
  4530.             Vi}
  4531.  
  4532.                             *jumplist*
  4533. Jumps are remembered in a jump list.  With the CTRL-O and CTRL-I command you
  4534. can go to cursor positions before older jumps, and back again.  Thus you can
  4535. move up and down the list.
  4536.  
  4537. For example, after three jump commands you have this jump list:
  4538.  
  4539.  jump line  file
  4540.    1     1  -current-
  4541.    2    70  -current-
  4542.    3  1154  -current-
  4543. >
  4544.  
  4545. You are currently in line 1167.  If you then use the CTRL-O command, the
  4546. cursor is put in line 1154.  This results in:
  4547.  
  4548.  jump line  file
  4549.    1     1  -current-
  4550.    2    70  -current-
  4551. >  3  1154  -current-
  4552.    4  1167  -current-
  4553.  
  4554. The pointer will be set at the last used jump position.  The next CTRL-O
  4555. command will use the entry above it, the next CTRL-I command will use the
  4556. entry below it.  If the pointer is below the last entry, this indicates that
  4557. you did not use a CTRL-I or CTRL-O before.  In this case the CTRL-O command
  4558. will cause the cursor position to be added to the jump list, so you can get
  4559. back to the position before the CTRL-O.  In this case this is line 1167.
  4560.  
  4561. With more CTRL-O commands you will go to lines 70 and 1.  If you use CTRL-I
  4562. you can go back to 1154 and 1167 again.
  4563.  
  4564. If you use a jump command, the current line number is inserted at the end of
  4565. the jump list.  If the same line was already in the jump list, it is removed.
  4566. The result is that when repeating CTRL-O you will get back to old positions
  4567. only once.
  4568.  
  4569. After the CTRL-O command that got you into line 1154 you could give another
  4570. jump command (e.g., "G").  The jump list would then become:
  4571.  
  4572.  jump line  file
  4573.    1     1  -current-
  4574.    2    70  -current-
  4575.    3  1167  -current-
  4576.    4  1154  -current-
  4577. >
  4578.  
  4579. The line numbers will be adjusted for deleted and inserted lines.  This fails
  4580. if you stop editing a file without writing, like with ":n!".
  4581.  
  4582.                             *%*
  4583. %            Find the next item in this line after or under the
  4584.             cursor and jump to its match (inclusive).  Items can
  4585.             be:
  4586.             ([{}])        parenthesis or (curly/square) brackets
  4587.             /* */        start or end of C-style comment
  4588.             #if, #ifdef, #else, #elif, #endif
  4589.                     C preprocessor conditionals
  4590.             Parens and braces preceded with a backslash are
  4591.             ignored.  When the '%' character is not present in
  4592.             'cpoptions', parens and braces inside quotes are
  4593.             ignored, unless the number of parens/braces in a line
  4594.             is uneven and this line and the previous one does not
  4595.             end in a backslash.  No count is allowed ({count}%
  4596.             jumps to a line {count} percentage down the file).
  4597.             Using '%' on #if/#else/#endif makes the movement
  4598.             linewise.
  4599.  
  4600.                         *[(*
  4601. [(            go to [count] previous unmatched '('.  {not in Vi}
  4602.  
  4603.                         *[{*
  4604. [{            go to [count] previous unmatched '{'.  {not in Vi}
  4605.  
  4606.                         *])*
  4607. ])            go to [count] next unmatched ')'.  {not in Vi}
  4608.  
  4609.                         *]}*
  4610. ]}            go to [count] next unmatched '}'.  {not in Vi}
  4611.  
  4612. The above four commands can be used to go to the start or end of the current
  4613. code block.  It is like doing "%" on the '(', ')', '{' or '}' at the other
  4614. end of the code block, but you can do this from anywhere in the code block.
  4615. Very useful for C programs.  Example: When standing on "case x:", "[{" will
  4616. bring you back to the switch statement.
  4617.  
  4618.                         *[#*
  4619. [#            go to [count] previous unmatched "#if" or "#else".
  4620.             {not in Vi}
  4621.  
  4622.                         *]#*
  4623. ]#            go to [count] next unmatched "#else" or "#endif".  {not
  4624.             in Vi}
  4625.  
  4626. These two commands work in C programs that contain #if/#else/#endif
  4627. constructs.  It brings you to the start or end of the #if/#else/#endif where
  4628. the current line is included.  You can then use "%" to go to the matching line.
  4629.  
  4630.                         *[star* *[/*
  4631. [*  or  [/        go to [count] previous start of a C comment "/*".  {not
  4632.             in Vi}
  4633.  
  4634.                         *]star* *]/*
  4635. ]*  or  ]/        go to [count] next end of a C comment "*/".  {not
  4636.             in Vi}
  4637.  
  4638.  
  4639.                         *H*
  4640. H            To line [count] from top (Home) of screen (default:
  4641.             first line on the screen) on the first non-blank
  4642.             character (linewise).  See also 'startofline' option.
  4643.             Cursor is adjusted for 'scrolloff' option.
  4644.  
  4645.                         *M*
  4646. M            To Middle line of screen, on the first non-blank
  4647.             character (linewise).  See also 'startofline' option.
  4648.  
  4649.                         *L*
  4650. L            To line [count] from bottom of screen (default: Last
  4651.             line on the screen) on the first non-blank character
  4652.             (linewise).  See also 'startofline' option.
  4653.             Cursor is adjusted for 'scrolloff' option.
  4654.  
  4655. <LeftMouse>        Moves to the position on the screen where the mouse
  4656.             click is (inclusive).  See also |<LeftMouse>|.  If the
  4657.             position is in a status line, that window is made the
  4658.             active window and the cursor is not moved.  {not in Vi}
  4659.  
  4660.  
  4661. 7. Scrolling                        *scrolling*
  4662. ============
  4663.  
  4664. Move edit window (the part of the buffer that you see) downwards (this means
  4665. that more lines downwards in the text buffer are seen):
  4666.  
  4667.                             *CTRL-E*
  4668. CTRL-E            Scroll window [count] lines downwards in the buffer.
  4669.             Mnemonic: Extra lines.
  4670.  
  4671.                             *CTRL-D*
  4672. CTRL-D            Scroll window Downwards in the buffer.  The number of
  4673.             lines comes from the 'scroll' option (default: half a
  4674.             screen).  If [count] given, first set 'scroll' option
  4675.             to [count].  The cursor is moved the same number of
  4676.             lines down in the file (if possible; when lines wrap
  4677.             and when hitting the end of the file there may be a
  4678.             difference).  When the cursor is on the last line of
  4679.             the buffer nothing happens and a beep is produced.
  4680.             See also 'startofline' option.
  4681.             {difference from vi: Vim scrolls 'scroll' screen
  4682.             lines, instead of file lines; makes a difference when
  4683.             lines wrap}
  4684.  
  4685. <S-Down>    or                *<S-Down>* *<kPageDown>*
  4686. <PageDown>    or                *<PageDown>* *CTRL-F*
  4687. CTRL-F            Scroll window [count] pages Forwards (downwards) in
  4688.             the buffer.  See also 'startofline' option.
  4689.  
  4690. Move edit window (the part of the buffer that you see) upwards (this means
  4691. that more lines upwards in the text buffer are seen):
  4692.  
  4693.                             *CTRL-Y*
  4694. CTRL-Y            Scroll window [count] lines upwards in the buffer.
  4695.  
  4696.                             *CTRL-U*
  4697. CTRL-U            Scroll window Upwards in the buffer.  The number of
  4698.             lines comes from the 'scroll' option (default: half a
  4699.             screen).  If [count] given, first set the 'scroll'
  4700.             option to [count].  The cursor is moved the same
  4701.             number of lines up in the file (if possible; when
  4702.             lines wrap and when hitting the end of the file there
  4703.             may be a difference).  When the cursor is on the first
  4704.             line of the buffer nothing happens and a beep is
  4705.             produced.  See also 'startofline' option.
  4706.             {difference from vi: Vim scrolls 'scroll' screen
  4707.             lines, instead of file lines; makes a difference when
  4708.             lines wrap}
  4709.  
  4710. <S-Up>        or                    *<S-Up>* *<kPageUp>*
  4711. <PageUp>    or                    *<PageUp>* *CTRL-B*
  4712. CTRL-B            Scroll window [count] pages Backwards (upwards) in the
  4713.             buffer.  See also 'startofline' option.
  4714.  
  4715. Window repositioning:
  4716.  
  4717.                             *z* *z<CR>*
  4718. z<CR>            Redraw, line [count] at top of window (default
  4719.             cursor line).  Put cursor at first non-blank in the
  4720.             line.
  4721.  
  4722.                             *zt*
  4723. zt            Like "z<CR>", but leave the cursor in the same
  4724.             column.  {not in Vi}
  4725.  
  4726.                             *zN<CR>*
  4727. z{height}<CR>        Redraw, make window {height} lines tall.  This is
  4728.             useful to make the number of lines small when screen
  4729.             updating is very slow.  Cannot make the height more
  4730.             than the physical screen height.
  4731.  
  4732.                             *z.*
  4733. z.            Redraw, line [count] at center of window (default
  4734.             cursor line).  Put cursor at first non-blank in the
  4735.             line.
  4736.  
  4737.                             *zz*
  4738. zz            Like "z.", but leave the cursor in the same column.
  4739.             Careful: If caps-lock is on, this commands becomes
  4740.             "ZZ": write buffer and exit!  {not in Vi}
  4741.  
  4742.                             *z-*
  4743. z-            Redraw, line [count] at bottom of window (default
  4744.             cursor line).  Put cursor at first non-blank in the
  4745.             line.
  4746.  
  4747.                             *zb*
  4748. zb            Like "z-", but leave the cursor in the same column.
  4749.             {not in Vi}
  4750.  
  4751. These commands move the contents of the window.  If the cursor position is
  4752. moved off of the window, the cursor is moved onto the window (with
  4753. 'scrolloff' screen lines around it).  A page is the number of lines in the
  4754. window minus two.  The mnemonics for these commands may be a bit confusing.
  4755. Remember that the commands refer to moving the window upwards or downwards
  4756. in the buffer.  When the window moves upwards in the buffer, the text in the
  4757. window moves downwards on your screen.
  4758.  
  4759. z<Right>    or                        *zl* *z<Right>*
  4760. zl            Scroll the screen [count] characters to the left.
  4761.             This only works when 'wrap' is off.  {not in Vi}
  4762.  
  4763. z<Left>      or                        *zh* *z<Left>*
  4764. zh            Scroll the screen [count] characters to the right.
  4765.             This only works when 'wrap' is off.  {not in Vi}
  4766.  
  4767. For these two commands the cursor follows the screen.  If the character that
  4768. the cursor is on is moved off the screen, the cursor is moved to the closest
  4769. character that is on the screen.  The value of 'sidescroll' is not used.
  4770.  
  4771.                         *zs*
  4772. zs            Scroll the screen horizontally to position the cursor
  4773.             at the start (left side) of the screen.  This only
  4774.             works when 'wrap' is off.  {not in Vi}
  4775.  
  4776.                         *ze*
  4777. ze            Scroll the screen horizontally to position the cursor
  4778.             at the end (right side) of the screen.  This only
  4779.             works when 'wrap' is off.  {not in Vi}
  4780.  
  4781. For these two commands the cursor is not moved in the text, only the text
  4782. scrolls on the screen.
  4783.  
  4784.  
  4785. 8. Tags and special searches                *tags_and_searches*
  4786. ============================
  4787.  
  4788. 8.1 Tags                        *tag_commands*
  4789.  
  4790.                             *:ta* *:tag*
  4791. :ta[g][!] {ident}    Jump to the definition of {ident}, using the
  4792.             information in the tags file.  Put {ident} in the tag
  4793.             stack.  See below for [!].
  4794.  
  4795. g<LeftMouse>                        *g<LeftMouse>*
  4796. <C-LeftMouse>                    *<C-LeftMouse>* *CTRL-]*
  4797. CTRL-]            ":ta" to the keyword under or after cursor.  Put the
  4798.             keyword in the tag stack.  {Vi: identifier after the
  4799.             cursor}
  4800.  
  4801.                             *v_CTRL-]*
  4802. {Visual}CTRL-]        ":ta" to the text that is highlighted.  {not in Vi}
  4803.  
  4804. g<RightMouse>                        *g<RightMouse>*
  4805. <C-RightMouse>                    *<C-RightMouse>* *CTRL-T*
  4806. CTRL-T            Jump to [count] older entry in the tag stack
  4807.             (default 1).  {not in Vi}
  4808.  
  4809.                             *:po* *:pop*
  4810. :[count]po[p][!]    Jump to [count] older entry in tag stack (default 1).
  4811.             See below for [!].  {not in Vi}
  4812.  
  4813. :[count]ta[g][!]    Jump to [count] newer entry in tag stack (default 1).
  4814.             See below for [!].  {not in Vi}
  4815.  
  4816.                             *:tags*
  4817. :tags            Show the contents of the tag stack.  The active
  4818.             entry is marked with a '>'.  {not in Vi}
  4819.  
  4820.                             *tags*
  4821. A tag is an identifier that appears in the "tags" file.  It is a sort of label
  4822. that can be jumped to.  For example: In C programs each function name can be
  4823. used as a tag.
  4824.  
  4825. With the ":tag" command the cursor will be positioned on the tag.  With the
  4826. CTRL-] command, the keyword on which the cursor is standing is used as the
  4827. tag.  If the cursor is not on a keyword, the first keyword to the right of the
  4828. cursor is used.
  4829.  
  4830.                             *telnet-CTRL-]*
  4831. CTRL-] is the the default telnet escape key.  When you type CTRL-] to jump to
  4832. a tag, you will get the telnet prompt instead.  Most versions of telnet allow
  4833. changing or disabling the default escape key.  See the telnet man page.  You
  4834. can 'telnet -E <Hostname>' to disable the escape character, or 'telnet -e
  4835. <EscapeCharacter> <Hostname>' to specify another escape character.  If
  4836. possible, try to use "rsh" instead of "telnet" to avoid this problem.
  4837.  
  4838.                             *tag_priority*
  4839. When there are multiple matches for a tag, this priority is used:
  4840. 1.  The first matching static tag with a full matching tag for the current
  4841.     file.
  4842. 2.  The first matching global tag with a full matching tag.
  4843. 3.  The first matching static tag with a full matching tag for another file.
  4844. 4.  The first matching static tag with an ignore-case matching tag for the
  4845.     current file.
  4846. 5.  The first matching global tag with an ignore-case matching tag.
  4847. 6.  The first matching static tag with an ignore-case matching tag for another
  4848.     file.
  4849.  
  4850.                             *static_tag*
  4851. A static tag is a tag that is defined for a specific file.  In a C program this
  4852. could be a static function.
  4853.  
  4854. In Vi jumping to a tag sets the current search pattern.  This means that
  4855. the "n" command after jumping to a tag does not search for the same pattern
  4856. that it did before jumping to the tag.  Vim does not do this as we consider it
  4857. to be a bug.  You can still find the tag search pattern in the search history.
  4858. If you really want the old Vi behaviour, set the 't' flag in 'cpoptions'.
  4859.  
  4860. If the tag is in the current file this will always work.  Otherwise the
  4861. performed actions depend on whether the current file was changed, whether a !
  4862. is added to the command and on the 'autowrite' option:
  4863.  
  4864.   tag in       file       autowrite
  4865. current file  changed    !   option      action
  4866. -----------------------------------------------------------------------------
  4867.     yes         x    x     x      goto tag
  4868.     no         no    x     x      read other file, goto tag
  4869.     no        yes    yes    x   abandon current file, read other file, goto
  4870.                   tag
  4871.     no        yes    no    on  write current file, read other file, goto
  4872.                   tag
  4873.     no        yes    no   off  fail
  4874. -----------------------------------------------------------------------------
  4875.  
  4876. - If the tag is in the current file, the command will always work.
  4877. - If the tag is in another file and the current file was not changed, the
  4878.   other file will be made the current file and read into the buffer.
  4879. - If the tag is in another file, the current file was changed and a ! is
  4880.   added to the command, the changes to the current file are lost, the other
  4881.   file will be made the current file and read into the buffer.
  4882. - If the tag is in another file, the current file was changed and the
  4883.   'autowrite' option is on, the current file will be written, the other
  4884.   file will be made the current file and read into the buffer.
  4885. - If the tag is in another file, the current file was changed and the
  4886.   'autowrite' option is off, the command will fail.  If you want to save
  4887.   the changes, use the ":w" command and then use ":tag" without an argument.
  4888.   This works because the tag is put on the stack anyway.  If you want to lose
  4889.   the changes you can use the ":tag!" command.
  4890.  
  4891. The ":tag" command works very well for C programs.  If you see a call to a
  4892. function and wonder what that function does, position the cursor inside of
  4893. the function name and hit CTRL-].  This will bring you to the function
  4894. definition.  An easy way back is with the CTRL-T command.  Also read about the
  4895. tag stack below.
  4896.  
  4897. A tags file can be created with the external command 'ctags'.  It will
  4898. contain a tag for each function.  Some versions of 'ctags' will also make a
  4899. tag for each "#defined" macro.
  4900.  
  4901. The lines in the tags file must have one of these two formats:
  4902.  
  4903.     {tag}{separator}{filename}{separator}{command}
  4904.     {filename}:{tag}{separator}{filename}{separator}{command}
  4905.  
  4906. The first is a normal tag, the second is a static tag.  A normal tag is often
  4907. used for functions that are global, also referenced in other files.  A static
  4908. tag is often used for functions that are local, only referenced in the file
  4909. {filename}.  Note that for the static tag, the two occurances of {filename}
  4910. must be exactly the same.  Also see |tags_option| below, for how static tags
  4911. are used.
  4912.  
  4913. {tag}        The identifier.  Normally the name of a function, but it can
  4914.         be any identifier.  It cannot contain white space.
  4915. {separator}    One or more <Tab> or space characters.
  4916. {filename}    The file that contains the definition of {tag}.  It may
  4917.         contain environment variables and wildcards (although the use
  4918.         of wildcards is doubtful).
  4919. {command}    The Ex command that positions the cursor on the tag.
  4920.  
  4921.                             *tag_search*
  4922. The command can be any Ex command, but often it is a search command.
  4923. Examples:
  4924.     tag1    file1    /^main(argc, argv)/
  4925.     tag2    file2    108
  4926.  
  4927. The command is always executed with 'magic' not set.  The only special
  4928. characters in a search pattern are "^" (begin-of-line) and "$" (end-of-line).
  4929. See |search_pattern|.  Note that you must put a backslash before each
  4930. backslash in the search text.  This is for backwards compatibility with Vi.
  4931.  
  4932. If the command is a normal search command (it starts end ends with "/" or
  4933. "?"), some special handling is done:
  4934. - Searching starts on the current line of the current file, unless the tag is
  4935.   in another file, in which case the search starts in line 1 of that file.
  4936.   The direction of the search is forward for "/", backward for "?".
  4937. - If the search fails, another try is done ignoring case.  If that fails too,
  4938.   a search is done for:
  4939.     "^tagname[ \t]*("
  4940.   (the tag with '^' prepended and "[ \t]*(" appended).  When using function
  4941.   names, this will find the function name when it is in column 0.  This will
  4942.   help when the arguments to the function have changed since the tags file was
  4943.   made.  If this search also fails another search is done with:
  4944.     "^[#a-zA-Z_].*tagname[ \t]*("
  4945.   This means: A line starting with '#' or an identifier and containing the tag
  4946.   followed by white space and a '('.  This will find macro names and function
  4947.   names with a type prepended.  {the extra searches are not in Vi}.
  4948.  
  4949.                             *tag_security*
  4950. Note that Vim forbids some commands, for security reasons.  This works like
  4951. using the 'secure' option for exrc/vimrc files in the current directory.  See
  4952. |trojan_horse|.
  4953. When the {command} changes a buffer, you will get a warning message:
  4954.     "WARNING: tag command changed a buffer!!!"
  4955. In a future version changing the buffer will be impossible.  All this for
  4956. security reasons: Somebody might hide a nasty command in the tags file, which
  4957. would otherwise go unnoticed.  Example: ":$d|/tag-function-name/".
  4958. {this security prevention is not present in Vi}.
  4959.  
  4960. In Vi the ":tag" command sets the last search pattern when the tag is searched
  4961. for.  In Vim this is not done, the previous search pattern is still remembered,
  4962. unless the 't' flag is present in 'cpoptions'.  The search pattern is always
  4963. put in the search history, so you can modify it if searching fails.
  4964.  
  4965.                             *emacs_tags*
  4966. Emacs style tag files are supported if Vim was compiled with EMACS_TAGS
  4967. defined.  Check the output of ":version", if it contains "+emacs_tags" then it
  4968. was.  Sorry, there is no explanation about Emacs tag files here, it is only
  4969. supported for backwards compatibility :-).
  4970.  
  4971.                             *tags_option*
  4972. The 'tags' option is a list of file names.  Each of these files is searched
  4973. for the tag.  This can be used to use a different tags file than the default
  4974. file "tags".  It can also be used to access a common tags file.
  4975.  
  4976. The next file in the list is not used when:
  4977. - A matching static tag for the current buffer has been found.
  4978. - A matching global tag has been found.
  4979. This also depends on the 'ignorecase' option.  If it is off, and the tags file
  4980. only has a match without matching case, the next tags file is searched for a
  4981. match with matching case.  If no tag with matching case is found, the first
  4982. match without matching case is used.  If 'ignorecase' is on, and a matching
  4983. global tag with or without matching case is found, this one is used, no
  4984. further tags files are searched.
  4985.  
  4986. When a tag file name starts with "./", the '.' is replaced with the path of
  4987. the current file.  This makes it possible to use a tags file in the directory
  4988. where the current file is (no matter what the current directory is).  The idea
  4989. of using "./" is that you can define which tag file is searched first: In the
  4990. current directory ("tags,./tags") or in the directory of the current file
  4991. ("./tags,tags").
  4992.  
  4993. For example:
  4994.  
  4995.     :set tags=./tags,tags,/home/user/commontags
  4996.  
  4997. In this example the tag will first be searched for in the file "tags" in the
  4998. directory where the current file is.  Next the "tags" file in the current
  4999. directory.  If it is not found there, then the file "/home/user/commontags"
  5000. will be searched for the tag.
  5001.  
  5002. This can be switched off by including the 'd' flag in 'cpoptions', to make
  5003. it Vi compatible.  "./tags" will than be the tags file in the current
  5004. directory, instead of the tags file in the directory where the current file
  5005. is.
  5006.  
  5007. Instead of the comma a space may be used.  Then a backslash is required for
  5008. the space to be included in the string option:
  5009.  
  5010.     :set tags=tags\ /home/user/commontags
  5011.  
  5012. To include a space in a file name use three backslashes.  To include a comma in
  5013. a file name use two backslashes.  For example, use:
  5014.  
  5015.     :set tags=tag\\\ file,/home/user/common\\,tags
  5016.  
  5017. for the files "tag file" and "/home/user/common,tags".  The 'tags' option will
  5018. have the value "tag\ file,/home/user/common\,tags".
  5019.  
  5020. If the 'tagrelative' option is on (which is the default) and using a tag file
  5021. in another directory, file names in that tag file are relative to the
  5022. directory where the tag file is.
  5023.  
  5024.  
  5025.                             *tagstack*
  5026. The tags that you use are remembered in the tag stack.  You can print this
  5027. stack with the ":tags" command.  The result looks like this:
  5028.  
  5029.   # TO tag    FROM line in file
  5030.   1 main           1  harddisk2:text/vim/test
  5031. > 2 FuncA          58  -current-
  5032.   3 FuncC         357  harddisk2:text/vim/src/amiga.c
  5033.  
  5034. This list shows the tags that you jumped to and the cursor position before that
  5035. jump.  The older tags are at the top, the newer at the bottom.
  5036.  
  5037. The '>' points to the active entry.  This is the tag that will be used by the
  5038. next ":tag" command.  The CTRL-T and ":pop" command will use the position
  5039. above the active entry.
  5040.  
  5041. The line number and file name are remembered to be able to get back to where
  5042. you were before the tag command.  The line number will be correct, also when
  5043. deleting/inserting lines, unless this was done by another program (e.g.
  5044. another instance of Vim).
  5045.  
  5046. You can jump to previously used tags with several commands.  Some examples:
  5047.  
  5048.     ":pop" or CTRL-T    to position before previous tag
  5049.     {count}CTRL-T        to position before {count} older tag
  5050.     ":tag"            to newer tag
  5051.     ":0tag"            to last used tag
  5052.  
  5053. The most obvious way to use this is while browsing through the call graph of
  5054. a program.  Consider the following call graph:
  5055.  
  5056.     main  --->  FuncA  --->  FuncC
  5057.           --->  FuncB
  5058.  
  5059. (Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
  5060. You can get from main to FuncA by using CTRL-] on the call to FuncA.  Then
  5061. you can CTRL-] to get to FuncC.  If you now want to go back to main you can
  5062. use CTRL-T twice.  Then you can CTRL-] to FuncB.
  5063.  
  5064. If you issue a ":ta {ident}" or CTRL-] command, this tag is inserted at the
  5065. current position in the stack.  If the stack was full (it can hold up to 20
  5066. entries), the oldest entry is deleted and the older entries shift one
  5067. position up (their index number is decremented by one).  If the last used
  5068. entry was not at the bottom, the entries below the last used one are
  5069. deleted.  This means that an old branch in the call graph is lost.  After the
  5070. commands explained above the tag stack will look like this:
  5071.  
  5072.   # TO tag    FROM line in file
  5073.   1 main           1  harddisk2:text/vim/test
  5074.   2 FuncB          59  harddisk2:text/vim/src/main.c
  5075. >
  5076.  
  5077.  
  5078. 8.2 Include file searches                *include_search*
  5079.  
  5080. These commands look for a string in the current file and in all encountered
  5081. included files (recursively).  This can be used to find the definition of a
  5082. variable, function or macro.  If you only want to search in the current
  5083. buffer, use the commands listed at |pattern_searches|.
  5084.  
  5085. When a line is encountered that includes another file, that file is searched
  5086. before continuing in the current buffer.  Files included by included files are
  5087. also searched.  When an include file could not be found it is silently
  5088. ignored.  Use the ":checkpath" command to discover which files could not be
  5089. found, possibly your 'path' option is not set up correctly.  Note: the
  5090. included file is searched, not a buffer that may be editing that file.  Only
  5091. for the current file the lines in the buffer are used.
  5092.  
  5093. The string can be any keyword or a defined macro.  For the keyword any match
  5094. will be found.  For defined macros only lines that match with the 'define'
  5095. option will be found.  The default is "\^#[ \t]*define", which is for C
  5096. programs.  Also, when a match is found for a defined macro, the displaying of
  5097. lines continues with the next line when a line ends in a backslash.
  5098.  
  5099. The commands that start with "[" start searching from the start of the current
  5100. file.  The commands that start with "]" start at the current cursor position.
  5101.  
  5102. The 'include' option is used to define a line that includes another file.  The
  5103. default is "\^#[ \t]*include", which is for C programs.  Note: Vim does not
  5104. recognize C syntax, if the 'include' option matches a line inside
  5105. "#ifdef/#endif" or inside a comment, it is searched anyway.  The 'isfname'
  5106. option is used to recognize the file name that comes after the matched
  5107. pattern.
  5108.  
  5109. The 'path' option is used to find the directory for the include files that
  5110. do not have an absolute path.
  5111.  
  5112. The 'comments' option is used for the commands that display a single line or
  5113. jump to a line.  It defines patterns that may start a comment.  Those lines
  5114. are ignored for the search, unless [!] is used.  One exception: When the line
  5115. matches the pattern "^# *define" it is not considered to be a comment.
  5116.  
  5117.                             *[i*
  5118. [i            Display the first line that contains the keyword
  5119.             under the cursor.  The search starts at the beginning
  5120.             of the file.  Lines that look like a comment are
  5121.             ignored (see 'comments' option).  If a count is given,
  5122.             the count'th matching line is displayed, and comment
  5123.             lines are not ignored.  {not in Vi}
  5124.  
  5125.                             *]i*
  5126. ]i            like "[i", but start at the current cursor position.
  5127.             {not in Vi}
  5128.  
  5129.                             *:is* *:isearch*
  5130. :[range]is[earch][!] [count] [/]pattern[/]
  5131.             Like "[i"  and "]i", but search in [range] lines
  5132.             (default: whole file).  Without [!] lines that are
  5133.             recognized as comments are skipped.  Without [/] only
  5134.             whole words are matched, using the pattern
  5135.             "\<pattern\>".  {not in Vi}
  5136.  
  5137.                             *[I*
  5138. [I            Display all lines that contain the keyword under the
  5139.             cursor.  File names and line numbers are displayed
  5140.             for the found lines.  The search starts at the
  5141.             beginning of the file.  {not in Vi}
  5142.  
  5143.                             *]I*
  5144. ]I            like "[I", but start at the current cursor position.
  5145.             {not in Vi}
  5146.  
  5147.                             *:il* *:ilist*
  5148. :[range]il[ist][!] [/]pattern[/]
  5149.             Like "[I" and "]I", but search in [range] lines
  5150.             (default: whole file).  Without [!] lines that are
  5151.             recognized as comments are skipped.  Without [/] only
  5152.             whole words are matched, using the pattern
  5153.             "\<pattern\>".  {not in Vi}
  5154.  
  5155.                             *[_CTRL-I*
  5156. [ CTRL-I        Jump to the first line that contains the keyword
  5157.             under the cursor.  The search starts at the beginning
  5158.             of the file.  Lines that look like a comment are
  5159.             ignored (see 'comments' option).  If a count is given,
  5160.             the count'th matching line is jumped to, and comment
  5161.             lines are not ignored.  {not in Vi}
  5162.  
  5163.                             *]_CTRL-I*
  5164. ] CTRL-I        like "[ CTRL-I", but start at the current cursor
  5165.             position.  {not in Vi}
  5166.  
  5167.                             *:ij* *:ijump*
  5168. :[range]ij[ump][!] [count] [/]pattern[/]
  5169.             Like "[ CTRL-I"  and "] CTRL-I", but search in
  5170.             [range] lines (default: whole file).  Without [!]
  5171.             lines that are recognized as comments are skipped.
  5172.             Without [/] only whole words are matched, using the
  5173.             pattern "\<pattern\>".  {not in Vi}
  5174.  
  5175. CTRL-W CTRL-I                    *CTRL-W_CTRL-I* *CTRL-W_i*
  5176. CTRL-W i        Open a new window, with the cursor on the first line
  5177.             that contains the keyword under the cursor.  The
  5178.             search starts at the beginning of the file.  Lines
  5179.             that look like a comment line are ignored (see
  5180.             'comments' option).  If a count is given, the count'th
  5181.             matching line is jumped to, and comment lines are not
  5182.             ignored.  {not in Vi}
  5183.  
  5184.                             *:isp* *:isplit*
  5185. :[range]isp[lit][!] [count] [/]pattern[/]
  5186.             Like "CTRL-W i"  and "CTRL-W i", but search in
  5187.             [range] lines (default: whole file).  Without [!]
  5188.             lines that are recognized as comments are skipped.
  5189.             Without [/] only whole words are matched, using the
  5190.             pattern "\<pattern\>".  {not in Vi}
  5191.  
  5192.                             *[d*
  5193. [d            Display the first macro definition that contains the
  5194.             macro under the cursor.  The search starts from the
  5195.             beginning of the file.  If a count is given, the
  5196.             count'th matching line is displayed.  {not in Vi}
  5197.  
  5198.                             *]d*
  5199. ]d            like "[d", but start at the current cursor position.
  5200.             {not in Vi}
  5201.  
  5202.                             *:ds* *:dsearch*
  5203. :[range]ds[earch][!] [count] [/]pattern[/]
  5204.             Like "[d"  and "]d", but search in [range] lines
  5205.             (default: whole file).  Without [!] lines that are
  5206.             recognized as comments are skipped.  Without [/] only
  5207.             whole words are matched, using the pattern
  5208.             "\<pattern\>".  {not in Vi}
  5209.  
  5210.                             *[D*
  5211. [D            Display all macro definitions that contain the macro
  5212.             under the cursor.  File names and line numbers are
  5213.             displayed for the found lines.  The search starts
  5214.             from the beginning of the file.  {not in Vi}
  5215.  
  5216.                             *]D*
  5217. ]D            like "[D", but start at the current cursor position.
  5218.             {not in Vi}
  5219.  
  5220.                             *:dl* *:dlist*
  5221. :[range]dl[ist][!] [/]pattern[/]
  5222.             Like "[D"  and "]D", but search in [range] lines
  5223.             (default: whole file).  Without [!] lines that are
  5224.             recognized as comments are skipped.  Without [/] only
  5225.             whole words are matched, using the pattern
  5226.             "\<pattern\>".  {not in Vi}
  5227.  
  5228.                             *[_CTRL-D*
  5229. [ CTRL-D        Jump to the first macro definition that contains the
  5230.             keyword under the cursor.  The search starts from
  5231.             the beginning of the file.  If a count is given, the
  5232.             count'th matching line is jumped to.  {not in Vi}
  5233.  
  5234.                             *]_CTRL-D*
  5235. ] CTRL-D        like "[ CTRL-D", but start at the current cursor
  5236.             position.  {not in Vi}
  5237.  
  5238.                             *:dj* *:djump*
  5239. :[range]dj[ump][!] [count] [/]pattern[/]
  5240.             Like "[ CTRL-D"  and "] CTRL-D", but search  in
  5241.             [range] lines (default: whole file).  Without [!]
  5242.             lines that are recognized as comments are skipped.
  5243.             Without [/] only whole words are matched, using the
  5244.             pattern "\<pattern\>".  {not in Vi}
  5245.  
  5246. CTRL-W CTRL-D                    *CTRL-W_CTRL-D* *CTRL-W_d*
  5247. CTRL-W d        Open a new window, with the cursor on the first
  5248.             macro definition line that contains the keyword
  5249.             under the cursor.  The search starts from the
  5250.             beginning of the file.  If a count is given, the
  5251.             count'th matching line is jumped to.  {not in Vi}
  5252.  
  5253.                             *:dsp* *:dsplit*
  5254. :[range]dsp[lit][!] [count] [/]pattern[/]
  5255.             Like "CTRL-W d", but search in [range] lines
  5256.             (default: whole file).  Without [!] lines that are
  5257.             recognized as comments are skipped.  Without [/] only
  5258.             whole words are matched, using the pattern
  5259.             "\<pattern\>".  {not in Vi}
  5260.  
  5261.                             *:che* *:checkpath*
  5262. :che[ckpath]        List all the included files that could not be found.
  5263.             {not in Vi}
  5264.  
  5265. :che[ckpath]!        List all the included files.  {not in Vi}
  5266.  
  5267.  
  5268. 9. Inserting text                    *inserting*
  5269. =================
  5270.  
  5271. The following commands can be used to insert new text into the buffer.  They
  5272. can all be undone.  The non-Ex commands can be repeated with the "." command.
  5273.  
  5274.                             *a*
  5275. a            Append text after the cursor [count] times.
  5276.  
  5277.                             *A*
  5278. A            Append text at the end of the line [count] times.
  5279.  
  5280. <Insert>    or                *i* *insert* *<Insert>*
  5281. i            Insert text before the cursor [count] times.
  5282.  
  5283.                             *I*
  5284. I            Insert text before the first non-blank in the line
  5285.             [count] times.
  5286.  
  5287.                             *gI*
  5288. gI            Insert text in column 1 [count] times.  {not in Vi}
  5289.  
  5290.                             *o*
  5291. o            Begin a new line below the cursor and insert text,
  5292.             repeat [count] times.  {Vi: blank [count] screen
  5293.             lines}
  5294.  
  5295.                             *O*
  5296. O            Begin a new line above the cursor and insert text,
  5297.             repeat [count] times.  {Vi: blank [count] screen
  5298.             lines}
  5299.  
  5300. These commands are used to start inserting text.  They can be undone and
  5301. repeated.  You can end Insert mode with <Esc>.  See the section "Insert and
  5302. Replace mode" |mode_ins_repl| for the other special characters in Insert
  5303. mode.  The effect of [count] takes place after Insert mode is exited.
  5304.  
  5305. When 'autoindent' is on, the indent for a new line is obtained from the
  5306. previous line.  When 'smartindent' or 'cindent' is on, the indent for a line
  5307. is automatically adjusted for C programs.
  5308.  
  5309. 'textwidth' can be set to the maximum width for a line.  When a line becomes
  5310. too long when appending characters a line break is automatically inserted.
  5311.  
  5312.                             *:r* *:read*
  5313. :r[ead] [name]        Insert the file [name] (default: current file) below
  5314.             the cursor.
  5315.  
  5316. :{range}r[ead] [name]    Insert the file [name] (default: current file) below
  5317.             the specified line.
  5318.  
  5319.                             *:r!* *:read!*
  5320. :r[ead] !{cmd}        Execute {cmd} and insert its standard output below
  5321.             the cursor.  A temporary file is used to store the
  5322.             output of the command which is then read into the
  5323.             buffer.  'shellredir' is used to save the output of
  5324.             the command, which can be set to include stderr or
  5325.             not.  {cmd} is executed like with ":!{cmd}", any '!'
  5326.             is replaced with the previous command |:!|.
  5327.  
  5328. These commands insert the contents of a file, or the output of a command,
  5329. into the buffer.  They can be undone.  They cannot be repeated with the "."
  5330. command.  They work on a line basis, insertion starts below the line in which
  5331. the cursor is, or below the specified line.  To insert text above the first
  5332. line use the command ":0r {name}".
  5333.  
  5334. If a file name is given with ":r", it becomes the alternate file.  This can be
  5335. used, for example, when you want to edit that file instead: ":e! #".  This can
  5336. be switched off by removing the 'a' flag from the 'cpoptions' option.
  5337.  
  5338.                             *textmode_read*
  5339. The <NL> character is recognized as end-of-line marker.  If the 'textmode'
  5340. option is on, a <CR> in front of an <NL> is ignored and a CTRL-Z at the end
  5341. of the file is ignored.  The 'textmode' option is default on for MS-DOS, Win32
  5342. and OS/2.
  5343.  
  5344. If the 'textauto' option is on Vim tries to recognize the type of end-of-line
  5345. marker (see |textmode_io|).  However, the 'textmode' option will not be
  5346. changed.  Only while reading the file the text mode is used or not.
  5347.  
  5348. On non-MS-DOS, Win32, and OS/2 systems the message "[textmode]" is shown if a
  5349. file is read in text mode, to remind you that something unusual is done.  On
  5350. MS-DOS, Win32, and OS/2 the message "[notextmode]" is shown if a file is read
  5351. without text mode.
  5352.  
  5353. An example on how to use ":r !":
  5354.     :r !uuencode binfile binfile
  5355. This command reads "binfile", uuencodes it and reads it into the current
  5356. buffer.  Useful when you are editing e-mail and want to include a binary
  5357. file.
  5358.  
  5359.  
  5360. 10. Deleting text                    *deleting*
  5361. =================
  5362.  
  5363. ["x]<Del>    or                    *<Del>* *x* *dl*
  5364. ["x]x            Delete [count] characters under and after the cursor
  5365.             [into register x] (not linewise).  Does the same as
  5366.             "dl".  See |:fixdel| if the <Del> key does not do what
  5367.             you want.  Also see |'whichwrap'|.  {<Del> not in Vi}
  5368.  
  5369.                             *X* *dh*
  5370. ["x]X            Delete [count] characters before the cursor [into
  5371.             register x] (not linewise).  Does the same as "dh".
  5372.             Also see |'whichwrap'|.
  5373.  
  5374.                             *d*
  5375. ["x]d{motion}        Delete text that is moved over [into register x].
  5376.             See below for exception.
  5377.  
  5378.                             *dd*
  5379. ["x]dd            Delete [count] lines [into register x] (linewise).
  5380.  
  5381.                             *D*
  5382. ["x]D            Delete the characters under the cursor until the end
  5383.             of the line and [count]-1 more lines [into register
  5384.             x]; synonym for d$ (not linewise).
  5385.  
  5386. {Visual}["x]x    or                    *v_x* *v_d*
  5387. {Visual}["x]d        Delete the highlighted text [into register x] (see
  5388.             the chapter on Visual mode |Visual_mode|).  {not in
  5389.             Vi}
  5390.  
  5391. {Visual}["x]X    or                    *v_X* *v_D*
  5392. {Visual}["x]D        Delete the highlighted lines [into register x] (see
  5393.             the chapter on Visual mode |Visual_mode|).  {not in
  5394.             Vi}
  5395.  
  5396.                             *:d* *:delete*
  5397. :[range]d[elete] [x]    Delete [range] lines (default: current line) [into
  5398.             register x].
  5399.  
  5400. :[range]d[elete] [x] {count}
  5401.             Delete {count} lines, starting with [range]
  5402.             (default: current line |cmdline_ranges|) [into
  5403.             register x].
  5404.  
  5405. These commands delete text.  They can be repeated with the "." command
  5406. (except ":d") and undone.  Use Visual mode to delete blocks of text.  See
  5407. |registers| for an explanation of registers.
  5408.  
  5409. An exception for the d{motion} command: If the motion is not linewise, the
  5410. start and end of the motion are not in the same line and before the start
  5411. and after the end are only blanks, the delete becomes linewise.  This means
  5412. that the blank line that would remain is also deleted.
  5413.  
  5414.  
  5415.                             *J*
  5416. J            Join [count] lines, with a minimum of two lines.
  5417.  
  5418.                             *v_J*
  5419. {Visual}J        Join the highlighted lines, with a minimum of two
  5420.             lines.  {not in Vi}
  5421.  
  5422.                             *:j* *:join*
  5423. :[range]j[oin][!]    Join [range] lines.  Same as "J", except when [!] is
  5424.             given, then no spaces will be inserted or deleted.
  5425.             When [range] is given and the start and end of the
  5426.             range are equal, nothing happens.  Default is to join
  5427.             two lines.
  5428.  
  5429. :[range]j[oin][!] {count}
  5430.             Join {count} lines, starting with [range] (default:
  5431.             current line |cmdline_ranges|).  Same as "J", except
  5432.             when [!] is given, then no spaces will be inserted
  5433.             or deleted.
  5434.  
  5435. These commands delete the newline between lines.  This has the effect of
  5436. joining them into one line.  They can be repeated (except ":j") and undone.
  5437.  
  5438. One space is inserted in place of the <NL>, unless the line ended with a
  5439. space, <Tab> or the next line started with a ')'.  If the next line has
  5440. leading white space it is deleted first.  If the 'joinspaces' option is on,
  5441. two spaces are inserted after a period.
  5442.  
  5443.  
  5444. 11. Changing text                    *changing*
  5445. =================
  5446.  
  5447. The following commands can be used to change text, that is delete some text
  5448. and insert something else, with one command.  They can all be undone.  The
  5449. non-Ex commands can be repeated with the "." command.
  5450.  
  5451.  
  5452. 11.1 Delete and insert                    *delete_insert*
  5453.  
  5454.                             *R*
  5455. R            Enter Replace mode: Each character you type replaces
  5456.             an existing character, starting with the character
  5457.             under the cursor.  Repeat the entered text [count]-1
  5458.             times.
  5459.  
  5460.                             *c*
  5461. ["x]c{motion}        Delete {motion} text [into register x] and start
  5462.             insert.
  5463.  
  5464.                             *cc*
  5465. ["x]cc            Delete [count] lines [into register x] and start
  5466.             insert (linewise).  If 'autoindent' is on, preserve
  5467.             the indent of the first line.
  5468.  
  5469.                             *C*
  5470. ["x]C            Delete from the cursor position to the end of the
  5471.             line and [count]-1 more lines [into register x], and
  5472.             start insert.  Synonym for c$ (not linewise).
  5473.  
  5474.                             *s*
  5475. ["x]s            Delete [count] characters [into register x] and start
  5476.             insert (s stands for Substitute).  Synonym for "cl"
  5477.             (not linewise).
  5478.  
  5479.                             *S*
  5480. ["x]S            Delete [count] lines [into register x] and start
  5481.             insert.  Synonym for "cc" (not linewise).
  5482.  
  5483. {Visual}["x]c    or                    *v_c* *v_r*
  5484. {Visual}["x]r        Delete the highlighted text [into register x] and
  5485.             start insert (see the chapter on Visual mode
  5486.             |Visual_mode|).  {not in Vi}
  5487.  
  5488. {Visual}["x]C    or                    *v_C* *v_R*
  5489. {Visual}["x]R        Delete the highlighted lines [into register x] and
  5490.             start insert (see the chapter on Visual mode
  5491.             |Visual_mode|).  {not in Vi}
  5492.  
  5493. Notes:
  5494. - You can end Insert and Replace mode with <Esc>.
  5495. - See the section "Insert and Replace mode" |mode_ins_repl| for the other
  5496.   special characters in these modes.
  5497. - The effect of [count] takes place after Insert or Replace mode is exited.
  5498. - When the 'cpoptions' option contains '$', and the change is within one line,
  5499.   the text is not directly deleted, but a '$' is put at the last deleted
  5500.   character.
  5501.  
  5502. See |registers| for an explanation of registers.
  5503.  
  5504. Replace mode is just like Insert mode, except that for every character you
  5505. enter, one character is deleted.  If the end of a line is reached, further
  5506. characters are appended (just like Insert mode).  In Replace mode the
  5507. backspace key restores the original text (if there was any) (see section
  5508. "Insert and Replace mode" |mode_ins_repl|).
  5509.  
  5510.                         *cw* *cW*
  5511. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is
  5512. on a non-blank.  This is because "cw" is interpreted as change-word, and a
  5513. word does not include the following white space.  {Vi: "cw" when on a blank
  5514. followed by other blanks changes only the first blank; this is probably a
  5515. bug, because "dw" deletes all the blanks}
  5516.  
  5517.  
  5518. 11.2 Simple changes                    *simple_change*
  5519.  
  5520.                             *r*
  5521. r{char}            Replace the character under the cursor with {char}.  If
  5522.             {char} is a <CR> or <NL> the character will be
  5523.             replaced with a line break.  Replacing with a real <CR>
  5524.             can be done by using CTRL-V <CR>.  CTRL-V <NL> will
  5525.             replace with a <Nul>.  {Vi: CTRL-V <CR> still replaces
  5526.             with a line break, cannot replace something with a
  5527.             <CR>}
  5528.             If a [count] is given that many characters will be
  5529.             replaced with [count] {char}s.  When {char} is a <CR>
  5530.             or <NL> only one is inserted.  "5r<CR>" replaces five
  5531.             characters with a single line break;
  5532.             When replacing with a <CR> or <NL> autoindenting is
  5533.             done.  This works just like deleting the characters
  5534.             that are replaced and then doing "i<CR><Esc>".
  5535.  
  5536.                             *~*
  5537. ~            'notildeop' option: switch case of the character
  5538.             under the cursor and move the cursor to the right.
  5539.             If a [count] is given do that many characters {Vi:
  5540.             no count}
  5541.  
  5542. ~{motion}        'tildeop' option: switch case of {motion} text.  {Vi:
  5543.             tilde cannot be used as an operator}
  5544.  
  5545.                             *g~*
  5546. g~{motion}        switch case of {motion} text.  {Not in Vi}
  5547.  
  5548.                             *v_~*
  5549. {Visual}~        switch case of highlighted text (see the chapter on
  5550.             Visual mode |Visual_mode|).  {not in Vi}
  5551.  
  5552.                             *v_U*
  5553. {Visual}U        Make highlighted text uppercase (see the chapter on
  5554.             Visual mode |Visual_mode|).  {not in Vi}
  5555.  
  5556.                             *gU*
  5557. gU{motion}        Make {motion} text uppercase.  {not in Vi}
  5558.  
  5559.                             *v_u*
  5560. {Visual}u        Make highlighted text lowercase (see the chapter on
  5561.             Visual mode |Visual_mode|).  {not in Vi}
  5562.  
  5563.                             *gu*
  5564. gu{motion}        Make {motion} text lowercase.  {not in Vi}
  5565.  
  5566.                             *CTRL-A*
  5567. CTRL-A            Add [count] to the number at or after the cursor.
  5568.             {not in Vi}
  5569.  
  5570.                             *CTRL-X*
  5571. CTRL-X            Subtract [count] from the number at or after the
  5572.             cursor.  {not in Vi}
  5573.  
  5574. The CTRL-A and CTRL-X commands work for (signed) decimal numbers and
  5575. unsigned octal and hexadecimal numbers.  Numbers starting with '0x' or '0X'
  5576. are assumed to be hexadecimal.  To decide whether the hexadecimal number
  5577. should be printed uppercase or not, the case of the rightmost letter in the
  5578. number is considered.  If there is no letter in the current number, the
  5579. previously detected case is used.  Numbers starting with a '0' are considered
  5580. to be octal.  Other numbers are decimal and may be preceded with a minus
  5581. sign.  If the cursor is on a number, that one will be used.  Otherwise the
  5582. number right of the cursor will be used.
  5583.  
  5584. For octal and hexadecimal numbers with leading zeros, the number of
  5585. characters in the number remains equal (when possible).  When doing CTRL-A on
  5586. "0077" it becomes "0100", CTRL-X on "0x0100" becomes "0x00ff".  Note that
  5587. when there are no leading zeros this does not work, so CTRL-X on "0x100"
  5588. results in "0xff".  Note that decimal numbers with leading zeros are
  5589. impossible, because they are recognized as octal numbers.
  5590.  
  5591. The CTRL-A command is very useful in a macro.  Example: How to make a
  5592. numbered list.
  5593.  
  5594. 1. Create the first entry.  The entry should start with a number.
  5595. 2. qa         - start recording into buffer 'a'
  5596. 3. Y         - yank the entry
  5597. 4. p         - put a copy of the entry below the first one
  5598. 5. CTRL-A    - increment the number
  5599. 6. q         - stop recording
  5600. 7. <count>@a - repeat the yank, put and increment <count> times
  5601.  
  5602.                             *<*
  5603. <{motion}        Shift the {motion} lines one 'shiftwidth' leftwards.
  5604.  
  5605.                             *<<*
  5606. <<            Shift [count] lines one 'shiftwidth' leftwards.
  5607.  
  5608.                             *v_<*
  5609. {Visual}[count]<    Shift the highlighted lines [count] 'shiftwidth'
  5610.             leftwards (see the chapter on Visual mode
  5611.             |Visual_mode|).  {not in Vi}
  5612.  
  5613.                             *>*
  5614. >{motion}        Shift {motion} lines one 'shiftwidth' rightwards.
  5615.  
  5616.                             *>>*
  5617. >>            Shift [count] lines one 'shiftwidth' rightwards.
  5618.  
  5619.                             *v_>*
  5620. {Visual}[count]>    Shift the highlighted lines [count] 'shiftwidth'
  5621.             rightwards (see the chapter on Visual mode
  5622.             |Visual_mode|).  {not in Vi}
  5623.  
  5624.                             *:<*
  5625. :[range]<        Shift [range] lines one 'shiftwidth' left.  Repeat '<'
  5626.             for shifting multiple 'shiftwidth's.
  5627.  
  5628. :[range]< {count}    Shift {count} lines one 'shiftwidth' left, starting
  5629.             with [range] (default current line |cmdline_ranges|).
  5630.             Repeat '<' for shifting multiple 'shiftwidth's.
  5631.  
  5632. :[range]le[ft] [indent]    left align lines in [range].  Sets the indent in the
  5633.             lines to [indent] (default 0).  {not in Vi}
  5634.  
  5635.                             *:>*
  5636. :[range]>        Shift {count} [range] lines one 'shiftwidth' right.
  5637.             Repeat '>' for shifting multiple 'shiftwidth's.
  5638.  
  5639. :[range]> {count}    Shift {count} lines one 'shiftwidth' right, starting
  5640.             with [range] (default current line |cmdline_ranges|).
  5641.             Repeat '>' for shifting multiple 'shiftwidth's.
  5642.  
  5643. The ">" and "<" commands are handy for changing the indent within programs.
  5644. The size of the white space which is inserted or deleted can be set with the
  5645. 'shiftwidth' option.  Normally the 'shiftwidth' option is 8, but you can set it
  5646. to, say, 3 to make smaller indents.  The shift leftwards stops when there is no
  5647. indent.  The shift right does not do anything with empty lines.
  5648.  
  5649. If the 'shiftround' option is on, the indent is rounded to a multiple of
  5650. 'shiftwidth'.
  5651.  
  5652. If the 'smartindent' option is on, or 'cindent' is on and 'cinkeys' contains
  5653. '#', lines starting with '#' will not be shifted right (they are supposed to
  5654. be C preprocessor lines that must stay in column 1).
  5655.  
  5656. When the 'expandtab' option is off (this is the default) <Tab>s are used as
  5657. much as possible to make the indent.  You can use ">><<" to replace an indent
  5658. made out of spaces with the same indent made out of <Tab>s (and a few
  5659. spaces if necessary).  If the 'expandtab' option is on, only spaces are
  5660. used.  Then you can use ">><<" to replace <Tab>s in the indent by spaces (or
  5661. use ":retab!").
  5662.  
  5663. To move a line several 'shiftwidth's use the Visual mode or the ":"
  5664. commands.  For example:
  5665.     Vjj4>        move three lines 4 indents to the right
  5666.     :<<<        move current line 3 indents to the left
  5667.     :>> 5        move 5 lines 2 indents to the right
  5668.     :5>>        move line 5 2 indents to the right
  5669.  
  5670.  
  5671. 11.3 Complex changes                    *complex_change*
  5672.  
  5673.                             *!*
  5674. !{motion}{filter}    Filter {motion} text through the external program
  5675.             {filter}.
  5676.  
  5677.                             *!!*
  5678. !!{filter}        Filter [count] lines through the external program
  5679.             {filter}.
  5680.  
  5681.                             *v_!*
  5682. {Visual}!{filter}    Filter the highlighted lines through the external
  5683.             program {filter} (see the chapter on Visual mode
  5684.             |Visual_mode|).  {not in Vi}
  5685.  
  5686. :{range}![!]{filter} [!][arg]                *:range!*
  5687.             Filter {range} lines through the external program
  5688.             {filter}.  The optional bangs are replaced with the
  5689.             latest given command.  The optional [arg] is
  5690.             appended.  The output of the filter command is
  5691.             temporaryly saved in a file and then read into the
  5692.             buffer.  The 'shellredir' option is used to write the
  5693.             output of the filter in the temporary file.
  5694.  
  5695.                             *=*
  5696. ={motion}        Filter {motion} lines through the external program
  5697.             given with the 'equalprg' option.  When the 'equalprg'
  5698.             option is empty (this is the default), use the
  5699.             internal formatting function to set the indent of each
  5700.             line |C_indenting|.
  5701.  
  5702.                             *==*
  5703. ==            Filter [count] lines through the external program
  5704.             given with the 'equalprg' option.  When the 'equalprg'
  5705.             option is empty (this is the default), use the
  5706.             internal formatting function |C_indenting|.
  5707.  
  5708.                             *v_=*
  5709. {Visual}=        Filter the highlighted lines through the external
  5710.             program given with the 'equalprg' option.  When the
  5711.             'equalprg' option is empty (this is the default),
  5712.             use the internal formatting function |C_indenting|.
  5713.             (see the chapter on Visual mode |Visual_mode|).  {not
  5714.             in Vi}
  5715.  
  5716. A filter is a program that accepts text at standard input, changes it in some
  5717. way, and sends it to standard output.  The commands above can be used to send
  5718. some text through a filter.  An example of a filter is "sort", which sorts
  5719. lines alphabetically.  The "indent" program is used to pretty indent C programs
  5720. (you need a version of indent that works like a filter, not all versions do
  5721. that).  The shell, given with the 'shell' option, is used to execute the
  5722. command (See also the 'shelltype' option).  The filter commands can be redone
  5723. with ".".  There cannot be a comment (with '"') after the ":!" command.
  5724.  
  5725.  
  5726.                         *:s* *:substitute*
  5727. :[range]s[ubstitute]/{pattern}/{string}/[g][c][r][p] [count]
  5728.             For each line in [range] replace {pattern} with
  5729.             {string}.  See |:s_flags| for the [g], [c], [r] and
  5730.             [p] flags.
  5731.  
  5732. :[range]s[ubstitute] [g][c][r] [count]
  5733. :[range]&[g][c][r] [count]            *:&*
  5734.             Repeat last :substitute with same search pattern and
  5735.             substitute string.  The flags [g], [c] and [r] may be
  5736.             different (see |:s_flags|).
  5737.  
  5738. :[range]~[g][c][r] [count]            *:~*
  5739.             Repeat last substitute with same substitute string
  5740.             but with last used search pattern.  This is like
  5741.             "&r".  See explanation for [r], [c] and [g] below
  5742.             |:s_flags|.
  5743.  
  5744.                         *&*
  5745. &            Synonym for ":s//~/" (repeat last substitute).
  5746.  
  5747.                             *:s_flags*
  5748. The arguments that can be given to the substitute commands:
  5749. [g]    All occurrences in the line are replaced.  Otherwise only the first
  5750.     occurrence in the line is replaced.  If the 'edcompatible' option is
  5751.     on this flag is remembered and toggled each time it is used.  It is
  5752.     reset when a new search pattern is given.  If the 'gdefault' option
  5753.     is on, this flag is default on, give the [g] to switch it off.
  5754. [c]    Each substitute has to be confirmed.  The cursor is positioned on the
  5755.     matching string.  You can type:                *:s_c*
  5756.         'y'        to substitute this match
  5757.         'n'        to skip this match
  5758.         <Esc>   to skip this match
  5759.         'a'        to substitute this and all remaining matches {not in Vi}
  5760.         'q'        to quit substituting {not in Vi}
  5761.         CTRL-E  to scroll the screen up {not in Vi}
  5762.         CTRL-Y  to scroll the screen down {not in Vi}.
  5763.     If the 'edcompatible' option is on the [c] flag is remembered and
  5764.     toggled each time it is used.  It is reset when a new search pattern
  5765.     is given.
  5766. [r]    When the search pattern is empty use the previously used search
  5767.     pattern instead of the search pattern from the last substitute or
  5768.     ":global".  If the last command that did a search was a substitute or
  5769.     ":global" there is no effect.  If the last command was a search
  5770.     command, like "/", the pattern from that command is used.
  5771. [p]    Print the line containing the last substitute.
  5772. [count] That many lines are are searched, starting with the last line number
  5773.     in [range] (default current line |cmdline_ranges|).
  5774.  
  5775. If the {pattern} for the substitute command is empty, the pattern from the
  5776. last substitute or ":global" command is used.  With the [r] flag the pattern
  5777. from the last substitute, ":global" or search command is used.
  5778.  
  5779. For compatibility with Vi these two execptions are allowed:
  5780. "\/{string}/" and "\?{string}?" do the same as "//{string}/r".
  5781. "\&{string}&" does the same as "//{string}/".
  5782.  
  5783. Instead of the '/' which surrounds the pattern and replacement string, you
  5784. can use any other character, but not an alphanumeric character, '\', '"' or
  5785. '|'.  This is useful if you want to include a '/' in the search pattern or
  5786. replacement string.  Example: ":s+/+//+"
  5787.  
  5788. For the definition of a pattern see 6.6, "Pattern searches" |search_pattern|.
  5789.  
  5790. Some characters in {string} have a special meaning:
  5791.  
  5792. magic    nomagic      action
  5793.   &      \&      replaced with the whole matched pattern
  5794.  \&       &      replaced with &
  5795.       \0      replaced with the whole matched pattern
  5796.       \1      replaced with the matched pattern in the first pair of ()
  5797.       \2      replaced with the matched pattern in the second pair of ()
  5798.       ..      ..
  5799.       \9      replaced with the matched pattern in the ninth pair of ()
  5800.   ~      \~      replaced with the {string} of the previous substitute
  5801.  \~       ~      replaced with ~
  5802.       \u      next character made uppercase
  5803.       \U      following characters made uppercase
  5804.       \l      next character made lowercase
  5805.       \L      following characters made lowercase
  5806.       \e      end of /u, /U, /l and /L (NOTE: not <Esc>!)
  5807.       \E      end of /u, /U, /l and /L
  5808.       <CR>      split line in two at this point
  5809.       \r      idem
  5810.       \n      <NL>
  5811.       \b      <BS>
  5812.       \t      <Tab>
  5813.   CTRL-V <CR>      insert a carriage-return (CTRL-M)
  5814.  
  5815. Examples:
  5816. :s/a\|b/xxx\0xxx/g          modifies "a b"      in "xxxaxxx xxxbxxx"
  5817. :s/\([abc]\)\([efg]\)/\2\1/g  modifies "af fa bg" in "fa fa gb"
  5818. :s/abcde/abc^Mde/          modifies "abcde"      in "abc", "de" (two lines)
  5819. :s/$/^V^M/              modifies "abcde"      in "abcde^M"
  5820.  
  5821. Note: To insert a ^M you have to type CTRL-V <CR>.  To insert a ^V you have
  5822. to type CTRL-V CTRL-V.  So to insert the ^V^M in the last example you have to
  5823. type CTRL-V CTRL-V CTRL-V <CR>.
  5824.  
  5825. Because CTRL-V <CR> inserts a <CR>, it is impossible to insert a CTRL-V just
  5826. in front of a line break.  You will have to split it up in two parts:
  5827.     :s/foo/^Vxxxx/
  5828.     :s/xxxx/^M/
  5829.  
  5830. When using parentheses in combination with '|', like in \([ab]\)\|\([cd]\),
  5831. either the first or second pattern in parentheses did not match, so either
  5832. \1 or \2 is empty.  Example:
  5833. :s/\([ab]\)\|\([cd]\)/\1x/g   modifies "a b c d"  in "ax bx x x"
  5834.  
  5835.                             *:ret* *:retab*
  5836. :[range]ret[ab][!] [new_tabstop]
  5837.             All sequences of white-space containing a tab are
  5838.             replaced with new strings of white-space using the new
  5839.             tabstop value given.  If no new tabstop size is
  5840.             given, the current value of 'tabstop' is used.  With
  5841.             !, strings of normal spaces will also be replace with
  5842.             tabs where appropriate.  With 'expandtab' on, all
  5843.             tabs will be replaced with the appropriate number of
  5844.             spaces.  This command sets 'tabstop' to the new
  5845.             value given, and if performed on the whole file,
  5846.             which is default, should not make any visible
  5847.             change.  Careful: In a C program a <Tab> inside a
  5848.             string will also be affected.  Use "\t" to avoid this
  5849.             (that's a good habit anyway).  {not in Vi}
  5850.  
  5851.  
  5852. 11.4 Formatting text                        *formatting*
  5853.  
  5854. :[range]ce[nter] [width]                *:ce* *:center*
  5855.             Center lines in [range] between [width] columns
  5856.             (default 'textwidth' or 80 when 'textwidth' is 0).
  5857.             {not in Vi}
  5858.  
  5859. :[range]ri[ght] [width]                    *:ri* *:right*
  5860.             right align lines in [range] at [width] columns
  5861.             (default 'textwidth' or 80 when 'textwidth' is 0).
  5862.             {not in Vi}
  5863.  
  5864.                             *:le* *:left*
  5865. :[range]le[ft] [indent]    left align lines in [range].  Sets the indent in the
  5866.             lines to [indent] (default 0).  {not in Vi}
  5867.  
  5868. gq{motion}                        *Q* *gq*
  5869. Q{motion}        Format the lines that were moved over.  The length of
  5870.             each line will be restricted to the width given with
  5871.             the 'textwidth' option.  See below.  If the
  5872.             'textwidth' option is 0, the width of the screen is
  5873.             used (with a maximum of 79).  {not in Vi}
  5874.             NOTE: The "Q" command is used in Vi to go to Ex mode.
  5875.             In a future version of Vim this will be made
  5876.             compatible.  Use "gq" for formatting now, to avoid
  5877.             problems when upgrading to a newer version of Vim.
  5878.  
  5879. {Visual}gq                            *v_Q* *v_gq*
  5880. {Visual}Q        Format the highlighted text.  (see the chapter on
  5881.             Visual mode |Visual_mode|).  {not in Vi}
  5882.  
  5883. Example: To format the current paragraph use "gqp".
  5884.  
  5885. After the "gq" command the cursor is left in the line where the motion command
  5886. would take the cursor.  This allows for the formatting to be repeated with
  5887. ".".  This works fine with "gqj" (format current and next line) and "gq}"
  5888. (format until end of paragraph).  Note: When 'formatprg' is set, the cursor is
  5889. left on the first formatted line (like when using a filter command).
  5890.  
  5891. If the 'autoindent' option is on, the indent of the first line is used for
  5892. the following lines.
  5893.  
  5894. Empty lines are left unchanged (but lines with spaces or tabs are!).
  5895.  
  5896. The 'formatprg' option can be set to the name of an external program, which
  5897. will be used instead of the internal function.  The 'textwidth' and other
  5898. options will not be used then.
  5899.  
  5900.                             *format_comments*
  5901. Comments can be formatted in a special way.  A comment is recognized by a
  5902. specific string at the start of the line (ignoring white space).  Three types
  5903. of comments can be used:
  5904.  
  5905. - Repeating the comment string at the start of each line.  An example is the
  5906.   type of comment used in shell scripts, starting with "#".
  5907. - Only the first line has the comment string, following lines don't.  An
  5908.   example is this list with dashes.
  5909. - Three-piece comments, that have a start string, an end string and optional
  5910.   lines in between.  The strings for the start, middle and end are different.
  5911.   An example is the C-style comment:
  5912.       /*
  5913.      *  this is a C comment
  5914.      */
  5915.  
  5916. The 'comments' option can be set to a comma separated list of parts.  Each
  5917. part defines a type of comment that is recognized.  A part consists of:
  5918.     {flags}:{string}
  5919.  
  5920. {string} is the literal text that must appear.
  5921.  
  5922. {flags}:
  5923.   n    Nested comment.  Nesting with mixed parts is allowed.  If 'comments'
  5924.     is "n:),n:>" a line starting with "> ) >" is accepted as comment.
  5925.  
  5926.   b    Blank (<Space>, <Tab> or end-of-line) required after {string}.
  5927.  
  5928.   f    First line has comment only, will not be repeated on next line, but
  5929.     indent is kept (for bullet-lists).
  5930.   s    Start of three-piece comment
  5931.   m    Middle of a three-piece comment
  5932.   e    End of a three-piece comment
  5933.  
  5934.   l    Left adjust middle with start or end (default).  Only recognized when
  5935.       used together with 's' or 'e'.
  5936.   r    Right adjust middle with start or end.  Only recognized when used
  5937.       together with 's' or 'e'.
  5938.  
  5939. When neither 'f', 's', 'm' or 'e' is given, a repeated comment string is
  5940. assumed.  It is possible to have an empty flags field.
  5941.  
  5942. Blank space in the text before and after the {string} is also included.  The
  5943. {string} in the 'comments' option should not include leading or trailing
  5944. blanks (although it is allowed, in which case they are required).
  5945.  
  5946. When one comment leader is part of another, put it after that one.  For
  5947. example, to include both "-" and "->", use
  5948.     :set comments=f:->,f:-
  5949.  
  5950. A three-piece comment must always be given as start-middle-end, with no other
  5951. parts in between.  An example of a three-piece comment is "sr:/*,mb:*,el:*/"
  5952. for C-comments.  To avoid recognizing "*ptr" the 'b' flag is included for the
  5953. middle.  For three-piece comments the text after the start and middle is
  5954. checked for the appearance of the end.  If it is found, the comment will not
  5955. continue below.  The middle part must be present, because otherwise Vim can't
  5956. recognize the middle lines.
  5957.  
  5958. Examples:
  5959. "b:*"    Includes lines starting with "*", but not if the "*" is followed by a
  5960.     non-blank.  This avoids a pointer dereference like "*str" to be
  5961.     recognized as a comment.
  5962. "n:>"    Includes a line starting with ">", ">>", ">>>", etc.
  5963. "fb:-"    Format a list that starts with "- ".
  5964.  
  5965. By default, "b:#" is included.  This means that a line that starts with
  5966. "#include" is not recognized as a comment line.  But a line that starts with
  5967. "# define" is recognized.  In C code this is good, because somewhere after this
  5968. a "#endif" is needed.
  5969.  
  5970.                             *fo_table*
  5971. The 'formatoptions' option can be set to influence the way how comments are
  5972. formatted.  It is a string option, that may contain any of these letters.  The
  5973. default is "tcq".  Commas can be added for readability.
  5974.  
  5975. letter     meaning when present in 'formatoptions'
  5976.  
  5977. t    Do text autowrapping using textwidth
  5978. c    Do comment autowrapping using textwidth, inserting the current
  5979.     comment leader automatically.
  5980. r    Automatically insert the current comment leader after hitting
  5981.     <return> in insert mode.
  5982. o    Automatically insert the current comment leader after hitting 'o' or
  5983.     'O' in Normal mode.
  5984. q    Allow formatting of comments with "gq" (or "Q", which is obsolete).
  5985.     Note that blank lines, or lines containing only the comment leader
  5986.     will be left untouched.  A new paragraph starts after such a line, or
  5987.     when the comment leader changes.
  5988. 2    When formatting text the indent of the second line of a paragraph is
  5989.     used for the rest of the paragraph.  This allows for paragraphs with
  5990.     a different indent for the first line.
  5991. v    Vi-compatible auto wrapping in insert mode: Only break a line at a
  5992.     blank that has been entered during the current insert command.  (Note:
  5993.     this is not 100% Vi compatible, Vi has some "unexpected features" or
  5994.     bugs in this area.  It uses the screen column instead of the line
  5995.     column)
  5996. b    Like 'v', but only auto wrap if a blank has been entered at or before
  5997.     the wrap margin.  If the line was longer than 'textwidth' when the
  5998.     insert started, or no blank was entered in the current insert before
  5999.     reaching 'textwidth', there is no auto wrapping.
  6000. l    Long lines are not broken in insert mode: When a line was longer than
  6001.     'textwidth' when the insert command started it is not automatically
  6002.     formatted.
  6003.  
  6004. With 't' and 'c' you can decide when auto-wrapping is done:
  6005. value    action
  6006. ""    no automatic formatting, "gq" can be used for manual formatting
  6007. "t"    automatic formatting of text, not for comments
  6008. "c"    automatic formatting for comments, not for text (good for C code)
  6009. "tc"    automatic formatting for text and comments
  6010.  
  6011. Note that when 'textwidth' is 0, no formatting is done anyway (but the comment
  6012. leader is inserted).
  6013. Note that when 'paste' is on, no formatting is done at all.
  6014. Note that 'textwidth' can be non-zero even though auto-wrapping never occurs.
  6015. This is good because it can be used for formatting only in this case (with
  6016. "gq").
  6017.  
  6018. If "/*", "*" and/or "*/" are in the 'comments' variable, then Vim has some
  6019. built in stuff to treat these types of comments a bit more cleverly.
  6020. Opening a new line before or after "/*" or "*/" (with 'r' or 'o' present in
  6021. 'formatoptions') gives the correct start of the line automatically.  The same
  6022. happens with formatting and auto-wrapping. Opening a line after a line
  6023. starting with "/*" or "*" and containing "*/", will cause no comment leader to
  6024. be inserted, and the indent of the new line is taken from the line containing
  6025. the start of the comment.
  6026. E.g.:
  6027.     /*
  6028.      * Your typical comment.
  6029.      */
  6030.     The indent on this line is the same as the start of the above
  6031.     comment.
  6032.  
  6033. All this should be really cool, especially in conjunction with the new
  6034. :autocmd command to prepare different settings for different types of file.
  6035.  
  6036. Some examples:
  6037.   for C code:        fo="croq"    (only format comments)
  6038.   for Mail/news:    fo="tcrq"    (format all, don't start comment with "o"
  6039.                   command)
  6040.  
  6041.  
  6042. 11.5 Indenting C programs                *C_indenting*
  6043.  
  6044. C programs can be automatically indented.  Only the indent is set, no other
  6045. formatting is done.  To format comments see |format_comments|.
  6046.  
  6047. There are in fact three methods that can be used.
  6048. 'autoindent'    Just takes the indent from the previous line.
  6049. 'smartindent'    Is like 'autoindent' but also recognizes some C syntax to
  6050.         increase/reduce the indent where appropriate.
  6051. 'cindent'    Works more clever than the other two and can be configured to
  6052.         different indenting styles.
  6053. The rest of this section is about the 'cindent' option.
  6054.  
  6055. Note that the indenting done with 'cindent' does not work for 100%.  Vim is
  6056. not a C compiler, not all syntax is recognized.
  6057.  
  6058. Four options are used for C program indenting:
  6059. 'cindent'    When on automatic C program indenting is enabled.
  6060. 'cinkeys'    Keys that trigger reindenting in insert mode.
  6061. 'cinoptions'    For setting your preferred indent style.
  6062. 'cinwords'    Defines keywords that start an extra indent in the next line.
  6063.  
  6064. If 'lisp' is not on and 'equalprg' is empty, the "=" operator indents using
  6065. this algorithm rather than calling an external program.
  6066.  
  6067. See |autocommand| for how to automatically set the 'cindent' option for C code
  6068. files and reset it for others.
  6069.  
  6070.                             *'cinkeys'* *'cink'*
  6071. The 'cinkeys' option can be set to a string that says when to do indenting.
  6072. The default is "0{,0},:,0#,!^F,o,O,e".  This means that indenting is done
  6073. when:
  6074.     "0{"    typing '{' as the first character in a line
  6075.     "0}"    typing '}' as the first character in a line
  6076.     ":"    typing ':' anywhere
  6077.     "0#"    typing '#' as the first character in a line
  6078.     "!^F"    typing CTRL-F, which is not inserted
  6079.     "o"    typing a <CR> anywhere and for the "o" command (not in insert
  6080.         mode!)
  6081.     "O"    for the "O" command (not in insert mode!)
  6082.     "e"    typing the second 'e' for an "else" at the start of a line
  6083.  
  6084. Characters that can be prepended:
  6085. '!'    When the key is preceded with a '!' the key will not be inserted but
  6086.     will just cause the current line to be reindented.  This allows you to
  6087.     set a command key for reindenting the current line.  By default CTRL-F
  6088.     is used for this.  Careful with CTRL-I, you might think that it is a
  6089.     nice command for Indenting, but it is the same as a <Tab>.
  6090. '*'    When the key is preceded with a '*' the reindenting will be done
  6091.     before inserting the key.  If you use "*<Return>" this means that the
  6092.     current line will be reindented, before opening a new line.
  6093.  
  6094. When the key is not preceded with a '!' or '*' the reindenting will be done
  6095. after inserting the key.  So ';' will set the indentation of the line
  6096. including the ';'.
  6097.  
  6098. '0'    When a zero is used before the key (but after '!' or '*') it will only
  6099.     trigger reindenting if the key is the first character typed in the
  6100.     line.
  6101.  
  6102. Special key names:
  6103. <>    Angle brackets mean spelled-out names of keys.  For example: "<Up>",
  6104.     "<Ins>".
  6105. '^'    Letters preceded by a caret (^) are control characters.  For example:
  6106.     "^F" is CTRL-F.
  6107. 'o'    Means to reindent a line for the "o" command and whenever a new
  6108.     line is opened below the current one.  This includes hitting <Return>
  6109.     in insert mode.
  6110. 'O'    Means to reindent a line for the "O" command.
  6111. 'e'    Means to reindent a line that starts with "else" when an 'e' is
  6112.     inserted.
  6113.  
  6114. If you really want to reindent when you type 'o', 'O', 'e', '0', '<', '>', '*'
  6115. or '!', use "<o>", "<O>", "<e>", "<0>", "<<>", "<>>", "<*>" or "<!>",
  6116. respectively, for those keys.
  6117.  
  6118. For an emacs-style indent mode, where lines aren't indented every time you
  6119. press Return but only if you press Tab, I suggest:
  6120.     :set cinkeys=0{,0},:,0#,!<Tab>,!^F
  6121.  
  6122. Note: When the indent of the current line was changed manually, cindenting
  6123. won't be done for any key.  This is to avoid re-indenting after you changed
  6124. the indent by typing <BS>, <Tab> or <Space> in the indent, or used CTRL-T or
  6125. CTRL-D.
  6126.  
  6127. How the indenting is done can be set with 'cinoptions'.  In the list below,
  6128. "N" represents a number of your choice.  It can be negative.  When there is an
  6129. 's' after the number, it is multiplied with 'shiftwidth'.  "1s" is
  6130. 'shiftwidth', "2s" is two times 'shiftwidth', etc.  A decimal point is allowed
  6131. too: "-0.5s" is minus half a 'shiftwidth'.  The examples given below assume a
  6132. 'shiftwidth' of 4.
  6133.  
  6134.     >N    Amount added for "normal" indent.  Used after a line that should
  6135.           increase the indent (lines starting with "if", an opening brace,
  6136.           etc.).  (default 'shiftwidth').
  6137.  
  6138.             cino=               cino=>2             cino=>2s
  6139.           if (cond)           if (cond)           if (cond)
  6140.           {                   {                   {
  6141.               foo;              foo;                      foo;
  6142.           }                   }                   }
  6143.  
  6144.     eN    Add N to the prevailing indent inside a set of braces if the
  6145.           opening brace at the End of the line (more precise: is not the
  6146.           first character in a line).  This is useful if you want a
  6147.           different indent when the '{' is at the start of the line from
  6148.           when '{' is at the end of the line.  (default 0).
  6149.  
  6150.             cino=               cino=e2             cino=e-2
  6151.               if (cond) {         if (cond) {         if (cond) {
  6152.                   foo;                  foo;            foo;
  6153.               }                   }                   }
  6154.               else                else                else
  6155.               {                   {                   {
  6156.                   bar;                bar;                bar;
  6157.               }                   }                   }
  6158.  
  6159.     nN    Add N to the prevailing indent for a statement after an "if",
  6160.           "while", etc., if it is Not inside a set of braces.  This is
  6161.           useful if you want a different indent when there is no '{'
  6162.           before the statement from when there is a '{' before it.
  6163.           (default 0).
  6164.  
  6165.             cino=               cino=n2             cino=n-2
  6166.               if (cond)           if (cond)           if (cond)
  6167.                   foo;                  foo;            foo;
  6168.               else                else                else
  6169.               {                   {                   {
  6170.                   bar;                bar;                bar;
  6171.               }                   }                   }
  6172.  
  6173.     fN    The First opening brace of a function or other block is placed
  6174.           in column N.  Only for an opening brace that is not inside other
  6175.           braces and is at the start of the line.  What comes after the
  6176.           brace is put relative to this brace.  (default 0).
  6177.  
  6178.             cino=               cino=f.5s           cino=f1s
  6179.           func()              func()              func()
  6180.           {                     {                     {
  6181.               int foo;              int foo;              int foo;
  6182.  
  6183.     {N    Opening braces are placed N characters from the prevailing
  6184.           indent.  Only for opening braces that are inside
  6185.           other braces.  (default 0).
  6186.  
  6187.             cino=               cino={.5s           cino={1s
  6188.           if (cond)           if (cond)           if (cond)
  6189.           {                     {                     {
  6190.               foo;                foo;                foo;
  6191.  
  6192.     }N    Closing braces are placed N characters from the matching opening
  6193.           brace.  (default 0).
  6194.  
  6195.             cino=               cino={2,}-0.5s      cino=}2
  6196.           if (cond)           if (cond)           if (cond)
  6197.           {                     {                 {
  6198.               foo;                foo;                foo;
  6199.           }                   }                     }
  6200.  
  6201.     ^N    Add N to the prevailing indent inside a set of braces if the
  6202.           opening brace is in column 0.  This is used to have a different
  6203.           indent for whole of a function (some may like to set it to a
  6204.           negative number).  (default 0).
  6205.  
  6206.         cino=               cino=^-2            cino=^-s
  6207.           func()              func()              func()
  6208.           {                   {                   {
  6209.               if (cond)         if (cond)         if (cond)
  6210.               {                {                 {
  6211.               a = b;            a = b;            a = b;
  6212.               }                }                 }
  6213.           }                   }                   }
  6214.  
  6215.     :N    Case labels are placed N characters from the indent of the
  6216.           switch().  (default 'shiftwidth').
  6217.  
  6218.             cino=               cino=:0
  6219.           switch (x)          switch(x)
  6220.           {              {
  6221.               case 1:         case 1:
  6222.                   a = b;          a = b;
  6223.               default:          default:
  6224.           }              }
  6225.  
  6226.     =N    Statements after a case label are placed N characters from the
  6227.           indent of the label.  (default 'shiftwidth').
  6228.  
  6229.             cino=               cino==10
  6230.            case 11:        case 11:  a = a + 1;
  6231.                a = a + 1;                 b = b + 1;
  6232.  
  6233.     pN    Parameter declarations for K&R-style function declarations will
  6234.           be indented N characters from the margin.  (default
  6235.           'shiftwidth').
  6236.  
  6237.             cino=               cino=p0             cino=p2s
  6238.           func(a, b)          func(a, b)          func(a, b)
  6239.               int a;          int a;                      int a;
  6240.               char b;         char b;                     char b;
  6241.  
  6242.     tN    Type for a function declaration will be indented N characters
  6243.           from the margin.  (default 'shiftwidth').
  6244.  
  6245.             cino=               cino=t0             cino=t7
  6246.               int             int                        int
  6247.           func()              func()              func()
  6248.  
  6249.     +N    Continuation lines (lines that spill onto two) are indented N
  6250.           additional characters.  (default 'shiftwidth').
  6251.  
  6252.             cino=                     cino=+10
  6253.           a = b + 9 *               a = b + 9 *
  6254.               c;                              c;
  6255.  
  6256.     cN    Comment lines after the comment opener, when there is no other
  6257.           text to line up with, are indented N characters from the comment
  6258.           opener.  (default 3).  See also |format_comments|.
  6259.  
  6260.             cino=                     cino=c5
  6261.           /*                        /*
  6262.              text.                       text.
  6263.            */                 */
  6264.  
  6265.     (N    When in unclosed parentheses, indent N characters from the line
  6266.           with the unclosed parentheses.  When N is 0 or the line starts
  6267.           with '(' line up with the unclosed parentheses.  (default
  6268.           'shiftwidth' * 2).
  6269.  
  6270.             cino=                     cino=(0
  6271.           if (c1 && (c2 ||          if (c1 && (c2 ||
  6272.                     c3))                         c3))
  6273.               foo;            foo;
  6274.           if (c1 &&            if (c1 &&
  6275.                   (c2 || c3)            (c2 || c3)
  6276.              }                         }
  6277.  
  6278.     )N    Unclosed parentheses will be searched for at most N lines away.
  6279.           This is just to limit the time needed to search for parentheses.
  6280.           (default 20 lines).
  6281.  
  6282.     *N    Unclosed comments will be searched for at most N lines away.
  6283.           This is just to limit the time needed to search for the start of
  6284.           a comment.  (default 30 lines).
  6285.  
  6286. The defaults, spelled out in full, would be
  6287.     cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,ps,ts,+s,(2s,)20,*30
  6288.  
  6289. Lines are put in column 1 if:
  6290. - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
  6291. - It starts with a label (a keyword followed by ':', other than "case" and
  6292.   "default").
  6293. - Any combination of indentations causes the line to have less than 0
  6294.   indentation.
  6295.  
  6296.  
  6297. 12. Copying and moving text                *copy_move*
  6298. ===========================
  6299.  
  6300.                             *quote*
  6301. "<a-zA-Z0-9.%:-">    Use register <a-zA-Z0-9.%:-"> for next delete, yank
  6302.             or put (use uppercase character to append with
  6303.             delete and yank) (<.%:> only work with put).
  6304.  
  6305.                             *:reg* *:registers*
  6306. :reg[isters]        Display the contents of all numbered and named
  6307.             registers.  {not in Vi}
  6308.  
  6309. :reg[isters] {arg}    Display the contents of the numbered and named
  6310.             registers that are mentioned in {arg}.  For example:
  6311.                 :dis 1a
  6312.             to display registers '1' and 'a'.  Spaces are allowed
  6313.             in {arg}.  {not in Vi}
  6314.  
  6315.                             *:di* *:display*
  6316. :di[splay] [arg]    Same as :registers.  {not in Vi}
  6317.  
  6318.                             *y*
  6319. ["x]y{motion}        Yank {motion} text [into register x].
  6320.  
  6321.                             *yy*
  6322. ["x]yy            Yank [count] lines [into register x] (linewise).
  6323.  
  6324.                             *Y*
  6325. ["x]Y            yank [count] lines [into register x] (synonym for
  6326.             yy, linewise).  If you like "Y" to work from the
  6327.             cursor to the end of line (which is more logical,
  6328.             but not Vi-compatible) use ":map Y y$".
  6329.  
  6330.                             *v_y*
  6331. {Visual}["x]y        Yank the highlighed text [into register x] (see the
  6332.             chapter on Visual mode |Visual_mode|).  {not in Vi}
  6333.  
  6334.                             *v_Y*
  6335. {Visual}["x]Y        Yank the highlighted lines [into register x] (see the
  6336.             chapter on Visual mode |Visual_mode|).  {not in Vi}
  6337.  
  6338.                             *:y* *:yank*
  6339. :[range]y[ank] [x]    Yank [range] lines [into register x].
  6340.  
  6341. :[range]y[ank] [x] {count}
  6342.             Yank {count} lines, starting with last line number
  6343.             in [range] (default: current line |cmdline_ranges|),
  6344.             [into register x].
  6345.  
  6346.                             *p*
  6347. ["x]p            Put the text [from register x] after the cursor
  6348.             [count] times.  {Vi: no count}
  6349.  
  6350. ["x]P            or                    *P* *<MiddleMouse>*
  6351. ["x]<MiddleMouse>    Put the text [from register x] before the cursor
  6352.             [count] times.  Using the mouse only works when
  6353.             'mouse' contains 'n' or 'a'.  {Vi: no count}
  6354.  
  6355.                             *:pu* *:put*
  6356. :[line]pu[t] [x]    Put the text [from register x] after [line] (default
  6357.             current line).
  6358.  
  6359. :[line]pu[t]! [x]    Put the text [from register x] before [line] (default
  6360.             current line).
  6361.  
  6362. ["x]]p            or                    *]p* *]<MiddleMouse>*
  6363. ["x]]<MiddleMouse>      Like "p", but adjust the indent to the current line.
  6364.             Using the mouse only works when 'mouse' contains 'n'
  6365.             or 'a'.  {not in Vi}
  6366.  
  6367. ["x][P            or                    *[P*
  6368. ["x]]P            or                    *]P*
  6369. ["x][p            or                    *[p* *[<MiddleMouse>*
  6370. ["x][<MiddleMouse>    Like "P", but adjust the indent to the current line.
  6371.             Using the mouse only works when 'mouse' contains 'n'
  6372.             or 'a'.  {not in Vi}
  6373.  
  6374. These commands can be used to copy text from one place to another.  This is
  6375. done by first getting the text into a register with a yank, delete or change
  6376. command.  The register can then be inserted with a put command.  All registers
  6377. are kept when changing files.  Thus you can also use this to move text from
  6378. one file to another (the CTRL-^ command is a quick way to toggle between two
  6379. files).
  6380.  
  6381. The put commands can be repeated with "." (except for :put) and undone.  If
  6382. the command that was used to get the text into the register was linewise, the
  6383. text will be inserted below ("p") or above ("P") the line where the cursor
  6384. is.  Otherwise the text will be inserted after ("p") or before ("P") the
  6385. cursor.  With the ":put" command the text will always be inserted in the next
  6386. line.  You can exchange two characters with the command sequence "xp".  You
  6387. can exchange two lines with the command sequence "ddp".  You can exchange
  6388. two words with the command sequence "deep" (start with the cursor in the
  6389. blank space before the first word).  The "']" or "`]" command can be used
  6390. after the put command to move the cursor to the end of the inserted text,
  6391. "'[" or "`[" to move the cursor to the start.
  6392.  
  6393. If the command that was used to get the text into the register used
  6394. blockwise Visual mode, the block of text will be inserted before ("P") or
  6395. after ("p") the cursor column, in the current and next lines.  Vim will make
  6396. the whole block of text start in the same column.  Thus the inserted text
  6397. looks the same as when it was yanked or deleted.  Some <Tab> characters may
  6398. be replaced with spaces to make this happen.  However, if the width of the
  6399. block is not a multiple of a <Tab> width and the text after the inserted
  6400. block contains <Tab>s, that text may be misaligned.
  6401.  
  6402. Rationale:    In Vi the "y" command followed by a backwards motion would
  6403.         sometimes not move the cursor to the first yanked character,
  6404.         because redisplaying was skipped.  In Vim it always moves to
  6405.         the first character, like specified by Posix.
  6406.  
  6407. There are five types of registers:            *registers*
  6408. - The unnamed register ""            *quote_quote* *quotequote*
  6409. - 10 numbered registers "0 to "9        *quote_number* *quote0*
  6410. - The small delete register "-            *quote_-* *quote-*
  6411. - 26 named registers "a to "z or "A to "Z    *quote_alpha* *quotea*
  6412. - three read-only registers ":, ". and "%
  6413.  
  6414.     The unnamed register is the register where all text deleted with
  6415. the "d", "c", "s", "x" commands or copied with the yank "y" command is
  6416. placed, regardless of whether or not a specific register was used (e.g.
  6417. "xdd).  The contents of this register are used by any put command (p or P)
  6418. which does not specify a register.  Additionally it can be accessed by the
  6419. name '"'.  This means you have to type two double quotes.  {Vi: register
  6420. contents lost when changing files, no '"'}
  6421.     The numbered registers are filled with yank and delete commands.
  6422. Numbered register 0 is filled with the last yank command, unless another
  6423. register was specified with ["x].  Numbered register 1 is filled with the text
  6424. that was deleted by each delete or change command, unless another register was
  6425. specified or the text is less than one line (text deleted with "x" or "dw"
  6426. will be put in the small delete register).  The contents of register 1 are put
  6427. in 2, 2 in 3, and so forth.  The contents of register 9 are lost.  {Vi:
  6428. numbered register contents are lost when changing files; register 0 does not
  6429. exist}
  6430.     The small delete register is filled with delete commands that delete
  6431. less than one line, except when a register was specified with ["x].
  6432.     The named registers are only filled when you say so.  They are named
  6433. 'a' to 'z' normally.  If you use an uppercase letter, the same registers as
  6434. with the lower case letter is used, but the text is appended to the previous
  6435. register contents.  With a lower case letter the previous contents are lost.
  6436.     The read-only registers are '%', ':' and '.'.  They can only be used
  6437. with the commands "p", "P", ":put" and with CTRL-R.
  6438.                             *quote_.* *quote.*
  6439.     ".    Contains the last inserted text (the same as what is inserted
  6440.         with the insert mode commands CTRL-A and CTRL-@).  Note: this
  6441.         doesn't work with CTRL-R on the command line.  It works a bit
  6442.         differently, like inserting the text instead of putting it
  6443.         ('textwidth' and other options affect what is inserted).
  6444.                             *quote_%* *quote%*
  6445.     "%    Contains the name of the current file.
  6446.                             *quote_:* *quote:*
  6447.     ":    Contains the last command line.  It can be used with "@:",
  6448.         this repeats the last command line.
  6449.  
  6450. If you use a put command without specifying a register, the register that
  6451. was last written to is used (this is also the contents of the unnamed
  6452. register).  If you are confused, use the ":dis" command to find out what will
  6453. be put (all named and numbered registers are displayed; the unnamed register
  6454. is labelled '"').
  6455.  
  6456. The next three commands always work on whole lines.
  6457.  
  6458. :[range]co[py] {address}                *:co* *:copy*
  6459.             Copy the lines given by [range] to below the line
  6460.             given by {address}.
  6461.  
  6462.                             *:t*
  6463. :t            Synonym for copy.
  6464.  
  6465. :[range]m[ove] {address}                *:m* *:move*
  6466.             Move the lines given by [range] to below the line
  6467.             given by {address}.
  6468.  
  6469.  
  6470. 13. Visual mode                    *Visual_mode* *visual_mode*
  6471. ===============
  6472.  
  6473. Visual mode is a flexible and easy way to select a piece of text for an
  6474. operator.  It is the only way to select a block of text.  {Vi has no Visual
  6475. mode, the name "visual" is used for Normal mode, to distinguish it from Ex
  6476. mode}
  6477.  
  6478.                             *v*
  6479. v            start Visual mode per character.  {not in Vi}
  6480.  
  6481.                             *V*
  6482. V            start Visual mode linewise.  {not in Vi}
  6483.  
  6484.                             *CTRL-V*
  6485. CTRL-V            start Visual mode blockwise.  {not in Vi}
  6486.  
  6487.                             *v_o*
  6488. o            go to Other end of highlighted text: The current
  6489.             cursor position becomes the start of the highlighted
  6490.             text and the cursor is moved to the Other end of the
  6491.             highlighted text.  {not in Vi}
  6492.  
  6493.                             *gv* *v_gv*
  6494. gv            Start Visual mode with the same area as the previous
  6495.             area and the same mode.  In Visual mode the current and
  6496.             the previous Visual area are exchanged.  {not in Vi}
  6497.  
  6498.                             *<LeftMouse>*
  6499. <LeftMouse>        Set the current cursor position.  If Visual mode is
  6500.             active it is stopped.  Only when 'mouse' option is
  6501.             contains 'n' or 'a'.  If the position is within 'so'
  6502.             lines from the last line on the screen the text is
  6503.             scrolled up.  If the position is within 'so' lines from
  6504.             the first line on the screen the text is scrolled
  6505.             down.  {not in Vi}
  6506.  
  6507.                             *<RightMouse>*
  6508. <RightMouse>        Start Visual mode if it is not active.  The text from
  6509.             the cursor position to the position of the click is
  6510.             highlighted.  If Visual mode was already active move
  6511.             the start or end of the highlighted text, which ever
  6512.             is closest, to the position of the click.  Only when
  6513.             'mouse' option contains 'n' or 'a'.  {not in Vi}
  6514.  
  6515.                             *<LeftRelease>*
  6516. <LeftRelease>        This works like a <LeftMouse>, if it is not a
  6517.             the same position as <LeftMouse>.  In an xterm you
  6518.             won't see the selected area until the button is
  6519.             released.  Only when 'mouse' option contains 'n' or
  6520.             'a'.  {not in Vi}
  6521.  
  6522.  
  6523. To apply an operator on a piece of text:
  6524.     1. mark the start of the text with "v", "V" or CTRL-V
  6525.         The character under the cursor will be used as the start.
  6526.     2. move to the end of the text
  6527.         The text from the start of the Visual mode up to and
  6528.         including the character under the cursor is highlighted.
  6529.     3. hit an operator
  6530.         The highlighted characters will be operated upon.
  6531.  
  6532. The 'highlight' option can be used to set the display mode to use for
  6533. highlighting in Visual mode.
  6534.  
  6535. The highlighted text includes the character under the cursor.  On terminals
  6536. where it is possible to make the cursor invisible the cursor position is
  6537. also highlighted.  On terminals where this is not possible the cursor is
  6538. displayed normally.  If your cursor cannot be made invisible and you want Vim
  6539. to highlight the character under the cursor anyway, you could set the 't_cv'
  6540. and 't_ci' options to something harmless, for example:
  6541.     :set t_cv=^[^[ t_ci=^[^[
  6542.  
  6543. With "v" the text before the start position and after the end position will
  6544. not be highlighted.  However, All uppercase and non-alpha operators, except
  6545. "~", will work on whole lines anyway.  See the list of operators below.
  6546.  
  6547.                             *visual_block*
  6548. With CTRL-V (blockwise Visual mode) the highlighted text will be a rectangle
  6549. between start position and the cursor.  However, some operators work on whole
  6550. lines anyway (see the list below).  The change and substitute operators will
  6551. delete the highlighted text and then start insertion at the top left
  6552. position.
  6553.  
  6554. When the "$" command is used with blockwise Visual mode, the right end of the
  6555. highlighted text will be determined by the longest highlighted line.  This
  6556. stops when a motion command is used that does not move straight up or down.
  6557.  
  6558. If you use <Esc>, click the left mouse button or use any command that
  6559. does a jump to another buffer while in Visual mode, the highlighting stops
  6560. and no text is affected.  Also when you hit "v" in characterwise Visual mode,
  6561. "CTRL-V" in blockwise Visual mode or "V" in linewise Visual mode.  If you hit
  6562. CTRL-Z the highlighting stops and the editor is suspended or a new shell is
  6563. started |CTRL-Z|.
  6564.  
  6565.               new mode after typing:        *v_v* *v_CTRL-V* *v_V*
  6566. old mode             "v"              "CTRL-V"               "V"
  6567.  
  6568. Normal              Visual         blockwise Visual       linewise Visual
  6569. Visual              Normal         blockwise Visual       linewise Visual
  6570. blockwise Visual    Visual         Normal                 linewise Visual
  6571. linewise Visual     Visual         blockwise Visual       Normal
  6572.  
  6573. For moving the end of the block many commands can be used, but you cannot
  6574. use Ex commands, commands that make changes or abandon the file.  Commands
  6575. (starting with) ".pPiIaAO&", CTRL-^, "Z", CTRL-], CTRL-T, CTRL-R, CTRL-I
  6576. and CTRL-O cause a beep and Visual mode continues.
  6577.  
  6578. If Visual mode is not active and the "v", "V" or CTRL-V is preceded with a
  6579. count, the size of the previously highlighted area is used for a start.  You
  6580. can then move the end of the highlighted area and give an operator.  The type
  6581. of the old area is used (character, line or blockwise).
  6582. - Linewise Visual mode: The number of lines is multiplied with the count.
  6583. - Blockwise Visual mode: The number of lines and columns is multiplied with
  6584.   the count.
  6585. - Normal Visual mode within one line: The number of characters is multiplied
  6586.   with the count.
  6587. - Normal Visual mode with several lines: The number of lines is multiplied
  6588.   with the count, in the last line the same number of characters is used as
  6589.   in the last line in the previously highlighted area.
  6590. The start of the text is the Cursor position.  If the "$" command was used as
  6591. one of the last commands to extend the highlighted text, the area will be
  6592. extended to the rightmost column of the longest line.
  6593.  
  6594. If you want to highlight exactly the same area as the last time, you can use
  6595. "gv" |gv| |v_gv|.
  6596.  
  6597. The operators that can be used are:
  6598.     ~    switch case                    |v_~|
  6599.     d    delete                        |v_d|
  6600.     c    change                        |v_c|
  6601.     y    yank                        |v_y|
  6602.     >    shift right (1)(*)                |v_>|
  6603.     <    shift left (1)(*)                |v_<|
  6604.     !    filter through external command (1)        |v_!|
  6605.     =    filter through 'equalprg' option command (1)    |v_=|
  6606.     Q    format lines to 'textwidth' length (1)(obsolete) |v_Q|
  6607.     gq    format lines to 'textwidth' length (1)        |v_gq|
  6608.  
  6609. The objects that can be used are:
  6610.     a    word                        |v_a|
  6611.     A    WORD                        |v_A|
  6612.     s    sentence                    |v_s|
  6613.     p    paragraph                    |v_p|
  6614.     P    block                        |v_P|
  6615.  
  6616. Additionally the following commands can be used:
  6617.     :    start ex command for highlighted lines (1)    |v_:|
  6618.     r    change                        |v_r|
  6619.     C    change (2)                    |v_C|
  6620.     R    change (2)                    |v_R|
  6621.     x    delete                        |v_x|
  6622.     D    delete (2)                    |v_D|
  6623.     X    delete (2)                    |v_X|
  6624.     Y    yank (2)                    |v_Y|
  6625.     J    join (1)                    |v_J|
  6626.     U    make uppercase                    |v_U|
  6627.     u    make lowercase                    |v_u|
  6628.     ^]    find tag                    |v_CTRL-]|
  6629.  
  6630. (1): always whole lines, see |:visual_example|
  6631. (2): whole lines when not using CTRL-V
  6632. (*): in a future a blockwise shift will move the block only, not whole
  6633.      lines.
  6634.  
  6635. Note that the ":vmap" command can be used to specifically map keys in Visual
  6636. mode.
  6637.  
  6638. If you want to give a register name using the """ command, do this just before
  6639. typing the operator character: "v{move around}"xd".
  6640.  
  6641. If you want to give a count to the command, do this just before typing the
  6642. operator character: "v{move around}3>" (move lines 3 indents to the right).
  6643.  
  6644.                             *repeat_Visual*
  6645. When repeating a Visual mode operator, the operator will be applied to the
  6646. same amount of text as the last time:
  6647. - Linewise Visual mode: The same number of lines.
  6648. - Blockwise Visual mode: The same number of lines and columns.
  6649. - Normal Visual mode within one line: The same number of characters.
  6650. - Normal Visual mode with several lines: The same number of lines, in the
  6651.   last line the same number of characters as in the last line the last time.
  6652. The start of the text is the Cursor position.  If the "$" command was used as
  6653. one of the last commands to extend the highlighted text, the repeating will
  6654. be applied up to the rightmost column of the longest line.
  6655.  
  6656.                             *:visual_example*
  6657. Currently the ":" command works on whole lines only.  When you select part of
  6658. a line, doing something like ":!date" will replace the whole line.  If you
  6659. want only part of the line to be replaced you will have to make a mapping for
  6660. it.  In a future release ":" may work on partial lines.
  6661.  
  6662. Here is an example, to replace the selected text with the output of "date":
  6663.  
  6664.     :vmap _a <Esc>a<CR><Esc>`\<i<CR><Esc>!!date<CR>kJJ
  6665.  
  6666. (In the <> notation |<>|, when typing it you should type it literally; you
  6667. need to remove the 'B' and '<' flags from 'cpoptions')
  6668.  
  6669. What this does is:
  6670. <Esc>        stop Visual mode
  6671. a<CR><Esc>    break the line after the Visual area
  6672. `\<        jump to the start of the Visual area
  6673. i<CR><Esc>    break the line before the Visual area
  6674. !!date<CR>    filter the Visual text through date
  6675. kJJ        Join the lines again
  6676.  
  6677.                             *visual_search*
  6678. Here is an idea for a mapping that makes it possible to do a search for the
  6679. selected text:
  6680.  
  6681.     :vmap X y/<C-R>"<CR>
  6682.  
  6683. (In the <> notation |<>|, when typing it you should type it literally; you
  6684. need to remove the 'B' and '<' flags from 'cpoptions')
  6685.  
  6686. Note that special characters (like '.' and '*') will cause problems.
  6687.  
  6688.  
  6689. 14. Various commands                    *various*
  6690. ====================
  6691.  
  6692.                             *CTRL-L*
  6693. CTRL-L            Clear and redraw the screen.
  6694.  
  6695.                             *N<Del>*
  6696. <Del>            When entering a number: Remove the last digit.
  6697.             Note: if you like to use <BS> for this, add this
  6698.             mapping to your .vimrc:
  6699.                 :map CTRL-V <BS>   CTRL-V <Del>
  6700.             See |:fixdel| if your <Del> key does not do what you
  6701.             want.
  6702.  
  6703. :as[cii]    or                    *ga* *:as* *:ascii*
  6704. ga            Print the ascii value of the character under the
  6705.             cursor in decimal, hexadecimal and octal.  For
  6706.             example, when the cursor is on a 'R':
  6707.                 <R>  82,  Hex 52,  Octal 122
  6708.             When the character is a non-standard ASCII character,
  6709.             but printable according to the 'isprint' option, the
  6710.             non-printable version is also given.  When the
  6711.             character is larger than 127, the <M-x> form is also
  6712.             printed.  For example:
  6713.                 <~A>  <M-^A>  129,  Hex 81,  Octal 201
  6714.                 <p>  <|~>  <M-~>  254,  Hex fe,  Octal 376
  6715.             (where <p> is a special character)
  6716.             The <Nul> character in a file is stored internally as
  6717.             <NL>, but it will be shown as:
  6718.                 <^@>  0,  Hex 00,  Octal 000
  6719.             Mnemonic: Get Ascii value.  {not in Vi}
  6720.  
  6721.                             *:p* *:print*
  6722. :[range]p[rint]        Print [range] lines (default current line).
  6723.  
  6724. :[range]p[rint] {count}
  6725.             Print {count} lines, starting with [range] (default
  6726.             current line |cmdline_ranges|).
  6727.  
  6728.                             *:l* *:list*
  6729. :[range]l[ist] [count]
  6730.             Same as :print, but display unprintable characters
  6731.             with '^'.
  6732.  
  6733.                             *:nu* *:number*
  6734. :[range]nu[mber] [count]
  6735.             Same as :print, but precede each line with its line
  6736.             number.  (See also 'highlight' option).
  6737.  
  6738.                             *:#*
  6739. :[range]# [count]    synonym for :number.
  6740.  
  6741.                             *:=*
  6742. :=            Print the cursor line number.
  6743.  
  6744. :norm[al][!] {commands}                    *:norm* *:normal*
  6745.             Execute Normal mode commands {commands}.  This makes
  6746.             it possible to execute Normal mode commands typed on
  6747.             the command line.  {commands} is executed like it is
  6748.             typed.  For undo all commands are undone together.  If
  6749.             the [!] is given, mappings will not be used.
  6750.             {commands} should be a complete command.  If
  6751.             {commands} does not finish a command, more characters
  6752.             need to be typed, but the display isn't updated while
  6753.             doing this.
  6754.             Mostly useful for autocommands.  This command cannot
  6755.             be followed by another command, since any '|' is
  6756.             considered part of the command.  {not in vi, of
  6757.             course}
  6758.  
  6759.                             *:sh* *:shell*
  6760. :sh[ell]        Escape to a shell (name from 'shell' option).
  6761.  
  6762.                             *:!cmd* *:!*
  6763. :!{cmd}            Execute {cmd} with the shell.  See also the 'shell'
  6764.             and 'shelltype' option.  Any '!' in {cmd} is replaced
  6765.             with the previous external command (see also
  6766.             'cpoptions').  But not when there is a backslash
  6767.             before the '!', then that backslash is removed.
  6768.             Example: ":!ls" followed by ":!echo ! \! \\!"
  6769.             executes "echo ls ! \!".  Also see |shell_window|.
  6770.  
  6771.                             *:!!*
  6772. :!!            Repeat last ":!{cmd}".
  6773.  
  6774.                             *:ve* *:version*
  6775. :ve[rsion]        Print the version number of the editor.  If the
  6776.             compiler used understands "__DATE__" the compilation
  6777.             date is mentioned.  Otherwise a fixed release-date is
  6778.             shown.  The following lines contain information about
  6779.             which options were defined when Vim was compiled.
  6780.  
  6781. :ve[rsion] {nr}        Set the version number to {nr}.  Used in .vimrc files.
  6782.             When omitted Vim will give a warning message. If {nr}
  6783.             is higher than the current Vim version this will
  6784.             result in an error message.  {not in Vi}
  6785.  
  6786. :if                            *:if* *:endif*
  6787. :endif            Every Ex command in between the ":if" and ":endif" is
  6788.             ignored.  These two commands are just to allow for
  6789.             future expansions in a backwards compatible way.
  6790.             Nesting is allowed.  In Vim version 5 you will be able
  6791.             to use this:
  6792.                 :if version >= 500
  6793.                 :  version-5-specific-command
  6794.                 :endif
  6795.             {not in Vi}
  6796.  
  6797.                             *K*
  6798. K            Run a program to lookup the keyword under the
  6799.             cursor.  The name of the program is given with the
  6800.             'keywordprg' (kp) option (default is "man").  The
  6801.             keyword is formed of letters, numbers and the
  6802.             characters in 'iskeyword'.  The keyword under or
  6803.             right of the cursor is used.  The same can be done
  6804.             with the command
  6805.                 ":!{program} {keyword}".
  6806.             There is an example of a program to use in the tools
  6807.             directory of Vim.  It is called 'ref' and does a
  6808.             simple spelling check.
  6809.             If 'keywordprg' is empty, the ":help" command is used.
  6810.             {not in Vi}
  6811.  
  6812.                             *v_K*
  6813. {Visual}K        Like "K", but use the visually highlighted text for
  6814.             the keyword.  Only works when the highlighted text is
  6815.             not more than one line.  {not in Vi}
  6816.  
  6817. [N]gs                            *gs* *:sl* *:sleep*
  6818. :[N]sl[eep] [N]        Do nothing for [N] seconds.  Can be interrupted with
  6819.             CTRL-C (CTRL-Break on MS-DOS).  "gs" stands for "goto
  6820.             sleep".  While sleeping the cursor is positioned in
  6821.             the text (if visible).  {not in Vi}
  6822.  
  6823.  
  6824. 15. Repeating commands                    *repeating*
  6825. ======================
  6826.  
  6827. 15.1 Single repeats                    *single_repeat*
  6828.  
  6829.                             *.*
  6830. .            Repeat last change with count replaced with [count].
  6831.  
  6832. Simple changes can be repeated with the "." command.  Without a count, the
  6833. count of the last change is used.  If you enter a count, it will replace the
  6834. last one.  If the last change included a specification of a numbered register,
  6835. the register number will be incremented.  See the section on undo and redo for
  6836. an example how to use this |undo_redo|.  Note that when repeating a command
  6837. that used a Visual selection, the same SIZE of area is used, see
  6838. |repeat_Visual|.
  6839.  
  6840.                             *@:*
  6841. @:            Repeat last command line [count] times.
  6842.  
  6843.  
  6844. 15.2 Multiple repeats                    *multi_repeat*
  6845.  
  6846.                             *:g* *:global*
  6847. :[range]g[lobal]/{pattern}/[cmd]
  6848.             Execute the Ex command [cmd] (default ":p") on the
  6849.             lines within [range] where {pattern} matches.
  6850.  
  6851. :[range]g[lobal]!/{pattern}/[cmd]
  6852.             Execute the Ex command [cmd] (default ":p") on the
  6853.             lines within [range] where {pattern} does NOT match.
  6854.  
  6855.                             *:v* *:vglobal*
  6856. :[range]v[global]/{pattern}/[cmd]
  6857.             Same as :g!.
  6858.  
  6859. The global commands work by first scanning through the [range] lines and
  6860. marking each line where a match occurs.  In a second scan the [cmd] is
  6861. executed for each marked line with its line number prepended.  If a line is
  6862. changed or deleted its mark disappears.  The default for [range] is the whole
  6863. buffer (1,$).  Use "CTRL-C" to interrupt the command.  If an error message is
  6864. given for a line the global command aborts.
  6865.  
  6866. To repeat a non-Ex command, you can use the ":normal" command:
  6867.     :g/pat/normal {commands}
  6868. Make sure that {commands} ends with a whole command, otherwise Vim will wait
  6869. for you to type the rest of the command for each match.  The screen will not
  6870. have been updated, so you don't know what you are doing.  See |:normal|.
  6871.  
  6872. The undo/redo command will undo/redo the whole global command at once.
  6873. The previous context mark will only be set once (with "''" you go back to
  6874. where the cursor was before the global command).
  6875.  
  6876. The global command sets both the last used search pattern and the last used
  6877. substitute pattern (this is vi compatible).  This makes it easy to globally
  6878. replace a string:
  6879.     :g/pat/s//PAT/g
  6880. This replaces all occurences of "pat" with "PAT".  The same can be done with:
  6881.     :%s/pat/PAT/g
  6882. Which is two characters shorter!
  6883.  
  6884.  
  6885. 15.3 Complex repeats                    *complex_repeat*
  6886.  
  6887.                             *q*
  6888. q<0-9a-zA-Z">        Record typed characters into register <0-9a-zA-Z">
  6889.             (uppercase to append).  The 'q' command is disabled
  6890.             while executing a register.  {Vi: no recording}
  6891.  
  6892. q            Stops recording.  (Implementation note: The 'q' that
  6893.             stops recording is not stored in the register, unless
  6894.             it was the result of a mapping)  {Vi: no recording}
  6895.  
  6896.                             *@*
  6897. @<0-9a-z".>        Execute the contents of register <0-9a-z".> [count]
  6898.             times.  Note that register '%' (name of the current
  6899.             file) cannot be used.  See also |@:|.  {Vi: only named
  6900.             registers}
  6901.  
  6902.                             *@@*
  6903. @@            Repeat the previous @<0-9a-z":> [count] times.
  6904.  
  6905.                             *:@*
  6906. :[addr]@<0-9a-z">    Execute the contents of register <0-9a-z"> as an Ex
  6907.             command.  First set cursor at line [addr] (default is
  6908.             current line).  When the last line in the register does
  6909.             not have a <CR> it will be added automatically when
  6910.             the 'e' flag is present in 'cpoptions'.  {Vi: only in
  6911.             some versions} Future: Will execute the register for
  6912.             each line in the address range.
  6913.  
  6914.                             *:@:*
  6915. :[addr]@:        Repeat last command line.  First set cursor at line
  6916.             [addr] (default is current line).  {not in Vi}
  6917.  
  6918.                             *:@@*
  6919. :[addr]@@        Repeat the previous :@<0-9a-z">.  First set cursor at
  6920.             line [addr] (default is current line).  {Vi: only in
  6921.             some versions}
  6922.  
  6923.                             *:so* *:source*
  6924. :so[urce] {file}    Read Ex commands from {file}.
  6925.  
  6926. :so[urce]! {file}    Read Vim commands from {file}.  {not in Vi}
  6927.  
  6928. All commands and command sequences can be repeated by putting them in a named
  6929. register and then executing it.  There are two ways to get the commands in the
  6930. register:
  6931. - Use the record command "q".  You type the commands once, and while they are
  6932.   being executed they are stored in a register.  Easy, because you can see
  6933.   what you are doing.  If you make a mistake, 'put' the register into the
  6934.   file, edit the command sequence, and then delete it into the register
  6935.   again.  You can continue recording by appending to the register (use an
  6936.   uppercase letter).
  6937. - Delete or yank the command sequence into the register.
  6938.  
  6939. Often used command sequences can be put under a function key with the ':map'
  6940. command.
  6941.  
  6942. An alternative is to put the commands in a file, and execute them with the
  6943. ':source!' command.  Useful for long command sequences.  Can be combined with
  6944. the ':map' command to put complicated commands under a function key.
  6945.  
  6946. The ':source' command reads Ex commands from a file line by line.  You will
  6947. have to type any needed keyboard input.  The ':source!' command reads from a
  6948. script file character by character, interpreting each character as if you
  6949. typed it.
  6950.  
  6951. Example: When you give the ":!ls" command you are asked to "hit return to
  6952. continue".  If you ':source' a file with the line "!ls" in it, you will have
  6953. to type the return yourself.  But if you ':source!' a file with the line
  6954. ":!ls" in it, the next characters from that file are read until a <CR> is
  6955. found.  You will not have to type <CR> yourself, unless ":!ls" was the last
  6956. line in the file.
  6957.  
  6958. It is possible to put ':source[!]' commands in the script file, so you can
  6959. make a top-down hierarchy of script files.  The ':source' command can be
  6960. nested as deep as the number of files that can be opened at one time (about
  6961. 15).  The ':source!' command can be nested up to 15 levels deep.
  6962.  
  6963. In script files terminal-dependent key codes are represented by
  6964. terminal-independent two character codes.  This means that they can be used
  6965. in the same way on different kinds of terminals.  The first character of a
  6966. key code is 0x80 or 128, shown on the screen as "~@".  The second one can be
  6967. found in the list |key_notation|.  Any of these codes can also be entered
  6968. with CTRL-V followed by the three digit decimal code.  This does NOT work for
  6969. the <t_xx> termcap codes, these can only be used in mappings.
  6970.  
  6971.                             *:source_crnl*
  6972. MS-DOS, Win32 and OS/2: Files that are read with ":source" normally have
  6973. <CR>-<NL> line separators.  These always work.  If you are using a file with
  6974. <NL> line separators (for example, a file made on Unix), this will be
  6975. recognized if you have 'textauto' on and the first line does not end in a
  6976. <CR>.  This fails if the first line has something like ":map <F1> :help^M",
  6977. where "^M" is a <CR>.  If the first line ends in a <CR>, but following ones
  6978. don't, you will get an error message, because the <CR> from the first lines
  6979. will be lost.
  6980.  
  6981.  
  6982. 16. Undo and redo                    *undo_redo*
  6983. =================
  6984.  
  6985. <Undo>        or                    *undo* *<Undo>* *u*
  6986. u            Undo [count] changes.  {Vi: only one level}
  6987.  
  6988.                             *:u* *:undo*
  6989. :u[ndo]            Undo one change.  {Vi: only one level}
  6990.  
  6991.                             *CTRL-R*
  6992. CTRL-R            Redo [count] changes which were undone.  {Vi: redraw
  6993.             screen}
  6994.  
  6995.                             *:red* *:redo*
  6996. :red[o]            Redo one change which was undone.  {Vi: no redo}
  6997.  
  6998.                             *U*
  6999. U            Undo all latest changes on one line.  {Vi: while not
  7000.             moved off of it}
  7001.  
  7002. The last changes are remembered.  You can go back in time with the "u"
  7003. command.  You can then go forward again with the 'CTRL-R' command.  If you
  7004. make a new change after the "u" command, the 'CTRL-R' will not be possible
  7005. anymore.  The number of changes that are remembered is set with the
  7006. 'undolevels' option.  If it is zero, the old fashioned Vi undo is present:
  7007. one level of undo and undo undoes itself.  If it is negative no undo is
  7008. possible.  Use this if you are running out of memory.
  7009.  
  7010. The "U" command is treated by undo/redo just like any other command.  Thus a
  7011. "u" command undos a "U" command and a 'CTRL-R' command redoes it again.  When
  7012. mixing "U", "u" and 'CTRL-R' you will notice that the "U" command will
  7013. restore the situation of a line to before the previous "U" command.  This may
  7014. be confusing.  Try it out to get used to it.
  7015.  
  7016. When all changes have been undone the buffer is not considered to be changed.
  7017. Vim can then be exit with ":q" instead of ":q!".  {this is not in Vi}
  7018. Note that this is relative to the last write of the file.  Typing "u" after
  7019. ":w" actually changes the buffer, compared to what was written, so the buffer
  7020. is considered changed then.
  7021.  
  7022. The numbered registers can also be used for undoing deletes.  Each time you
  7023. delete text, it is put into register "1.  The contents of register "1 are
  7024. shifted to "2, etc.  The contents of register "9 are lost.  You can now get
  7025. back the most recent deleted text with the put command: '"1P'.  (also, if the
  7026. deleted text was the result of the last delete or copy operation, 'P' or 'p'
  7027. also works as this puts the contents of the unnamed register).  You can get
  7028. back the text of three deletes ago with '"3P'.
  7029.  
  7030. If you want to get back more than one part of deleted text, you can use a
  7031. special feature of the repeat command ".".  It will increase the number of the
  7032. register used.  So if you first do ""1P", the following "." will result in a
  7033. '"2P'.  Repeating this will result in all numbered registers being inserted.
  7034.  
  7035. Example:    If you deleted text with 'dd....' it can be restored with
  7036.         '"1P....'.
  7037.  
  7038. If you don't know in which register the deleted text is, you can use the
  7039. :display command.  An alternative is to try the first register with '"1P', and
  7040. if it is not what you want do 'u.'.  This will remove the contents of the
  7041. first put, and repeat the put command for the second register.  Repeat the
  7042. 'u.' until you got what you want.
  7043.  
  7044.  
  7045. 17. Key mapping                        *key_mapping*
  7046. ===============
  7047.  
  7048. There are commands to enter new mappings, remove mappings and list mappings:
  7049.  
  7050. :map    {lhs} {rhs}                    *:map*
  7051. :nm[ap] {lhs} {rhs}                    *:nm* *:nmap*
  7052. :vm[ap] {lhs} {rhs}                    *:vm* *:vmap*
  7053. :map!   {lhs} {rhs}                    *:map!*
  7054. :im[ap] {lhs} {rhs}                    *:im* *:imap*
  7055. :cm[ap] {lhs} {rhs}                    *:cm* *:cmap*
  7056.             Map the key sequence {lhs} to {rhs} for the modes
  7057.             where the map command applies.
  7058.  
  7059.  
  7060. :no[remap]  {lhs} {rhs}                    *:no*  *:noremap*
  7061. :nn[oremap] {lhs} {rhs}                    *:nn*  *:nnoremap*
  7062. :vn[oremap] {lhs} {rhs}                    *:vn*  *:vnoremap*
  7063. :no[remap]! {lhs} {rhs}                    *:no!* *:noremap!*
  7064. :ino[remap] {lhs} {rhs}                    *:ino* *:inoremap*
  7065. :cno[remap] {lhs} {rhs}                    *:cno* *:cnoremap*
  7066.             Map the key sequence {lhs} to {rhs} for the modes
  7067.             where the map command applies.  Disallow mapping of
  7068.             {rhs}. {not in Vi}
  7069.  
  7070.  
  7071. :unm[ap]  {lhs}                        *:unm*  *:unmap*
  7072. :nun[map] {lhs}                        *:nun*  *:nunmap*
  7073. :vu[nmap] {lhs}                        *:vu*   *:vunmap*
  7074. :unm[ap]! {lhs}                        *:unm!* *:unmap!*
  7075. :iu[nmap] {lhs}                        *:iu*   *:iunmap*
  7076. :cu[nmap] {lhs}                        *:cu*   *:cunmap*
  7077.             Remove the mapping of {lhs} for the modes where the
  7078.             map command applies.
  7079.  
  7080. :mapc[lear]                        *:mapc*  *:mapclear*
  7081. :nmapc[lear]                        *:nmapc* *:nmapclear*
  7082. :vmapc[lear]                        *:vmapc* *:vmapclear*
  7083. :mapc[lear]!                        *:mapc!* *:mapclear!*
  7084. :imapc[lear]                        *:imapc* *:imapclear*
  7085. :cmapc[lear]                        *:cmapc* *:cmapclear*
  7086.             Remove all mappings for the modes where the map
  7087.             command applies.  {not in Vi}
  7088.  
  7089. :map
  7090. :nm[ap]
  7091. :vm[ap]
  7092. :map!
  7093. :im[ap]
  7094. :cm[ap]
  7095.             List all key mappings for the modes where the map
  7096.             command applies.
  7097.  
  7098. :map    {lhs}                        *:map_l*
  7099. :nm[ap] {lhs}                        *:nmap_l*
  7100. :vm[ap] {lhs}                        *:vmap_l*
  7101. :map!   {lhs}                        *:map_l!*
  7102. :im[ap] {lhs}                        *:imap_l*
  7103. :cm[ap] {lhs}                        *:cmap_l*
  7104.             List the key mappings for the key sequences starting
  7105.             with {lhs} in the modes where the map command applies.
  7106.             {not in Vi}
  7107.  
  7108. These commands are used to map a key or key sequence to a string of
  7109. characters.  You can use this to put command sequences under function keys,
  7110. translate one key into another, etc.  See the "Options" chapter below for how
  7111. to save and restore the current mapping |options|.
  7112.  
  7113. There are four sets of mappings
  7114. - For Insert mode. These are also used in Replace mode.
  7115. - For Command-line mode: When entering a ":" or "/" command.
  7116. - For Normal mode: When typing commands.
  7117. - For Visual mode: When typing commands while the Visual area is highlighted.
  7118.  
  7119. Overview of which map command works in which mode:
  7120.  
  7121.     commands:                      modes:
  7122.                       Normal  Visual  Insert Command-line
  7123. :map   :noremap   :unmap   :mapclear         X       X       .         .
  7124. :nmap  :nnoremap  :nunmap  :nmapclear        X       .       .         .
  7125. :vmap  :vnoremap  :vunmap  :vmapclear        .       X       .         .
  7126. :map!  :noremap!  :unmap!  :mapclear!        .       .       X         X
  7127. :imap  :inoremap  :iunmap  :imapclear        .       .       X         .
  7128. :cmap  :cnoremap  :cunmap  :cmapclear        .       .       .         X
  7129.  
  7130. The original Vi did not have separate mappings for Normal/Visual mode and
  7131. Insert/Command-line mode.  Therefore the ":map" and ":map!" commands enter
  7132. and display mappings for both.  In Vim you can use the ":nmap", "vmap",
  7133. ":cmap" and ":imap" commands to enter mappings for each mode separately.
  7134. When listing mappings the character in column 1 is
  7135.  
  7136.     CHAR        MODE
  7137.     <Space>        Normal and Visual
  7138.      n        Normal
  7139.      v        Visual
  7140.      !        Insert and Command-line
  7141.      i        Insert
  7142.      c        Command-line
  7143.  
  7144. A "*" just before the {rhs} indicates that it is non-remappable.
  7145.  
  7146. Note: When using mappings for Visual mode, you can use the "'<" mark, which
  7147. is the start of the last selected Visual area |'<|.
  7148.  
  7149. Everything from the first non-blank after {lhs} up to the end of the line
  7150. (or '|') is considered to be part of {rhs}.  This allows the {rhs} to end
  7151. with a space.
  7152.  
  7153.                             *map_backslash*
  7154. Note that only CTRL-V is mentioned here as a special character for mappings
  7155. and abbreviations.  When 'cpoptions' does not contain 'B', a backslash can
  7156. also be used like CTRL-V.  The <> notation can be fully used then |<>|.  But
  7157. you cannot use "<C-V>" like CTRL-V to escape the special meaning of what
  7158. follows.
  7159.                             *map_CTRL_C*
  7160. It's not possible to use a CTRL-C in the {lhs}.  You just can't map CTRL-C.
  7161. The reason is that CTRL-C must always be available to break a running command.
  7162.  
  7163.                             *map_space_in_lhs*
  7164. To include a space in {lhs} precede it with a CTRL-V (type two CTRL-Vs for
  7165. each space).
  7166.                             *map_space_in_rhs*
  7167. If you want a {rhs} that starts with a space, precede {rhs} with a single
  7168. CTRL-V (you have to type CTRL-V two times).
  7169.                             *map_empty_rhs*
  7170. You can create an empty {rhs} by typing nothing after a single CTRL-V (you
  7171. have to type CTRL-V two times).  Unfortunately, you cannot do this in a vimrc
  7172. file.
  7173.  
  7174. It is not possible to put a comment after this command, because the '"'
  7175. character is considered to be part of the {rhs}.
  7176.  
  7177.                             *map_bar*
  7178. Since the '|' character is used to separate a map command from the next
  7179. command, you will have to do something special to include  a '|' in {rhs}.
  7180. There are three methods:
  7181.    use       works when                    example
  7182.    <Bar>     '<' is not in 'cpoptions'     :map _l :!ls <Bar> more^M
  7183.    \|        'b' is not in 'cpoptions'     :map _l :!ls \| more^M
  7184.    ^V|       always, in Vim and Vi         :map _l :!ls ^V| more^M
  7185.  
  7186. (here ^V stands for CTRL-V; to get one CTRL-V you have to type it twice; you
  7187. cannot use the <> notation "<C-V>" here).
  7188.  
  7189. All three work when you use the default setting for 'cpoptions'.
  7190.  
  7191. When 'b' is present in 'cpoptions', "\|" will be recognized as a mapping
  7192. ending in a '\' and then another command.  This is Vi compatible, but
  7193. unlogical when compared to other commands.
  7194.  
  7195. To avoid mapping of the characters you type in insert or Command-line mode,
  7196. type a CTRL-V first.  The mapping in Insert mode is disabled if the 'paste'
  7197. option is on.
  7198.  
  7199. Note that when an error is enountered (that causes an error message) the rest
  7200. of the mapping is not executed.  This is Vi-compatible.
  7201.  
  7202. Note that the second character (argument) of the commands @zZtTfF[]rm'`"v
  7203. and CTRL-X is not mapped.  This was done to be able to use all the named
  7204. registers and marks, even when the command with the same name has been
  7205. mapped.
  7206.  
  7207.                             *map-which-keys*
  7208. If you are going to map something, you will need to choose which key(s) to use
  7209. for the {lhs}.  You will have to avoid keys that are used for Vim commands,
  7210. otherwise you would not be able to use those commands anymore.  Here are a few
  7211. suggestions:
  7212. - Function keys <F2>, <F3>, etc..  Also the shifted function keys.  Note that
  7213.   <F1> is already used for the help command.
  7214. - Meta-keys (with the ALT key pressed).
  7215. - Use the "_" character and then any other character.  The "_" command does
  7216.   exist in Vim (see |_|), but you probably never use it.
  7217.  
  7218.                             *map-examples*
  7219. A few examples (given as you type them, for "<CR>" you type four characters;
  7220. the '<' flag must not be present in 'cpoptions' for this to work).
  7221.  
  7222.     :map <F3>  o#include 
  7223.     :map <M-g> /foo<CR>cwbar<Esc>
  7224.     :map _x    d/END/e<CR>
  7225.     :map! qq   quadrillion questions
  7226.  
  7227.                             *map-typing*
  7228. Vim will compare what you type with the start of a mapped sequence.  If there
  7229. is an incomplete match, it will get more characters until there either is a
  7230. complete match or until there is no match at all.  Example: If you map! "qq",
  7231. the first 'q' will not appear on the screen until you type another
  7232. character.  This is because Vim cannot know if the next character will be a
  7233. 'q' or not.  If the 'timeout' option is on (which is the default) Vim will
  7234. only wait for one second (or as long as specified with the 'timeoutlen'
  7235. option).  After that it assumes that the 'q' is to be interpreted as such.  If
  7236. type slowly, or your system is slow, reset the 'timeout' option.  Then you
  7237. might want to set the 'ttimeout' option.  See the "Options" chapter |options|.
  7238.  
  7239.                         *recursive_mapping*
  7240. If you include the {lhs} in the {rhs} you have a recursive mapping.  When
  7241. {lhs} is typed, it will be replaced with {rhs}.  When the {lhs} which is
  7242. included in {rhs} is encountered it will be replaced with {rhs}, and so on.
  7243. This makes it possible to repeat a command an infinite number of times.  The
  7244. only problem is that the only way to stop this is by causing an error.  The
  7245. macros to solve a maze uses this, look there for an example.  There is one
  7246. exception: If the {rhs} starts with {lhs}, the first character is not mapped
  7247. again (this is Vi compatible).
  7248. For example:
  7249.     :map ab abcd
  7250. will execute the "a" command and insert "bcd" in the text.  The "ab" in the
  7251. {rhs} will not be mapped again.
  7252.  
  7253. If you want to exchange the meaning of two keys you should use the :noremap
  7254. command.  For example:
  7255.     :noremap k j
  7256.     :noremap j k
  7257. This will exchange the cursor up and down commands.
  7258.  
  7259. With the normal :map command, when the 'remap' option is on, mapping takes
  7260. place until the text is found not to be a part of a {lhs}.  For example, if
  7261. you use:
  7262.     :map x y
  7263.     :map y x
  7264. Vim will replace x with y, and then y with x, etc.  When this has happened
  7265. 'maxmapdepth' times (default 1000), Vim will give the error message
  7266. "recursive mapping".
  7267.  
  7268. See the file "index" for keys that are not used and thus can be mapped
  7269. without losing any builtin function.  I suggest you use function keys,
  7270. and meta-keys.  If you are prepared to lose a command that you hardly ever use
  7271. you can make mappings that start with '_' or '-'.  You can also use
  7272. ":help <key>^D" to find out if a key is used for some command.  (<key> is the
  7273. specific key you want to find out about, ^D is CTRL-D).
  7274.  
  7275. If you include an undo command inside a mapped sequence, this will bring the
  7276. text back in the state before executing the macro.  This is compatible with
  7277. the original Vi, as long as there is only one undo command in the mapped
  7278. sequence (having two undo commands in a mapped sequence did not make sense
  7279. in the original Vi, you would get back the text before the first undo).
  7280.  
  7281. There are three ways to map a special key:
  7282. 1. The Vi-compatible method: Map the key code.  Often this is a sequence that
  7283.    starts with <Esc>.  To enter a mapping like this you type ":map " and then
  7284.    you have to type CTRL-V before hitting the function key.  Note that when
  7285.    the key code for the key is in the termcap (the t_ options), it will
  7286.    automatically be translated into the internal code and become the second
  7287.    way of mapping (unless the 'k' flag is included in 'cpoptions').
  7288. 2. The second method is to use the internal code for the function key.  To
  7289.    enter such a mapping type CTRL-K and then hit the function key, or use
  7290.    the form "#1", "#2", .. "#9", "#0", "<Up>", "<S-Down>", "<S-F7>", etc.
  7291.    (see table of keys |key_notation|, all keys from <Up> can be used).  The
  7292.    first ten function keys can be defined in two ways: Just the number, like
  7293.    "#2", and with "<F>", like "<F2>".  Both stand for function key 2.  "#0"
  7294.    refers to function key 10, defined with option 't_f10', which may be
  7295.    function key zero on some keyboards.  The <> form cannot be used when
  7296.    'cpoptions' includes the '<' flag.
  7297. 3. Use the termcap entry, with the form <t_xx>, where "xx" is the name of the
  7298.    termcap entry.  Any string entry can be used.  For example:
  7299.        :map <t_F3> G
  7300.    Maps function key 13 to "G".  This does not work if 'cpoptions' includes
  7301.    the '<' flag.
  7302.  
  7303. The advantage of the second and third method is that the mapping will work on
  7304. different terminals without modification (the function key will be
  7305. translated into the same internal code or the actual key code, no matter what
  7306. terminal you are using.  The termcap must be correct for this to work, and you
  7307. must use the same mappings).
  7308.  
  7309. DETAIL: Vim first checks if a sequence from the keyboard is mapped.  If it
  7310. isn't the terminal key codes are tried (see section 20.2
  7311. |terminal_options|).  If a terminal code is found it is replaced with the
  7312. internal code.  Then the check for a mapping is done again (so you can map an
  7313. internal code to something else).  What is written into the script file
  7314. depends on what is recognized.  If the terminal key code was recognized as a
  7315. mapping the key code itself is written to the script file.  If it was
  7316. recognized as a terminal code the internal code is written to the script
  7317. file.
  7318.  
  7319.  
  7320. 18. Recovery after a crash                *crash_recovery*
  7321. ==========================
  7322.  
  7323. You have spent several hours typing in that text that has to be finished
  7324. next morning, and then disaster strikes: Your computer crashes.
  7325.  
  7326.             DON'T PANIC!
  7327.  
  7328. You can recover most of your changes from the files that Vim uses to store
  7329. the contents of the file.  Mostly you can recover your work with one command:
  7330.     vim -r filename
  7331.  
  7332. 18.1 The swap file                    *swap_file*
  7333.  
  7334. Vim stores the things you changed in a swap file.  Using the original file
  7335. you started from plus the swap file you can mostly recover your work.
  7336.  
  7337. You can see the name of the current swap file being used with the command:
  7338.  
  7339.     :sw[apname]                    *:sw* *:swapname*
  7340.  
  7341. The name of the swap file is normally the same as the file you are editing,
  7342. with the extension ".swp".  On MS-DOS machines and when the 'shortname' option
  7343. is on, any '.' in the original file name is replaced with '_'.  If this file
  7344. already exists (e.g., when you are recovering from a crash) a warning is given
  7345. and another extension is used, ".swo", ".swn", etc.  An existing file will
  7346. never be overwritten.  The swap file is deleted as soon as Vim stops editing
  7347. the file.
  7348.  
  7349. Technical: The replacement of '.' with '_' is done to avoid problems with
  7350.        MS-DOS compatible filesystems (e.g., crossdos, multidos).  If Vim
  7351.        is able to detect that the file is on an MS-DOS-like filesystem, a
  7352.        flag is set that has the same effect as the 'shortname' option.
  7353.        This flag is reset when you start editing another file.
  7354.  
  7355.        If the ".swp" filename already exists, the last character is
  7356.        decremented until there is no file with that name or ".swa" is
  7357.        reached.  In the last case, no swap file is created.
  7358.  
  7359. By setting the 'directory' option you can place the swap file in another place
  7360. than where the edited file is.
  7361. Advantages:
  7362. - You will not pollute the directories with ".swp" files.
  7363. - When the 'directory' is on another partition, reduce the risk of damaging
  7364.   the file system where the file is (in a crash).
  7365. Disadvantages:
  7366. - You can get name collisions from files with the same name but in different
  7367.   directories (although Vim tries to avoid that by comparing the path name).
  7368.   This will result in bogus ATTENTION warning messages.
  7369. - When you use your home directory, and somebody else tries to edit the same
  7370.   file, he will not see your swap file and will not get the ATTENTION waring
  7371.   message.
  7372. On the Amiga you can also use a recoverable ram disk, but there is no 100%
  7373. guarantee that this works.  Putting swap files in a normal ram disk (like RAM:
  7374. on the Amiga) or in a place that is cleared when rebooting (like /tmp on Unix)
  7375. makes no sense, you will lose the swap file in a crash.
  7376.  
  7377. If you want to put swap files in a fixed place, put a command resembling the
  7378. following ones in your .vimrc:
  7379.     :set dir=dh2:tmp    (for Amiga)
  7380.     :set dir=~/tmp        (for Unix)
  7381.     :set dir=c:\\tmp    (for MS-DOS and Win32)
  7382. This is also very handy when editing files on floppy.  Of course you will have
  7383. to create that "tmp" directory for this to work!
  7384.  
  7385. When starting to edit a file, Vim checks if a swap file already exists for
  7386. that file.  If there is one, you will get a message indicating that something
  7387. is wrong:
  7388.  
  7389.     ATTENTION
  7390.     Found a swap file by the name "../doc/vim_ref.txt.swp"
  7391.              dated: Thu May 16 11:46:31 1996
  7392.          file name: ~mool/vim/vim/doc/vim_ref.txt
  7393.          host name: Kibaale
  7394.          user name: mool
  7395.         process ID: 211 (still running)
  7396.     While opening file "../doc/vim_ref.txt"
  7397.              dated: Wed May 15 21:38:40 1996
  7398.  
  7399. You are to take one of two actions:
  7400.  
  7401. 1. Quit editing this file, because another edit session is active on this
  7402.    file.  Continuing to edit will result in two versions of the same file.
  7403.    The one that is written last will overwrite the other one, resulting in
  7404.    loss of changes.  The text "(still running)" indicates that the process
  7405.    editing this file runs on the same computer (Unix only).  When working over
  7406.    a network you will not see this message, because the process will be
  7407.    running on another computer.
  7408. 2. Recover a previously crashed edit session.  See below |recovery|.
  7409.  
  7410. Vim cannot always detect that a swap file already exists for a file.  This is
  7411. the case when the other edit session puts the swap files in another
  7412. directory or when the path name for the file is different when editing it on
  7413. different machines.
  7414.  
  7415. The swap file is updated after typing 200 characters or when you have not
  7416. typed anything for four seconds.  This only happens if the buffer was
  7417. changed, not when you only moved around.  The reason why it is not kept up to
  7418. date all the time is that this would slow down normal work too much.  You can
  7419. change the 200 character count with the 'updatecount' option.  You can set
  7420. the time with the 'updatetime' option.  The time is given in milliseconds.
  7421. After writing to the swap file Vim syncs the file to disk.  This takes some
  7422. time, especially on busy Unix systems.  If you don't want this you can set the
  7423. 'swapsync' option to an empty string.  The risk of loosing work becomes bigger
  7424. though.  On some non-Unix systems (MS-DOS, Amiga) the swap file won't be
  7425. written at all.
  7426.  
  7427. If the writing to the swap file is not wanted, it can be switched off by
  7428. setting the 'updatecount' option to 0.  The same is done when starting Vim
  7429. with the "-n" option.  Writing can be switched back on by setting the
  7430. 'updatecount' option to non-zero.  Swap files will be created for all buffers
  7431. when doing this.  But when setting 'updatecount' to zero, the existing swap
  7432. files will not be removed, it will only affect files that will be opened
  7433. after this.
  7434.  
  7435. If you want to make sure that your changes are in the swap file use this
  7436. command:
  7437.  
  7438.                             *:pre* *:preserve*
  7439. :pre[serve]        Write all text for all buffers into swap file.  The
  7440.             original file is no longer needed for recovery.  {Vi:
  7441.             emergency exit}
  7442.  
  7443. A Vim swap file can be recognized by the first six characters: "b0VIM ".
  7444. After that comes the version number, e.g., "3.0".
  7445.  
  7446.  
  7447. 18.2 Recovery                        *recovery*
  7448.  
  7449. In most cases recovery is quite easy: Start Vim on the same file you were
  7450. editing when the crash happened, with the "-r" option added.  Vim will read
  7451. the ".swp" file and may read bits and pieces of the original file.
  7452.  
  7453. Example:    vim -r vim_ref.txt
  7454.  
  7455. If you were editing without a file name, give an empty string as argument:
  7456.         vim -r ""
  7457.  
  7458. If there are several swap files that look they may be the one you want to
  7459. use, a list is given of these swap files and you are requested to enter the
  7460. number of the one you want to use.  In case you don't know which one to use,
  7461. just try them one by one and check the resulting files if they are what you
  7462. expected.
  7463.  
  7464. If you know which swap file needs to be used, you can recover by giving the
  7465. swap file name.  Vim will then find out the name of the original file from
  7466. the swap file.
  7467.  
  7468. Example:    Vim -r vim_ref.txt.swo
  7469.  
  7470. This is also handy when the swap file is in another directory than expected.
  7471. If this still does not work, see what file names Vim reports and rename the
  7472. files accordingly.  Check the 'directory' option to see where Vim may have
  7473. put the swap file.
  7474.  
  7475. Note: Vim tries to find the swap file by searching the directories in the
  7476. 'dir' option, looking for files that match "filename.sw?".  If wildcard
  7477. expansion doesn't work (e.g., when the 'shell' option is invalid), Vim does a
  7478. desparate try to find the file "filename.swp".  If that fails too, you will
  7479. have to give the name of the swapfile itself to be able to recover the file.
  7480.  
  7481. Another way to do recovery is to start Vim and use the ":recover" command.
  7482. This is easy when you start Vim to edit a file and you get the "ATTENTION:
  7483. Found a swap file ..." message.  In this case the single command ":recover"
  7484. will do the work.  You can also give the name of the file or the swap file to
  7485. the recover command:
  7486.                             *:rec* *:recover*
  7487. :rec[over] [file]    Try to recover [file] from the swap file.  If [file]
  7488.             is not given use the file name for the current
  7489.             buffer.  The current contents of the buffer are lost.
  7490.             This command fails if the buffer was modified.
  7491.  
  7492. :rec[over]! [file]    Like ":recover", but any changes in the current
  7493.             buffer are lost.
  7494.  
  7495. Vim has some intelligence about what to do if the swap file is corrupt in
  7496. some way.  If Vim has doubt about what it found, it will give an error
  7497. message and insert lines with "???" in the text.  If you see an error message
  7498. while recovering, search in the file for "???" to see what is wrong.  You may
  7499. want to cut and paste to get the text you need.
  7500.  
  7501. Be sure that the recovery was successful before overwriting the original
  7502. file or deleting the swap file.  It is good practice to write the recovered
  7503. file elsewhere and run 'diff' to find out if the changes you want are in the
  7504. recovered file.
  7505.  
  7506. Once you are sure the recovery is ok delete the swap file.  Otherwise, you
  7507. will continue to get warning messages that the ".swp" file already exists.
  7508.  
  7509. {Vi: recovers in another way and sends mail if there is something to recover}
  7510.  
  7511.  
  7512. 19. Options                        *options*
  7513. ===========
  7514.  
  7515. Vi has a number of internal variables and switches which can be set to
  7516. achieve special effects.  These options come in three forms:
  7517.     toggle        can only be on or off        *toggle*
  7518.     number        has a numeric value
  7519.     string        has a string value
  7520.  
  7521. 19.1 Setting options                    *set_option*
  7522.  
  7523.                             *:se* *:set*
  7524. :se[t]            Show all options that differ from their default value.
  7525.  
  7526. :se[t] all        Show all but terminal options.
  7527.  
  7528. :se[t] termcap        Show all terminal options.
  7529.  
  7530. :se[t] {option}?    Show value of {option}.
  7531.  
  7532. :se[t] {option}        Toggle option: set, switch it on.
  7533.             Number option: show value.
  7534.             String option: show value.
  7535.  
  7536. :se[t] no{option}    Toggle option: Reset, switch it off.
  7537.  
  7538. :se[t] {option}!   or
  7539. :se[t] inv{option}    Toggle option: Invert value.  {not in Vi}
  7540.  
  7541. :se[t] {option}&    Reset option to its default value.  {not in Vi}
  7542.  
  7543. :se[t] {option}={value}        or
  7544. :se[t] {option}:{value}
  7545.             Set string or number option to {value}.  For numeric
  7546.             options the value can be given in decimal, hex
  7547.             (preceded with 0x) or octal (preceded with '0')
  7548.             (hex and octal are only available for machines which
  7549.             have the strtol() function).  The old value can be
  7550.             inserted by typing <Tab> (or whatever the value of
  7551.             'wildchar' is).  See 4.4.2 |cmdline_completion|.
  7552.             See |option_backslash| for using backslashes in
  7553.             {value}.
  7554.  
  7555.                             *:fix* *:fixdel*
  7556. :fix[del]        Set the value of 't_kD':
  7557.                 't_kb' is     't_kD' becomes
  7558.                   CTRL-?    CTRL-H
  7559.                 not CTRL-?    CTRL-?
  7560.  
  7561.             (CTRL-? is 0177 octal, 0x7f hex) {not in Vi}
  7562.  
  7563.             If your delete key terminal code is wrong, but the
  7564.             code for backspace is allright, you can put this in
  7565.             your .vimrc:
  7566.                 :fixdel
  7567.             This works no matter what the actual code for
  7568.             backspace is.
  7569.  
  7570.             If the backspace key terminal code is
  7571.             wrong you can use this:
  7572.                 :set t_kb=^V<BS>
  7573.                 :fixdel
  7574.             Where "^V" is CTRL-V and "<BS>" is the backspace
  7575.             key.  This will only work for terminals with the same
  7576.             code for the backspace key, you cannot use this in
  7577.             your .vimrc unless the code for backspace is the same
  7578.             on all your systems.
  7579.  
  7580.             If your <Delete> key sends a strange key sequence (not
  7581.             CTRL-? or CTRL-H) you cannot use ":fixdel".  Then use:
  7582.                 :set t_kD=^V<Delete>
  7583.             Where "^V" is CTRL-V and "<Delete>" is the delete key.
  7584.             This will only work on systems with the same terminal
  7585.             codes for delete.
  7586.  
  7587.             Note about Linux: By default the backspace key
  7588.             produces CTRL-?, which is wrong.  You can fix it by
  7589.             putting this line in your rc.local:
  7590.                 echo "keycode 14 = BackSpace" | loadkeys
  7591.  
  7592. The {option} arguments to ":set" may be repeated.  For example:
  7593.     ":set ai nosi sw=3 ts=3".
  7594. If you make an error in one of the arguments an error message will be given
  7595. and the text up to the next space will be skipped.  Thus following arguments
  7596. will be processed.
  7597.  
  7598. For {option} the form "t_xx" may be used to set a termcap option.  This will
  7599. override the value from the termcap.  You can then use it in a mapping.  If
  7600. the "xx" part contains special characters, use the <t_xx> form:
  7601.     :set <t_#4>=^[Ot
  7602.  
  7603. The listing from ":set" looks different from Vi.  Long string options are put
  7604. at the end of the list.  The number of options is quite large.  The output of
  7605. "set all" probably does not fit on the screen, causing Vim to give the
  7606. "--more--" message.  See the 'more' option.
  7607.  
  7608.                         *:set_env* *expand_env*
  7609. Environment variables in most string options will be expanded.  If the
  7610. environment variable exists the '$' and the following environment variable
  7611. name is replaced with its value.  If it does not exist the '$' and the name
  7612. are not modified.  Any non-id character (not a letter, digit or '_') may
  7613. follow the environment variable name.  That character and what follows is
  7614. appended to the value of the environment variable.  Examples:
  7615.     :set term=$TERM.new
  7616.     :set path=/usr/$INCLUDE,$HOME/include,.
  7617.  
  7618. Using "~" is like using "$HOME", but it is only recognized at the start of an
  7619. option and after a space or comma.
  7620.  
  7621. On Unix systems the form "${HOME}" can be used too.  The name between {} can
  7622. contain non-id characters then.  Note that if you want to use this for the
  7623. "gf" command, you need to add the '{' and '}' characters to 'isfname'.
  7624.  
  7625. Note the maximum lenght of an expanded option is limited.  How much depends on
  7626. the system, mostly it is something like 256 or 1024 characters.
  7627.  
  7628.                             *option_backslash*
  7629. To include white space in a string option value it has to be preceded with a
  7630. backslash.  To include a backslash you have to use two.  Effectively this
  7631. means that the number of backslashes in an option value is halved (rounded
  7632. down).
  7633. A few examples:
  7634.     :set tags=tags\ /usr/tags     results in "tags /usr/tags"
  7635.     :set tags=tags\\,file        results in "tags\,file"
  7636.     :set tags=tags\\\ file        results in "tags\ file"
  7637.  
  7638. For MS-DOS and WIN32 backslashes in file names are mostly not removed.  More
  7639. precise: For options that expect a file name (those where environment
  7640. variables are expanded) a backslash before a normal file name character is not
  7641. removed.  But a backslash before a special character (space, backslash, comma,
  7642. etc.) is used like explained above.
  7643.  
  7644.  
  7645. 19.2 Automatically setting options            *auto_setting*
  7646.  
  7647. Besides changing options with the ":set" command, there are three alternatives
  7648. to set options automatically for one or more files:
  7649.  
  7650. 1. When starting Vim initializations are read from various places.  See
  7651.    |initialization|.  Most of them are performed for all editing sessions,
  7652.    and some of them depend on the directory where Vim is started.
  7653. 2. If you start editing a new file, the automatic commands are executed.
  7654.    This can be used to set options for files matching a particular pattern and
  7655.    many other things.  See the section "Automatic commands" |autocommand|.
  7656. 3. If you start editing a new file, and the 'modeline' option is on, a
  7657.    number of lines at the beginning and end of the file are checked for
  7658.    modelines.  This is explained here.
  7659.  
  7660.                             *modeline*
  7661. There are two forms of modelines.  The first form:
  7662.     [text]{white}{vi:|vim:|ex:}[white]{options}
  7663.  
  7664. [text]        any text or empty
  7665. {white}        at least one white space (<Space> or <Tab>)
  7666. {vi:|vim:|ex:}    the string "vi:", "vim:" or "ex:"
  7667. [white]        optional white space
  7668. {options}    a list of option settings, separated with white space or ':',
  7669.         where each part between ':' is the argument for a ":set"
  7670.         command
  7671.  
  7672. Example:
  7673.     " vi:noai:sw=3 ts=6"
  7674.  
  7675. The second form (this is compatible with some versions of Vi):
  7676.  
  7677.     [text]{white}{vi:|vim:|ex:}[white]set {options}:[text]
  7678.  
  7679. [text]        any text or empty
  7680. {white}        at least one white space (<Space> or <Tab>)
  7681. {vi:|vim:|ex:}    the string "vi:", "vim:" or "ex:"
  7682. [white]        optional white space
  7683. set         the string "set " (note the space)
  7684. {options}    a list of options, separated with white space, which is the
  7685.         argument for a ":set" command
  7686. :        a colon
  7687. [text]        any text or empty
  7688.  
  7689. Example:
  7690.     "/* vim: set ai tw=75: */"
  7691.  
  7692. The white space before {vi:|vim:|ex:} is required.  This minimizes the chance
  7693. that a normal word like "lex:" is caught.  There is one exception: "vi:" and
  7694. "vim:" can also be at the start of the line (for compatibility with version
  7695. 3.0).  Using "ex:" at the start of the line will be ignored (this could be
  7696. short for "example:").
  7697.  
  7698. The number of lines that are checked can be set with the 'modelines' option.
  7699. If 'modeline' is off or 'modelines' is 0 no lines are checked.
  7700.  
  7701. Note that for the first form all of the rest of the line is used, thus a line
  7702. like:
  7703.     "/* vi:ts=4: */"
  7704. will give an error message for the trailing "*/".  This line is OK:
  7705.     "/* vi:set ts=4: */"
  7706.  
  7707. If an error is detected the rest of the line is skipped.
  7708.  
  7709. If you want to include a ':' in a set command precede it with a '\'.  No other
  7710. commands than "set" are supported, for security reasons (somebody might create
  7711. a trojan horse text file with modelines).
  7712.  
  7713.  
  7714. 19.3 Saving settings                    *save_settings*
  7715.  
  7716.                             *:mk* *:mkexrc*
  7717. :mk[exrc] [file]    Write current key mappings and changed options to
  7718.             [file] (default ".exrc" in the current directory),
  7719.             unless it already exists.  {not in Vi}
  7720.  
  7721. :mk[exrc]! [file]    Always write current key mappings and changed
  7722.             options to [file] (default ".exrc" in the current
  7723.             directory).  {not in Vi}
  7724.  
  7725.                             *:mkv* *:mkvimrc*
  7726. :mkv[imrc][!] [file]    Like as :mkexrc, but default is ".vimrc" in the
  7727.             current directory.  The ":version" command is also
  7728.             written to the file.  {not in Vi}
  7729.  
  7730. These commands will write ":map" and ":set" commands to a file, in such a way
  7731. that when these commands are executed, the current key mappings and options
  7732. will be set to the same values.  The options 'columns', 'endofline', 'lines',
  7733. 'modified', 'scroll', 'term' and 'ttyfast' are not included, because these are
  7734. terminal or file dependent.  Note that the options 'binary', 'textmode',
  7735. 'paste' and 'readonly' are included, this might not always be what you want.
  7736.  
  7737. A common method is to use a default ".vimrc" file, make some modifications
  7738. with ":map" and ":set" commands and write the modified file.  First read the
  7739. default ".vimrc" in with a command like ":source ~piet/.vimrc.Cprogs", change
  7740. the settings and then save them in the current directory with ":mkvimrc!".  If
  7741. you want to make this file your default .vimrc, move it to your home directory
  7742. (on Unix), s: (Amiga) or $VIM directory (MS-DOS).  You could also use
  7743. autocommands |autocommand| and/or modelines |modeline|.
  7744.  
  7745.  
  7746. 19.4 Options summary                *option_summary*
  7747.  
  7748. In the list below all the options are mentioned with their full name and some
  7749. with an abbreviation between parens.  Both forms may be used.  In this
  7750. document when an option that can be toggled is "set" that means that ":set
  7751. option" is entered.  When an option is "reset", ":set nooption" is used.
  7752.  
  7753. Most options are the same in all windows and buffers.  There are a few that
  7754. are specific to how the text is presented in a window.  These can be set to a
  7755. different value in each window.  For example the 'list' option can be set in
  7756. one window and reset in another for the same text, giving both types of view
  7757. at the same time.  There are a few options that are specific to a certain
  7758. file.  These can have a different value for each file or buffer.  For example
  7759. the 'textwith' option can be 78 for a normal text file and 0 for a C
  7760. program.
  7761.  
  7762.     global            one option for all buffers and windows
  7763.     local to window        each window has its own copy of this option
  7764.     local to buffer        each buffer has its own copy of this option
  7765.  
  7766. When creating a new window the option values from the currently active window
  7767. are used as a default value for the window-specific options.  For the
  7768. buffer-specific options this depends on the 's' and 'S' flags in the
  7769. 'cpoptions' option.  If 's' in included (which is the default) the values for
  7770. buffer options are copied from the currently active buffer when a buffer is
  7771. first entered.  If 'S' is present the options are copied each time the buffer
  7772. is entered, this is almost like having global options.  If 's' and 'S' are not
  7773. present, the options are copied from the currently active buffer when the
  7774. buffer is created.
  7775.  
  7776. A jump table for the options with a short description can be found at |X_op|.
  7777.  
  7778.                     *'aleph'* *'al'*
  7779. aleph (al)        number  (default 128 for MS-DOS, 224 otherwise)
  7780.             global
  7781.             {not in Vi}
  7782.             {This option applies only if Vim was compiled with
  7783.             RIGHTLEFT defined}
  7784.     The ASCII code for the first letter of the Hebrew alphabet.  The
  7785.     routine that maps the keyboard in Hebrew mode, both in Insert mode
  7786.     (when hkmap is set) and on the command line (when hitting CTRL-_)
  7787.     outputs the Hebrew characters in the range [aleph..aleph+26].
  7788.     aleph=128 applies to PC code, and aleph=224 applies to ISO 8859-8.
  7789.     See |vim_rlh.txt|.
  7790.  
  7791.                    *'autoindent'* *'ai'* *'noautoindent'* *'noai'*
  7792. autoindent (ai)        toggle    (default off)
  7793.             local to buffer
  7794.     Copy indent from current line when starting a new line (typing <CR>
  7795.     in Insert mode or when using the "o" or "O" command).  If you do not
  7796.     type anything on the new line except <BS> and then type <Esc> or
  7797.     <CR>, the indent is deleted again.  When autoindent is on,
  7798.     formatting (with the "gq" command or when you reach 'textwidth' in
  7799.     Insert mode) uses the indentation of the first line.   When
  7800.     'smartindent' or 'cindent' is on the indent is changed in specific
  7801.     cases.  The 'autoindent' option is reset when the 'paste' option is
  7802.     set.  {small difference from Vi: After the indent is deleted when
  7803.     typing <Esc> or <CR>, the cursor position when moving up or down is
  7804.     after the deleted indent; Vi puts the cursor somewhere in the deleted
  7805.     indent}.
  7806.  
  7807.                  *'autowrite'* *'aw'* *'noautowrite'* *'noaw'*
  7808. autowrite (aw)        toggle    (default off)
  7809.             global
  7810.     Write the contents of the file, if it has been modified, on each
  7811.     :next, :rewind, :previous, :stop, :suspend, :tag, :!, :make, CTRL-]
  7812.     and CTRL-^ command; and when a CTRL-O, CTRL-I, '<A-Z0-9>, or `<A-Z0-9>
  7813.     command takes one to another file.
  7814.  
  7815.                     *'backspace'* *'bs'*
  7816. backspace (bs)        number    (default 0)
  7817.             global
  7818.             {not in Vi}
  7819.     Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
  7820.     mode.  If set to 0 Vi compatible backspacing is used.  When 1 allow
  7821.     backspacing over newlines.  When larger than 1 allow backspacing over
  7822.     the start of insert.  In the last case CTRL-W and CTRL-U stop once at
  7823.     the start of insert.  See |:fixdel| if your <BS> or <Del> key does not
  7824.     do what you want.
  7825.  
  7826.                        *'backup'* *'bk'* *'nobackup'* *'nobk'*
  7827. backup (bk)        toggle    (default off)
  7828.             global
  7829.             {not in Vi}
  7830.     Make a backup before overwriting a file.  Leave it around after the
  7831.     file has been successfully written.  If you do not want to keep the
  7832.     backup file, but you do want a backup while the file is being
  7833.     written, reset this option and set the 'writebackup' option (this is
  7834.     the default).  If you do not want a backup file at all reset both
  7835.     options (use this if your file system is almost full).  See the table
  7836.     in section 5.4 for more explanations |backup_table|.
  7837.  
  7838.                         *'backupdir'* *'bdir'*
  7839. backupdir (bdir)    string    (default for Amiga: ".,t:",
  7840.                  for MS-DOS and Win32: ".,c:/tmp,c:/temp"
  7841.                  for Unix: ".,~/tmp,~/")
  7842.             global
  7843.             {not in Vi}
  7844.     List of directories for the backup file, separated with commas.
  7845.     - The backup file will be created in the first directory in the list
  7846.       where this is possible.
  7847.     - Empty means that no backup file will be created ('patchmode' is
  7848.       impossible!).
  7849.     - A directory "." means to put the backup file in the same directory
  7850.       as the edited file.
  7851.     - A directory starting with "./" (or ".\" for MS-DOS et.al.) means to
  7852.       put the backup file relative to where the edited file is.  The
  7853.       leading "." is replaced with the path name of the edited file.
  7854.     - Spaces after the comma are ignored, other spaces are considered part
  7855.       of the directory name.  To have a space at the start of a directory
  7856.       name, precede it with a backslash.
  7857.     - To include a comma in a directory name precede it with a backslash.
  7858.     - A directory name may end in an '/'.
  7859.     - Environment variables are expanded |:set_env|.
  7860.     - Careful with '\' characters, type one before a space, type two to
  7861.       get one in the option (see |option_backslash|), for example:
  7862.         :set bdir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces
  7863.     - For backwards compatibility with Vim version 3.0 a '>' at the start
  7864.       of the option is removed.
  7865.     See also 'backup' and 'writebackup' options.
  7866.  
  7867.                         *'backupext'* *'bex'*
  7868. backupext (bex)        string    (default "~")
  7869.             global
  7870.             {not in Vi}
  7871.     String which is appended to a file name to make the name of the
  7872.     backup file.  The default is quite unusual, because this avoids
  7873.     accidently overwriting existing files with a backup file.  You might
  7874.     prefer using ".bak", but make sure that you don't have files with
  7875.     ".bak" that you want to keep.
  7876.  
  7877.                      *'binary'* *'bin'* *'nobinary'* *'nobin'*
  7878. binary (bin)        toggle    (default off)
  7879.             local to buffer
  7880.             {not in Vi}
  7881.     This option should be set before editing a binary file.  You can also
  7882.     use the "-b" Vim argument.  When this option is switched on a few
  7883.     options will be changed (also when it already was on):
  7884.         'textwidth'  will be set to 0
  7885.         'wrapmargin' will be set to 0
  7886.         'modeline'   will be off
  7887.         'textmode'   will be off
  7888.         'textauto'   will be off
  7889.         'expandtab'  will be off
  7890.     NOTE: When you start editing a(nother) file while the 'bin' option is
  7891.     on, settings from the modelines or autocommands may change the
  7892.     settings again (e.g., 'textwidth'), causing trouble when editing.  You
  7893.     might want to set 'bin' again when the file has been loaded.
  7894.     The previous values of these options are remembered and restored when
  7895.     'bin' is switched fron on to off.  Each buffer has its own set of
  7896.     saved option values, except for 'textauto', which is global.
  7897.     When writing a file the end-of-line for the last line is only written
  7898.     if there was one in the original file (normally Vim appends an
  7899.     end-of-line to the last line if there is none; this would make the
  7900.     file longer).  See the 'endofline' option.
  7901.  
  7902.                    *'bioskey'* *'biosk'* *'nobioskey'* *'nobiosk'*
  7903. bioskey (biosk)        toggle    (default on)
  7904.             global
  7905.             {not in Vi}  {Only for MS-DOS}
  7906.     When on the bios is called to obtain a keyboard character.  This works
  7907.     better to detect CTRL-C, but only works for the console.  When using a
  7908.     terminal over a serial port reset this option.
  7909.  
  7910.                         *'breakat'* *'brk'*
  7911. breakat (brk)        string    (default " ^I!@*-+_;:,./?")
  7912.             global
  7913.             {not in Vi}
  7914.     This option lets you choose which characters might cause a line
  7915.     break if 'linebreak' is on.
  7916.  
  7917.                    *'cindent'* *'cin'* *'nocindent'* *'nocin'*
  7918. cindent (cin)        toggle    (default off)
  7919.             local to buffer
  7920.             {not in Vi}
  7921.             {Only present when compiled with CINDENT enabled,
  7922.             ":version" says "+cindent" instead of "-cindent"}
  7923.     Enables automatic C program indenting  See 'cinkeys' to set the keys
  7924.     that trigger reindenting in insert mode and 'cinoptions' to set your
  7925.     preferred indent style.  If 'lisp' is not on and 'equalprg' is empty,
  7926.     the "=" operator indents using this algorithm rather than calling an
  7927.     external program.  See |C_indenting|.  This option is switched off
  7928.     when 'paste' is set.  When you don't like the way 'cindent' works, try
  7929.     the 'smartindent' option.
  7930.  
  7931. cinkeys (cink)        string    (default "0{,0},:,0#,!^F,o,O,e")
  7932.             local to buffer
  7933.             {not in Vi}
  7934.             {Only present when compiled with CINDENT enabled}
  7935.     A list of keys that, when typed in insert mode, cause reindenting of
  7936.     the current line.  Only happens if 'cindent' is on.  See
  7937.     |C_indenting|.
  7938.  
  7939.                         *'cinoptions'* *'cino'*
  7940. cinoptions (cino)    string    (default "")
  7941.             local to buffer
  7942.             {not in Vi}
  7943.             {Only present when compiled with CINDENT enabled}
  7944.     The 'cinoptions' affect the way 'cindent' reindents lines in a C
  7945.     program.  See |C_indenting|.
  7946.  
  7947.                         *'cinwords'* *'cinw'*
  7948. cinwords (cinw)        string    (default "if,else,while,do,for,switch")
  7949.             local to buffer
  7950.             {not in Vi}
  7951.             {Only present when compiled with CINDENT or
  7952.             SMARTINDENT enabled}
  7953.     These keywords start an extra indent in the next line when
  7954.     'smartindent' or 'cindent' is set.  For 'cindent' this is only done at
  7955.     an appropriate place (inside {}).
  7956.  
  7957.                         *'cmdheight'* *'ch'*
  7958. cmdheight (ch)        number    (default 1)
  7959.             global
  7960.             {not in Vi}
  7961.     Number of lines to use for the command line.  If you are annoyed by
  7962.     "Hit return ..." caused by long messages, set this option to a larger
  7963.     value.
  7964.  
  7965.                         *'columns'* *'co'*
  7966. columns (co)        number    (default 80 or terminal width)
  7967.             global
  7968.             {not in Vi}
  7969.     Number of columns of the screen.  Normally this is set by the terminal
  7970.     initialization and does not have to be set by hand.
  7971.  
  7972.                         *'comments'* *'com'*
  7973. comments (com)        string    (default
  7974.                 "sr:/*,mb:*,el:*/,://,b:#,:%,:XCOMM,n:>,fb:-")
  7975.             local to buffer
  7976.             {not in Vi}
  7977.     A comma separated list of strings that can start a comment line.  See
  7978.     |format_comments|.  See |option_backslash| about using backslashes to
  7979.     insert a space.
  7980.  
  7981.                    *'compatible'* *'cp'* *'nocompatible'* *'nocp'*
  7982. compatible (cp)        toggle    (default off, on when compiled with COMPATIBLE
  7983.                 defined, ":version" shows "+compatible")
  7984.             global
  7985.             {not in Vi}
  7986.     At the moment this option is set, several other options will be set
  7987.     or reset to make Vim Vi-compatible.  Switching this option off has no
  7988.     effect.  See also 'cpoptions'.
  7989.  
  7990.     option        new value    effect
  7991.  
  7992.     backspace    0        normal backspace
  7993.     backup        off        no backup file
  7994.     cindent        off        no C code indentation
  7995.     cpoptions    "aAbBcdefFklmorsStwx$!%<"    vi-compatible flags
  7996.     digraph        off        no digraphs
  7997.     esckeys        off        no <Esc>-keys in Insert mode
  7998.     expandtab    off        tabs not expanded to spaces
  7999.     formatoptions    "vt"        Vi compatible formatting
  8000.     gdefault    off        no default 'g' flag for ":s"
  8001.     history        0        no commandline history
  8002.     insertmode    off        do not start in Insert mode
  8003.     iskeyword    "@,48-57,_"    keywords contain alphanumeric
  8004.                         characters and '_'
  8005.     joinspaces    on        insert 2 spaces after period
  8006.     modeline    off        no modelines
  8007.     more        off        no pauses in listings
  8008.     revins        off        no reverse insert
  8009.     ruler        off        no ruler
  8010.     scrolljump    1        no jump scroll
  8011.     scrolloff    0        no scroll offset
  8012.     shiftround    off        indent not rounded to shiftwidth
  8013.     showcmd        off        command characters not shown
  8014.     showmode    off        current mode not shown
  8015.     smartcase    off        no automatic ignore case switch
  8016.     smartindent    off        no smart indentation
  8017.     smarttab    off        no smart tab size
  8018.     startofline    on        goto startofline with some commands
  8019.     textauto    off        no automatic textmode detection
  8020.     textwidth    0        no automatic line wrap
  8021.     tildeop        off        tilde is not an operator
  8022.     ttimeout    off        no terminal timeout
  8023.     undolevels    0        no multilevel undo
  8024.     updatecount    0        no swap file
  8025.     whichwrap    ""        left-right movements don't wrap
  8026.     wildchar    CTRL-E        only when the current value is <Tab>
  8027.                     use CTRL-E for cmdline completion
  8028.     writebackup    off        no backup file written
  8029.  
  8030.                         *'cpoptions'* *'cpo'*
  8031. cpoptions (cpo)        string    (default "aABceFs", unless compiled with
  8032.                 COMPATIBLE defined, then all flags are
  8033.                 included)
  8034.             global
  8035.             {not in Vi}
  8036.     Sequence of characters.  When a character is present this indicates
  8037.     vi-compatible behaviour.  This is used for things where not being
  8038.     vi-compatible is mostly or sometimes preferred.  'cpoptions' stands
  8039.     for 'compatibleoptions'.  Commas can be added for readability.
  8040.  
  8041.         contains    behaviour
  8042.         a    When included, a ":read" command with a file name
  8043.             argument will set the alternate filename for the
  8044.             current window.
  8045.         A    When included, a ":write" command with a file name
  8046.             argument will set the alternate filename for the
  8047.             current window.
  8048.         b    "\|" in a ":map" command is recognized as the end of
  8049.             the map command.  The '\' is included in the mapping,
  8050.             the text after the '|' is interpreted as the next
  8051.             command.  Use a CTRL-V instead of a backslash to
  8052.             include the '|' in the mapping.  Applies to all
  8053.             mapping, abbreviation, menu and autocmd commands.
  8054.             See also |map_bar|.
  8055.         B    A backslash has no special meaning in mappings,
  8056.             abbreviations and the "to" part of the menu commands.
  8057.             Remove this flag to be able to use a backslash like a
  8058.             CTRL-V.  This flag must be removed to be able to fully
  8059.             use the <> notation.  For example, the command
  8060.             ":map X \<Esc>" results in X being mapped to:
  8061.                 'B' included:    "\^["    (^[ is a real <Esc>)
  8062.                 'B' excluded:   "<Esc>"  (5 characters)
  8063.                 ('<' excluded in both cases)
  8064.         <    Disable the recognition of special key codes in <>
  8065.             form in mappings, abbreviations, and the "to" part of
  8066.             menu commands.  For example, the command
  8067.             ":map X <Tab>" results in X being mapped to:
  8068.                 '<' included:   "<Tab>"  (5 characters)
  8069.                 '<' excluded:   "^I"     (^I is a real <Tab>)
  8070.             Also see the 'k' flag below.
  8071.         c    Searching continues at the end of any match at the
  8072.             cursor position.  When not present searching continues
  8073.             one character from the cursor position.  With 'c'
  8074.             "abababababab" only gets three matches when repeating
  8075.             "/abab", without 'c' there are five matches.
  8076.         d    Using "./" in the 'tags' option doesn't mean to use
  8077.             the tags file relative to the current file, but the
  8078.             tags file in the current directory.
  8079.         e    When executing a register with ":@r", always add a
  8080.             <CR> to the last line, also when the register is not
  8081.             linewise.  If this flag is not present, the register
  8082.             is not linewise and the last line does not end in a
  8083.             <CR>, then the last line is put on the command line
  8084.             and can be edited before hitting <CR>.
  8085.         f    When included, a ":read" command with a file name
  8086.             argument will set the file name for the current buffer,
  8087.             if the current buffer doesn't have a file name yet.
  8088.         F    When included, a ":write" command with a file name
  8089.             argument will set the file name for the current buffer,
  8090.             if the current buffer doesn't have a file name yet.
  8091.         k    Disable the recognition of raw key codes in
  8092.             mappings, abbreviations, and the "to" part of menu
  8093.             commands.  For example, if <Key> sends ^[OA (where ^[
  8094.             is <Esc>), the command ":map X ^[OA" results in X
  8095.             being mapped to:
  8096.                 'k' included:   "^[OA"   (3 characters)
  8097.                 'k' excluded:   "<Key>"  (one key code)
  8098.             Also see the '<' flag above.
  8099.         l    Backslash in a [] range in a search pattern is taken
  8100.             literally, only "\]" is special  See |/[]|
  8101.                'l' included: "/[ \t]"  finds <Space>, '\' and 't'
  8102.                'l' excluded: "/[ \t]"  finds <Space> and <Tab>
  8103.         m    When included, a showmatch will always wait half a
  8104.             second.  When not included, a showmatch will wait half
  8105.             a second or until a character is typed.  |'showmatch'|
  8106.         o    Line offset to search command is not remembered for
  8107.             next search.
  8108.         r    Redo ("." command) uses "/" to repeat a search
  8109.             command, instead of the actually used search string.
  8110.         s    Set buffer options when entering the buffer for the
  8111.             first time.  This is like it is in Vim version 3.0.
  8112.             And it is the default.  If not present the options are
  8113.             set when the buffer is created.
  8114.         S    Set buffer options always when entering a buffer
  8115.             (except 'readonly' and 'textmode').  This is the
  8116.             (most) Vi compatible setting.
  8117.             The options are set to the values in the current
  8118.             buffer.  When you change an option and go to another
  8119.             buffer, the value is copied.  Effectively makes the
  8120.             buffer options global to all buffers.
  8121.  
  8122.             's'    'S'     copy buffer options
  8123.             no     no      when buffer created
  8124.             yes    no      when buffer first entered (default)
  8125.              X     yes     each time when buffer entered (vi comp.)
  8126.  
  8127.         t    Search pattern for the tag command is remembered for
  8128.             "n" command.  Otherwise Vim only puts the pattern in
  8129.             the history for search pattern, but doesn't change the
  8130.             last used search pattern.
  8131.         w    When using "cw" on a blank character, only change one
  8132.             character and not all blanks until the start of the
  8133.             next word.
  8134.         x    <Esc> on the command line executes the command line.
  8135.             The default in Vim is to abandon the command line,
  8136.             because <Esc> normally aborts a command.  |c_<Esc>|
  8137.         $    When making a change to one line, don't redisplay the
  8138.             line, but put a '$' at the end of the changed text.
  8139.             The changed text will be overwritten when you type the
  8140.             new text.  The line is redisplayed if you type any
  8141.             command that moves the cursor from the insertion
  8142.             point.
  8143.         !    When redoing a filter command, use the last used
  8144.             external command, whatever it was.  Otherwise the last
  8145.             used -filter- command is used.
  8146.         %    Vi-compatible matching is done for the "%" command.
  8147.             Parens inside single and double quotes are also
  8148.             counted, causing a string that contains a paren to
  8149.             disturb the matching.  For example, in a line like
  8150.             "if (strcmp("foo(", s))" the first paren does not
  8151.             match the last one.  When this flag is not included,
  8152.             parens inside single and double quotes are treated
  8153.             specially.  When matching a paren outside of quotes,
  8154.             everything inside quotes is ignored.  When matching a
  8155.             paren inside quotes, it will find the matching one (if
  8156.             there is one).  This works very well for C programs.
  8157.  
  8158.                         *'define'* *'def'*
  8159. define (def)        string    (default "^#[ \t]*define")
  8160.             global
  8161.             {not in Vi}
  8162.     Pattern to be used to find a macro definition.  It is a search
  8163.     pattern, just like for the "/" command.  The default value is for C
  8164.     programs.  This option is used for the commands like "[i" and "[d"
  8165.     |include_search|.  The 'isident' option is used to recognize the
  8166.     identifier name after the match.  See |option_backslash| about
  8167.     inserting backslashes to include a space or backslash.
  8168.  
  8169.                         *'dictionary'* *'dict'*
  8170. dictionary (dict)    string    (default "")
  8171.             global
  8172.             {not in Vi}
  8173.     List of file names, separated by commas, that are used to lookup words
  8174.     for keyword completion commands |i_CTRL-X_CTRL-K|.  Each file should
  8175.     contain a list of words, one word per line.  To include a comma in a
  8176.     file name precede it with a backslash.  Spaces after a comma are
  8177.     ignored, otherwise spaces are included in the file name.  See
  8178.     |option_backslash| about using backslashes.
  8179.  
  8180.                      *'digraph'* *'dg'* *'nodigraph'* *'nodg'*
  8181. digraph (dg)        toggle    (default off)
  8182.             global
  8183.             {not in Vi}
  8184.             {Only applies when compiled with DIGRAPHS defined,
  8185.             check with ":version"}
  8186.     Enable the entering of digraphs in Insert mode with {char1} <BS>
  8187.     {char2}.  See |digraphs|.
  8188.  
  8189.                         *'directory'* *'dir'*
  8190. directory (dir)        string    (default for Amiga: ".,t:",
  8191.                  for MS-DOS and Win32: ".,c:\tmp,c:\temp"
  8192.                  for Unix: ".,~/tmp,/tmp")
  8193.             global
  8194.     List of directory names for the swap file, separated with commas.
  8195.     - The swap file will be created in the first directory where this is
  8196.       possible.
  8197.     - Empty means that no swap file will be used (recovery is
  8198.       impossible!).
  8199.     - A directory "." means to put the swap file in the same directory as
  8200.       the edited file.
  8201.     - A directory starting with "./" (or ".\" for MS-DOS et.al.) means to
  8202.       put the swap file relative to where the edited file is.  The leading
  8203.       "." is replaced with the path name of the edited file.
  8204.     - Spaces after the comma are ignored, other spaces are considered part
  8205.       of the directory name.  To have a space at the start of a directory
  8206.       name, precede it with a backslash.
  8207.     - To include a comma in a directory name precede it with a backslash.
  8208.     - A directory name may end in an ':' or '/'.
  8209.     - Environment variables are expanded |:set_env|.
  8210.     - Careful with '\' characters, type one before a space, type two to
  8211.       get one in the option (see |option_backslash|), for example:
  8212.         :set dir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces
  8213.     - For backwards compatibility with Vim version 3.0 a '>' at the start
  8214.       of the option is removed.
  8215.     Using "." first in the list is recommended.  This means that editing
  8216.     the same file twice will result in a warning.  Using "/tmp" on Unix is
  8217.     discouraged, when the system crashes you lose the swap file.  That is
  8218.     why a "tmp" directory in your home directory is used first.
  8219.     {Vi: directory to put temp file in, defaults to "/tmp"}
  8220.  
  8221.                *'ed'* *'edcompatible'* *'noed'* *'noedcompatible'*
  8222. edcompatible (ed)    toggle    (default off)
  8223.             global
  8224.     Makes the 'g' and 'c' flags of the ":substitute" command to be
  8225.     toggled each time the flag is given.  See 11.3 |complex_change|.  See
  8226.     also 'gdefault' option.
  8227.  
  8228.                    *'endofline'* *'eol'* *'noendofline'* *'noeol'*
  8229. endofline (eol)        toggle    (default on)
  8230.             local to buffer
  8231.             {not in Vi}
  8232.     When writing a file and this option is off and the 'binary' option
  8233.     is on, no end of line (newline) character will be written for the
  8234.     last line in the file.  This option is automatically set when
  8235.     starting to edit a new file, unless the file does not have an end of
  8236.     line (newline) for the last line in the file, in which case it is
  8237.     reset.  Normally you don't have to set or reset this option.  When
  8238.     'binary' is off the value is not used when writing the file.  When
  8239.     'binary' is on it is used to remember the presence of a newline for
  8240.     the last line in the file, so that when you write the file the
  8241.     situation from the original file can be kept.  But you can change it
  8242.     when you want to.
  8243.  
  8244.                  *'equalalways'* *'ea'* *'noequalalways'* *'noea'*
  8245. equalalways (ea)    toggle    (default on)
  8246.             global
  8247.             {not in Vi}
  8248.     When on all the windows are automatically made the same size after
  8249.     splitting or closing a window.  When off, splitting a window will
  8250.     reduce the size of the current window and leave the other windows the
  8251.     same.  When closing a window the extra lines are given the the window
  8252.     above it.
  8253.  
  8254.                         *'equalprg'* *'ep'*
  8255. equalprg (ep)        string    (default "")
  8256.             global
  8257.             {not in Vi}
  8258.     External program to use for "=" command.  When this option is empty
  8259.     the internal formatting functions are used ('lisp' or 'cindent').
  8260.     Environment variables are expanded |:set_env|.  See |option_backslash|
  8261.     about including spaces and backslashes.
  8262.  
  8263.                    *'errorbells'* *'eb'* *'noerrorbells'* *'noeb'*
  8264. errorbells (eb)        toggle    (default off)
  8265.             global
  8266.     Ring the bell (beep or screen flash) for error messages.  This only
  8267.     makes a difference for error messages, the bell will be used always
  8268.     for a lot of errors without a message (e.g., hitting <Esc> in Normal
  8269.     mode).  See 'visualbell' on how to make the bell behave like a beep,
  8270.     screen flash or do nothing.
  8271.  
  8272.                         *'errorfile'* *'ef'*
  8273. errorfile (ef)        string    (default "AztecC.Err" or "errors.vim")
  8274.             global
  8275.             {not in Vi}
  8276.     Name of the error file for the QuickFix mode (see 5.5
  8277.     |:make_makeprg|).  Environment variables are expanded |:set_env|.  See
  8278.     |option_backslash| about including spaces and backslashes.
  8279.  
  8280.                         *'errorformat'* *'efm'*
  8281. errorformat (efm)    string    (default is very long)
  8282.             global
  8283.             {not in Vi}
  8284.     Scanf-like description of the format for the lines in the error file
  8285.     (see 5.5 |errorformat|).
  8286.  
  8287.                      *'esckeys'* *'ek'* *'noesckeys'* *'noek'*
  8288. esckeys (ek)        toggle    (default on, off when compiled with COMPATIBLE
  8289.                 defined)
  8290.             global
  8291.             {not in Vi}
  8292.     Function keys that start with an <Esc> are recognized in Insert
  8293.     mode.  When this option is off, the cursor and function keys cannot be
  8294.     used in Insert mode if they start with an <Esc>.  The advantage of
  8295.     this is that the single <Esc> is recognized immediately, instead of
  8296.     after one second.  Instead of resetting this option, you might want to
  8297.     try changing the values for 'timeoutlen' and 'ttimeoutlen'.
  8298.  
  8299.                  *'expandtab'* *'et'* *'noexpandtab'* *'noet'*
  8300. expandtab (et)        toggle    (default off)
  8301.             local to buffer
  8302.             {not in Vi}
  8303.     In Insert mode: Use the appropriate number of spaces to insert a
  8304.     <Tab>.  Spaces are used in indents with the '>' and '<' commands and
  8305.     when 'autoindent' is on.  To insert a real tab when 'expandtab' is
  8306.     on, use CTRL-V<Tab>.  See also ":retab" command in 11.3 |:retab|
  8307.     and section 4.3.4 |ins_expandtab|.
  8308.  
  8309.                     *'exrc'* *'ex'* *'noexrc'* *'noex'*
  8310. exrc (ex)        toggle (default off)
  8311.             global
  8312.             {not in Vi}
  8313.     Enables the reading of .vimrc, .exrc and .gvimrc in the current
  8314.     directory.  If you switch this option on you should also consider
  8315.     setting the 'secure' option (see 3.4 |initialization|).  Using a local
  8316.     .exrc, .vimrc or .gvimrc is a potential security leak, use with care!
  8317.     also see |.vimrc| and |gui_init|.
  8318.  
  8319.                     *'formatoptions'* *'fo'*
  8320. formatoptions (fo)    string (default "tcq", "vt" when compiled with
  8321.                 COMPATIBLE defined)
  8322.             local to buffer
  8323.             {not in Vi}
  8324.     This is a sequence of letters which describes how automatic
  8325.     formatting is to be done.  See |fo_table|.  When the 'paste' option is
  8326.     on, no formatting is done (like 'formatoptions' is empty).  Commas can
  8327.     be inserted for readability.
  8328.  
  8329.                         *'formatprg'* *'fp'*
  8330. formatprg (fp)        string (default "")
  8331.             global
  8332.             {not in Vi}
  8333.     The name of an external program that will be used to format the lines
  8334.     selected with the "gq" command.  The program must take the input on
  8335.     stdin and produce the output on stdout.  The Unix program 'fmt' is
  8336.     such a program.  If this option is an empty string, the internal
  8337.     format function will be used |C_indenting|.  Environment variables are
  8338.     expanded |:set_env|.  See |option_backslash| about including spaces
  8339.     and backslashes.
  8340.  
  8341.                    *'gdefault'* *'gd'* *'nogdefault'* *'nogd'*
  8342. gdefault (gd)        toggle    (default off)
  8343.             global
  8344.             {not in Vi}
  8345.     When on, the ":substitute" flag 'g' is default on.  This means that
  8346.     all matches in a line are substituted instead of one.  When a 'g' flag
  8347.     is given to a ":substitute" command, this will toggle the substitution
  8348.     of all or one match.  See 11.3 |complex_change|.
  8349.  
  8350.         command        'gdefault' on    'gdefault' off
  8351.         :s///          subst. all      subst. one
  8352.         :s///g          subst. one      subst. all
  8353.         :s///gg          subst. all      subst. one
  8354.  
  8355.                         *'guifont'* *'gfn'*
  8356. guifont (gfn)        string  (default "")
  8357.             global
  8358.             {not in Vi}
  8359.             {Only available when compiled with GUI enabled}
  8360.     This is a list of fonts which should be tried when starting the GUI
  8361.     version of vim.  The fonts are separated with commas.  Spaces after a
  8362.     comma are ignored.  To include a comma in a font name precede it with
  8363.     a backslash.  Setting an option requires an extra backslash before a
  8364.     space and a backslash.  See also |option_backslash|.  For example:
  8365.         :set guifont=Screen15,\ 7x13,font\\,with\\,commas
  8366.     will make vim try to use the font "Screen15" first, and if it fails
  8367.     it will try to use "7x13" and then "font,with,commas" instead.  If
  8368.     none of the fonts can be loaded, vim will try using other resource
  8369.     settings (for X, it will use the Vim.font resource), and finally it
  8370.     will try some builtin default which should always be there ("7x13" in
  8371.     the case of X).  The font names given should be "normal" fonts.  Vim
  8372.     will try to find the related bold and italic fonts.
  8373.  
  8374.                         *'guioptions'* *'go'*
  8375. guioptions (go)        string  (default "agmr")
  8376.             global
  8377.             {not in Vi}
  8378.             {Only available when compiled with GUI enabled}
  8379.     This option only has an effect in the GUI version of vim.  It is a
  8380.     sequence of letters which describes what components and options of the
  8381.     GUI should be used.  Valid letters are as follows:
  8382.  
  8383.       'a'    Autoselect:  If present, then whenever VISUAL mode is started,
  8384.         or the Visual area extended, vim tries to become the owner of
  8385.         the windowing system's global selection.  This means that the
  8386.         Visually highlighted text is available for pasting into other
  8387.         applications as well as into vim itself.  When the Visual mode
  8388.         ends, possibly due to an operation on the text, or when an
  8389.         application wants to paste the selection, the highlighted text
  8390.         is automatically yanked into the <"*> GUI selection register.
  8391.         Thus the selection is still available for pasting into other
  8392.         applications after the VISUAL mode has ended.
  8393.             If not present, then vim won't become the owner of the
  8394.         windowing system's global selection unless explicitly told to
  8395.         by selecting "Cut" or "Copy" etc from the "Edit" menu (which
  8396.         have not been implemented yet!).
  8397.  
  8398.       'f'    Foreground: Don't use fork() to detatch the GUI from the shell
  8399.         where it was started.  Use this for programs that wait for the
  8400.         editor to finish (e.g., an e-mail program).  Altenatively you
  8401.         can use "gvim -f" or ":gui -f" to start the GUI in the
  8402.         foreground.  |gui_fork|
  8403.  
  8404.       'm'    Menu bar is present when 'm' is included.
  8405.       'g'    Grey menu items: Make menu items that are not active grey.  If
  8406.         'g' is not included inactive menu items are not shown at all.
  8407.  
  8408.       'r'    Right-hand scrollbar is present when 'r' is included.
  8409.       'l'    Left-hand scrollbar is present when 'l' is included.
  8410.       'b'    Bottom (horizontal) scrollbar is present when 'b' is included.
  8411.  
  8412.     And yes, you may even have scrollbars on the left AND the right if
  8413.     you really want to :-).  See |gui_scrollbars| for more information.
  8414.  
  8415.                         *'guipty'* *'noguipty'*
  8416. guipty            toggle    (default off)
  8417.             global
  8418.             {not in Vi}
  8419.             {Only available when compiled with GUI enabled}
  8420.     Only in the GUI: If on, an attempt is made to open a pseudo-tty for
  8421.     I/O to/from shell commands.  See |gui_pty|.
  8422.  
  8423.                     *'helpfile'* *'hf'*
  8424. helpfile (hf)        string    (default (Amiga) "vim:vim_help.txt"
  8425.                  (MS-DOS, Win32, OS/2) "$VIM/vim_help.txt"
  8426.                  (Unix) "/usr/local/lib/vim/vim_help.txt")
  8427.             global
  8428.             {not in Vi}
  8429.     Name of the help file.  All help files should be placed together in
  8430.     one directory.  Environment variables are expanded |:set_env|.  For
  8431.     example: "$VIM/doc/vim_help.txt".  If $VIM is not set, $HOME is also
  8432.     tried.  For Unix the default is adjusted at compile time to where the
  8433.     help files are being installed.  See |option_backslash| about
  8434.     including spaces and backslashes.
  8435.  
  8436.                         *'helpheight'* *'hh'*
  8437. helpheight (hh)        number    (default 20)
  8438.             global
  8439.             {not in Vi}
  8440.     Minimal initial height of the help window when it is opened with the
  8441.     ":help" command.  The initial height of the help window is half of the
  8442.     current window, or (when the 'ea' option is on) the same as other
  8443.     windows.  When the height is less than 'helpheight', the height is
  8444.     set to 'helpheight'.  Set to zero to disable.
  8445.  
  8446.                      *'hidden'* *'hid'* *'nohidden'* *'nohid'*
  8447. hidden (hid)        toggle    (default off)
  8448.             global
  8449.             {not in Vi}
  8450.     When off the current buffer is unloaded when it is abandoned.  When
  8451.     on the current buffer becomes hidden when starting to edit another
  8452.     buffer.  If the current buffer is also displayed in another window it
  8453.     does not become hidden.  The commands that move through the buffer
  8454.     list make the current buffer hidden although the 'hidden' option is
  8455.     off.  See also |vim_win.txt|.
  8456.  
  8457.                         *'highlight'* *'hl'*
  8458. highlight (hl)        string    (default "8b,db,es,mb,Mn,nu,rs,sr,tb,vr,ws")
  8459.             global
  8460.             {not in Vi}
  8461.     This option can be used to set highlighting mode for various
  8462.     occasions.  It is a comma separated list of character pairs.  The
  8463.     first character in a pair gives the occasion, the second the mode to
  8464.     use for that occasion.  The occasions are:
  8465.         8    Meta & special keys listed with ":map"
  8466.         d    directories in CTRL-D listing
  8467.         e    error messages
  8468.         m    "--More--" message
  8469.         M    Mode (e.g., "-- INSERT --")
  8470.         n    line number for ":number" and ":#" commands
  8471.         r    return to continue message and yes/no questions
  8472.         s    status lines
  8473.         t    Titles for output from ":set all", ":autocmd" etc.
  8474.         v    Visual mode
  8475.         w    warning messages
  8476.     The display modes are:
  8477.         r    reverse        (termcap entry "mr" and "me")
  8478.         i    italic        (termcap entry "ZH" and "ZR")
  8479.         b    bold        (termcap entry "md" and "me")
  8480.         s    standout    (termcap entry "so" and "se")
  8481.         u    underline    (termcap entry "us" and "ue")
  8482.         n    no highlighting
  8483.     The default is used for occasions that are not included.
  8484.     If you want to change what the display modes do, see |colors| for an
  8485.     example.
  8486.  
  8487.                         *'history'* *'hi'*
  8488. history (hi)        number    (default 20)
  8489.             global
  8490.             {not in Vi}
  8491.     A history of ":" commands, and a history of previous search patterns
  8492.     are remembered.  This option decides how many entries may be stored in
  8493.     each of these histories (see |cmdline_editing|).
  8494.  
  8495.                      *'hkmap'* *'hk'* *'nohkmap'* *'nohk'*
  8496. hkmap (kh)        toggle  (default off)
  8497.             global
  8498.             {not in Vi}
  8499.             {Only available if Vim was compiled with RIGHTLEFT
  8500.             defined}
  8501.     When on, the keyboard is mapped for the Hebrew character set.
  8502.     Normally you would use CTRL-_ in insert mode to toggle this option.
  8503.     See |vim_rlh.txt|.
  8504.  
  8505.                         *'icon'* *'noicon'*
  8506. icon            toggle    (default off, on when title can be restored)
  8507.             global
  8508.             {not in Vi}
  8509.     When on the icon of the window will be set to the name of the file
  8510.     currently being edited.  Only the last part of the name is used.  Only
  8511.     works if the terminal supports setting window icons (currently only
  8512.     Unix xterm and iris-ansi).  When Vim was compiled with HAVE_X11
  8513.     defined, the original icon will be restored if possible |X11|.
  8514.  
  8515.                    *'ignorecase'* *'ic'* *'noignorecase'* *'noic'*
  8516. ignorecase (ic)        toggle    (default off)
  8517.             global
  8518.     Ignore case in search patterns.  Also used when searching in the tags
  8519.     file.
  8520.  
  8521.                         *'include'* *'inc'*
  8522. include (inc)        string    (default "^#[ \t]*include")
  8523.             global
  8524.             {not in Vi}
  8525.     Pattern to be used to find an include command.  It is a search
  8526.     pattern, just like for the "/" command (See 6.6, "Pattern
  8527.     searches" |search_pattern|).  The default value is for C programs.
  8528.     This option is used for the commands "[i", "]I", "[d", etc..  The
  8529.     'isfname' option is used to recognize the file name that comes after
  8530.     the matched pattern.  See |option_backslash| about including spaces
  8531.     and backslashes.
  8532.  
  8533.                  *'incsearch'* *'is'* *'noincsearch'* *'nois'*
  8534. incsearch (is)        toggle    (default off)
  8535.             global
  8536.             {not in Vi}
  8537.     While typing a search pattern, show immediately where the so far
  8538.     typed pattern matches.  The matched string is highlighted.  If the
  8539.     pattern is invalid or not found, nothing is shown.  The screen will
  8540.     be updated often, this is only useful on fast terminals.  Note that
  8541.     the match will be shown, but the cursor is not actually positioned
  8542.     there.  You still need to finish the search command with <CR> to move
  8543.     the cursor.
  8544.  
  8545.                    *'infercase'* *'inf'* *'noinfercase'* *'noinf'*
  8546. infercase (inf)        toggle    (default off)
  8547.             local to buffer
  8548.             {not in Vi}
  8549.     When doing keyword completion in insert mode |ins_completion|, and
  8550.     'ignorecase' is also on, the case of the match is adjusted.  If the
  8551.     typed text contains a lowercase letter where the match has an upper
  8552.     case letter, the completed part is made lower case.  If the typed text
  8553.     has no lower case letters and the match has a lower case letter where
  8554.     the typed text has an upper case letter, and there is a letter before
  8555.     it, the completed part is made uppercase.
  8556.  
  8557.                    *'insertmode'* *'im'* *'noinsertmode'* *'noim'*
  8558. insertmode (im)        toggle    (default off)
  8559.             global
  8560.             {not in Vi}
  8561.     Start the edit of a file in Insert mode.  Useful if you want to use
  8562.     Vim like a modeless editor (use the cursor keys to move around, use
  8563.     CTRL-O for other commands |i_CTRL-O|).
  8564.  
  8565.                         *'isfname'* *'isf'*
  8566. isfname (isf)        string    (default for MS-DOS, Win32 and OS/2:
  8567.                         "@,48-57,/,.,-,_,+,,,$,:,\"
  8568.                  for AMIGA: "@,48-57,/,.,-,_,+,,,$,:"
  8569.                  otherwise: "@,48-57,/,.,-,_,+,,,$,:,~")
  8570.             global
  8571.             {not in Vi}
  8572.     The characters given by this option are included in file names and
  8573.     path names.  File names are used for commands like "gf", "[i" and in
  8574.     the tags file.  Besides the characters in this option characters that
  8575.     are defined by the C function isalpha() are also always included
  8576.     (this depends on the character set and "locale").
  8577.  
  8578.     The format of this option is a list of parts, separated with commas.
  8579.     Each part can be a single character number or a range.  A range is two
  8580.     character numbers with '-' in between.  A character number can be a
  8581.     decimal number between 0 and 255 or the ASCII character itself (does
  8582.     not work for digits).  Example:
  8583.         "_,-,128-140,#-43"    (include '_' and '-' and the range
  8584.                     128 to 140 and '#' to 43)
  8585.     If a part starts with '^', the following character number or range
  8586.     will be excluded from the option.  The option is interpreted from left
  8587.     to right.  Put the excluded character after the range where it is
  8588.     included.  To include '^' itself use it as the last character of the
  8589.     option or the end of a range.  Example:
  8590.         "^a-z,#,^"    (exclude 'a' to 'z', include '#' and '^')
  8591.     If the character is '@', all characters where isalpha() returns TRUE
  8592.     are included.  Normally these are the characters a to z and A to Z,
  8593.     plus accented characters.  To include '@' itself use "@-@".  Examples:
  8594.         "@,^a-z"    All alphabetic characters, excluding lower
  8595.                 case letters.
  8596.         "a-z,A-Z,@-@"    All letters plus the '@' character.
  8597.     A comma can be included by using it where a character number is
  8598.     expected.  Example:
  8599.         "48-57,,,_"    Digits, command and underscore.
  8600.     A comma can be excluded by prepending a '^'.  Example:
  8601.         " -~,^,,9"    All characters from space to '~', excluding
  8602.                 comma, plus <Tab>.
  8603.     See |option_backslash| about including spaces and backslashes.
  8604.  
  8605.                         *'isident'* *'isi'*
  8606. isident (isi)    string    (default for MS-DOS, Win32 and OS/2:
  8607.                        "@,48-57,_,128-167,224-235"
  8608.                 otherwise: "@,48-57,_,192-255")
  8609.             global
  8610.             {not in Vi}
  8611.     The characters given by this option are included in identifiers.
  8612.     Identifiers are used in recognizing environment variables and after
  8613.     a match of the 'define' option.  See 'isfname' for a description of
  8614.     the format of this option.
  8615.     Careful: If you change this option, it might break expanding
  8616.     environment variables.  E.g., when '/' is included and Vim tries to
  8617.     expand "$HOME/.viminfo".  Maybe you should change 'iskeyword' instead.
  8618.  
  8619.                         *'iskeyword'* *'isk'*
  8620. iskeyword (isk)         string (default for MS-DOS and Win32:
  8621.                         "@,48-57,_,128-167,224-235"
  8622.                 otherwise:  "@,48-57,_,192-255"
  8623.                 but when compiled with COMPATIBLE defined:
  8624.                         "@,48-57,_")
  8625.             local to buffer
  8626.             {not in Vi}
  8627.     Keywords are used in searching and recognizing with many commands:
  8628.     "w", "*", "[i", etc.  See 'isfname' for a description of the format of
  8629.     this option.  For C programs you could use "a-z,A-Z,48-57,_,.,-,>".
  8630.     For a help file it is set to all non-blank printable characters except
  8631.     '*', '"' and '|'.  When the 'lisp' option is on the '-' character is
  8632.     always included.
  8633.  
  8634.                         *'isprint'* *'isp'*
  8635. isprint (isp)    string    (default for MS-DOS and Win32: "@,~-255"
  8636.                   otherwise:           "@,161-255")
  8637.             global
  8638.             {not in Vi}
  8639.     The characters given by this option are displayed directly on the
  8640.     screen.  The characters from space (ascii 32) to '~' (ascii 126) are
  8641.     always displayed directly, even when they are not included in
  8642.     'isprint' or excluded.  See 'isfname' for a description of the format
  8643.     of this option.  Non-printable characters are displayed with two
  8644.     characters:
  8645.           0 -  31    "^@" - "^_"
  8646.          32 - 126    always single characters
  8647.            127        "^?"
  8648.         128 - 159    "~@" - "~_"
  8649.         160 - 254    "| " - "|~"
  8650.            255        "~?"
  8651.  
  8652.                    *'joinspaces'* *'js'* *'nojoinspaces'* *'nojs'*
  8653. joinspaces (js)        toggle    (default on)
  8654.             global
  8655.             {not in Vi}
  8656.     Insert two spaces after a period with a join command.
  8657.  
  8658.                     *'keywordprg'* *'kp'*
  8659. keywordprg (kp)        string    (default "man")
  8660.             global
  8661.             {not in Vi}
  8662.     Program to use for the "K" command.  Environment variables are
  8663.     expanded |:set_env|.  When empty ":help" is used.  See
  8664.     |option_backslash| about including spaces and backslashes.
  8665.  
  8666.                     *'langmap'* *'lmap'*
  8667. langmap (lmap)        string    (default "")
  8668.             global
  8669.             {not in Vi}
  8670.             {Only included when Vim was compiled with HAVE_LANGMAP
  8671.             defined (Check ":version" for "+langmap").
  8672.     This option allows support for keyboards that have a mode for a
  8673.     special language.  The idea is that when you are typing text in Insert
  8674.     mode your keyboard is switched in the special language mode, you get
  8675.     different key codes for the special characters.  When in command mode
  8676.     the 'langmap' option takes care of translating these special
  8677.     characters to the original meaning of the key.  This means you don't
  8678.     have to change the keyboard mode to be able to execute normal mode
  8679.     commands.
  8680.  
  8681.     Example (for greek):                    *greek*
  8682.         :set langmap=┴A,┬B,╪C,─D,┼E,╓F,├G,╟H,╔I,╬J,╩K,╦L,╠M,═N,╧O,╨P,QQ,╤R,╙S,╘T,╚U,┘V,WW,╫X,╒Y,╞Z,ßa,Γb,°c,Σd,σe,÷f,πg,τh,Θi,εj,Ωk,δl,∞m,φn,∩o,≡p,qq,±r,≤s,⌠t,Φu,∙v,≥w,≈x,⌡y,µz
  8683.     Example (exchanges meaning of z and y for commands):
  8684.         :set langmap=zy,yz,ZY,YZ
  8685.  
  8686.     The 'langmap' option is a list of parts, separated with commas.  Each
  8687.     part can be in one of two forms:
  8688.     1.  A list of pairs.  Each pair is a "from" character immediately
  8689.         followed by the "to" character.  Examples: "aA", "aAbBcC".
  8690.     2.  A list of "from" characters, a semi-colon and a list of "to"
  8691.         characters.  Example: "abc;ABC"
  8692.     Example: "aA,fgh;FGH,cCdDeE"
  8693.     Special characters need to be preceded with a backslash.  These are
  8694.     ";", ',' and backslash itself.
  8695.  
  8696.     This will allow you to activate vim actions without having to switch
  8697.     back and forth between the languages.  Your language characters will
  8698.     be understood as normal vim English characters (according to the
  8699.     langmap mappings) in the following cases:
  8700.      o Normal/Visual mode (commands, buffer/register names, user mappings)
  8701.      o Insert/Replace Mode: Register names after CTRL-R
  8702.      o Insert/Replace Mode: Mappings
  8703.     Characters entered in Command-line mode will NOT be affected by
  8704.     this option.   Note that this option can be changed at any time
  8705.     allowing to switch between mappings for different languages/encodings.
  8706.     Use a mapping to avoid having to type it each time!
  8707.  
  8708.                     *'laststatus'* *'ls'*
  8709. laststatus (ls)        number    (default 1)
  8710.             global
  8711.             {not in Vi}
  8712.     The value of this option influences when the last window will have a
  8713.     status line:
  8714.         0: never
  8715.         1: only if there are at least two windows
  8716.         2: always
  8717.     The screen looks nicer with a status line if you have several
  8718.     windows, but it takes another screen line.
  8719.  
  8720.                    *'linebreak'* *'lbr'* *'nolinebreak'* *'nolbr'*
  8721. linebreak (lbr)        toggle    (default off)
  8722.             local to window
  8723.             {not in Vi}
  8724.     If on Vim will wrap long lines at a character in 'breakat' rather
  8725.     than at the last character that fits on the screen.  Unlike
  8726.     'wrapmargin' and 'textwidth', this does not insert newline characters
  8727.     in the file, it only affects the way the file is displayed, not its
  8728.     contents.  The value of 'showbreak' is used to put in front of wrapped
  8729.     lines.  This option is not used when the 'wrap' option is off.  Note
  8730.     that <Tab> characters after a line break are mostly not displayed
  8731.     correctly.
  8732.  
  8733.                         *'lines'*
  8734. lines            number    (default 24 or terminal height)
  8735.             global
  8736.     Number of lines in the display.  Normally you don't need to set this.
  8737.     That is done automatically by the terminal initialization code.  When
  8738.     you do set this, and Vim is unable to change the physical number of
  8739.     lines on the display, redisplaying may be wrong.
  8740.  
  8741.                         *'lisp'* *'nolisp'*
  8742. lisp            toggle    (default off)
  8743.             local to buffer
  8744.             {Only included when compiled with LISPINDENT enabled,
  8745.             ":version" says "+lispindent" instead of
  8746.             "-lispindent"}
  8747.     Lisp mode: When a return is typed in insert mode set the indent for
  8748.     the next line to Lisp standards (well, sort of).  Also happens with
  8749.     "cc" or "S".  'autoindent' must also be on for this to work.  The '-'
  8750.     character is included in keyword characters.  Redefines the "="
  8751.     operator to use this same indentation algorithm rather than calling an
  8752.     external program if 'equalprg' is empty.  This option is reset when
  8753.     'paste' is set.  {Vi: Does it a little bit differently}
  8754.  
  8755.                         *'list'* *'nolist'*
  8756. list            toggle    (default off)
  8757.             local to window
  8758.     List mode: Show tabs as CTRL-I, show end of line with $.  Useful to
  8759.     see the difference between tabs and spaces and for trailing blanks.
  8760.     Note that this will also affect formatting (set with 'textwidth' or
  8761.     'wrapmargin').
  8762.  
  8763.                         *'magic'* *'nomagic'*
  8764. magic            toggle    (default on)
  8765.             global
  8766.     Changes the special characters that can be used in search patterns.
  8767.     See section "Pattern searches" |search_pattern|.
  8768.  
  8769.                         *'makeprg'* *'mp'*
  8770. makeprg (mp)        string    (default "make")
  8771.             global
  8772.             {not in Vi}
  8773.     Program to use for the ":make" command.  See |:make_makeprg|.  This
  8774.     option may contain '%' and '#' characters, which are expanded like
  8775.     when used in a command line.  Environment variables are expanded
  8776.     |:set_env|.  See |option_backslash| about including spaces and
  8777.     backslashes.
  8778.  
  8779.                         *'maxmapdepth'* *'mmd'*
  8780. maxmapdepth (mmd)    number    (default 1000)
  8781.             global
  8782.             {not in Vi}
  8783.     Maximum number of times a mapping is done without resulting in a
  8784.     character to be used.  This normally catches endless mappings, like
  8785.     ":map x y" with ":map y x".  It still does not catch ":map g wg",
  8786.     because the 'w' is used before the next mapping is done.  See also
  8787.     |key_mapping|.
  8788.  
  8789.                         *'maxmem'* *'mm'*
  8790. maxmem (mm)        number    (default 512)
  8791.             global
  8792.             {not in Vi}
  8793.     Maximum amount of memory (in Kbyte) to use for one buffer.  When this
  8794.     limit is reached allocating extra memory for a buffer will cause
  8795.     other memory to be freed.  See also 'maxmemtot'.
  8796.  
  8797.                         *'maxmemtot'* *'mmt'*
  8798. maxmemtot (mmt)        number    (default 2048, or half the amount of memory
  8799.                 available)
  8800.             global
  8801.             {not in Vi}
  8802.     Maximum amount of memory (in Kbyte) to use for all buffers together.
  8803.     See also 'maxmem'.
  8804.  
  8805.                    *'modeline'* *'ml'* *'nomodeline'* *'noml'*
  8806. modeline (ml)        toggle    (default on, off when compiled with COMPATIBLE
  8807.                 defined)
  8808.             local to buffer
  8809.                         *'modelines'* *'mls'*
  8810. modelines (mls)        number    (default 5)
  8811.             global
  8812.             {not in Vi}
  8813.     If 'modeline' is on 'modelines' gives the number of lines that is
  8814.     checked for set commands.  If 'modeline' is off or 'modelines' is zero
  8815.     no lines are checked.  See 19.1 |modeline|.  'modeline' is reset when
  8816.     'compatible' is set.
  8817.  
  8818.                  *'modified'* *'mod'* *'nomodified'* *'nomod'*
  8819. modified (mod)        toggle    (default off)
  8820.             local to buffer
  8821.             {not in Vi}
  8822.     When on the buffer is considered to be modified.  This option is set
  8823.     by every command that makes a change to the buffer.  Only the undo
  8824.     command may reset it, when all changes have been undone.
  8825.  
  8826.                         *'more'* *'nomore'*
  8827. more            toggle    (default on, off when compiled with COMPATIBLE
  8828.                 defined)
  8829.             global
  8830.             {not in Vi}
  8831.     Listings pause when the whole screen is filled.  Type:
  8832.          <CR> or <NL>   for one more line.
  8833.          <Space>        for the next page.
  8834.          'd'            for down half a page.
  8835.          'q', <Esc> or CTRL-C  to stop the listing.
  8836.          ':'            to stop the listing and enter a command line.
  8837.     Any other key causes the meaning of the keys to be displayed.
  8838.     When this option is off there are no pauses, the listing continues
  8839.     until finished.  When 'compatible' is set this option is reset.
  8840.     Note: The key typed at the "more" prompt is directly obtained from the
  8841.     terminal, it is not mapped and typeahead is ignored.
  8842.  
  8843.                         *'mouse'*
  8844. mouse            string    (default "", "a" for MS-DOS and Win32)
  8845.             global
  8846.             {not in Vi}
  8847.     Enable the use of the mouse.  Only works for certain terminals
  8848.     (MS-DOS, Win32 and xterm).  The mouse can be enabled for different
  8849.     modes:
  8850.         n    Normal mode
  8851.         v    Visual mode
  8852.         i    Insert mode
  8853.         c    Command-line mode
  8854.         h    all previous modes when editing a help file
  8855.         a    all previous modes
  8856.         r    for "Hit return ..." question
  8857.     Normally you would enable the mouse in all four modes with:
  8858.         :set mouse=a
  8859.     Note: Normal copy/paste in an xterm can still be used by pressing the
  8860.     shift key when the mouse is being used by Vim.  See |mouse_using|.
  8861.  
  8862.                         *'mousetime'* *'mouset'*
  8863. mousetime (mouset)    number    (default 500)
  8864.             global
  8865.             {not in Vi}
  8866.     Only for GUI, MS-DOS, Win32 and Unix with xterm.  Defines the maximum
  8867.     time in msec between two mouse clicks for the second click to be
  8868.     recognized as a multi click.
  8869.  
  8870.                        *'number'* *'nu'* *'nonumber'* *'nonu'*
  8871. number (nu)        toggle    (default off)
  8872.             local to window
  8873.     Print the line number in front of each line.  Tip: If you don't like
  8874.     wrapping lines to mix with the line numbers, set the 'showbreak'
  8875.     option to eight spaces:
  8876.         :set showbreak=\ \ \ \ \ \ \ \ 
  8877.  
  8878.             *'paragraphs'* *'para'*
  8879. paragraphs (para)    string    (default "IPLPPPQPP LIpplpipbp")
  8880.             global
  8881.     Specifies the nroff macros that separate paragraphs.  These are pairs
  8882.     of two letters (see section 6.4 |object_motions|).
  8883.  
  8884.                         *'paste'* *'nopaste'*
  8885. paste            toggle    (default off)
  8886.             global
  8887.             {not in Vi}
  8888.     Put Vim in Paste mode.  This is useful if you want to cut or copy
  8889.     some text from one window and paste it in Vim.  This will avoid
  8890.     unexpected effects.  When the 'paste' option is switched on (also when
  8891.     it was already on):
  8892.         - mapping in Insert mode is disabled
  8893.         - abbreviations are disabled
  8894.         - 'textwidth' is set to 0
  8895.         - 'autoindent' is reset
  8896.         - 'smartindent' is reset
  8897.         - 'cindent' is reset
  8898.         - 'lisp' is reset
  8899.         - 'revins' is reset
  8900.         - 'ruler' is reset
  8901.         - 'showmatch' is reset
  8902.         - 'formatoptions' is used like it is empty
  8903.     NOTE: When you start editing another file while the 'paste' option is
  8904.     on, settings from the modelines or autocommands may change the
  8905.     settings again, causing trouble when pasting text.  You might want to
  8906.     set the 'paste' option again.
  8907.     When the 'paste' option is reset the mentioned options are restored to
  8908.     the value before the moment 'paste' was switched from off to on.
  8909.     Resetting 'paste' before ever setting it does not have any effect.  If
  8910.     you use this often, you could map a function key to the command ":set
  8911.     invpaste^V^M".
  8912.  
  8913.                         *'patchmode'* *'pm'*
  8914. patchmode (pm)        string    (default "")
  8915.             global
  8916.             {not in Vi}
  8917.     When non-empty the oldest version of a file is kept.  This can be used
  8918.     to keep the original version of a file if you are changing files in a
  8919.     source distribution.  Only the first time that a file is edited a copy
  8920.     of the original file will be kept.  The name of the copy is the name
  8921.     of the original file with the string in the 'patchmode' option
  8922.     appended.  This option should start with a dot.  Use a string like
  8923.     ".org".  'backupdir' must not be empty for this to work (Detail: The
  8924.     backup file is renamed to the patchmode file after the new file has
  8925.     been succesfully written, that's why it must be possible to write a
  8926.     backup file).  If there was no file to be backed up, an empty file is
  8927.     created.
  8928.  
  8929.                         *'path'* *'pa'*
  8930. path (pa)        string    (default on Unix: ".,/usr/include,,"
  8931.                    on OS/2:       ".,/emx/include,,"
  8932.                    other systems: ".,,")
  8933.             global
  8934.             {not in Vi}
  8935.     This is a list of directories which will be searched when using the
  8936.     gf, [f, ]f, ^Wf and other commands, provided that the file being
  8937.     searched for has a relative path (not starting with '/').  The
  8938.     directories in the 'path' option may be relative or absolute.
  8939.     - Use commas to separate directory names:
  8940.         :set path=.,/usr/local/include,/usr/include
  8941.     - Spaces can also be used to separate directory names (for backwards
  8942.       compatibility with version 3.0).  To have a space in a directory
  8943.       name, precede it with an extra backslash:
  8944.           :set path=.,/dir/with\\ space
  8945.     - To include a comma in a directory name precede it with an extra
  8946.       backslash:
  8947.           :set path=.,/dir/with\\,comma
  8948.     - To search relative to the directory where the current file is use
  8949.           :set path=.
  8950.     - To search in the current directory use an empty string between two
  8951.       commas:
  8952.         :set path=,,
  8953.     - A directory name may end in a ':' or '/'.
  8954.     - Environment variables are expanded |:set_env|.
  8955.     - Careful with '\' characters, type two to get one in the option:
  8956.         :set path=.,c:\\include
  8957.       Or just use '/' instead:
  8958.         :set path=.,c:/include
  8959.     Don't forget "." or files won't even be found in the same directory as
  8960.     the file!
  8961.     The maximum lenght is limited.  How much depends on the system, mostly
  8962.     it is something like 256 or 1024 characters.
  8963.  
  8964.                    *'readonly'* *'ro'* *'noreadonly'* *'noro'*
  8965. readonly (ro)        toggle    (default off)
  8966.             local to buffer
  8967.             {not in Vi}
  8968.     If on, writes fail unless you use a '!'.  Protects you from
  8969.     accidentally overwriting a file.  Default on when Vim is started
  8970.     in view mode ("vim -v") or when the executable is called "view".
  8971.     {not in Vi:}  When using the ":view" command the 'readonly' option is
  8972.     set for the newly edited buffer.  When using ":w!" the 'readonly'
  8973.     option is reset for the current buffer.
  8974.  
  8975.                         *'remap'* *'noremap'*
  8976. remap            toggle    (default on)
  8977.             global
  8978.     Allows for mappings to work recursively.  If you do not want this for
  8979.     a single entry, use the :noremap[!] command.
  8980.  
  8981.                         *'report'*
  8982. report            number    (default 2)
  8983.             global
  8984.     Threshold for reporting number of lines changed.  When the number of
  8985.     changed lines is more than 'report' a message will be given for most
  8986.     ":" commands.  For the ":substitute" command the number of
  8987.     substitutions is used instead of the number of lines.
  8988.  
  8989.              *'restorescreen'* *'rs'* *'norestorescreen'* *'nors'*
  8990. restorescreen (rs)    toggle    (default on)
  8991.             global
  8992.             {not in Vi}  {Windows 95/NT version only}
  8993.     When set, the screen contents is restored when exiting Vim.  This also
  8994.     happens when executing external commands.
  8995.  
  8996.                        *'revins'* *'ri'* *'norevins'* *'nori'*
  8997. revins (ri)        toggle    (default off)
  8998.             global
  8999.             {not in Vi}
  9000.             {only when compiled with RIGHTLEFT defined}
  9001.     Inserting characters in Insert mode will work backwards.  See "typing
  9002.     backwards" |ins_reverse|.  This option can be toggled with the CTRL-B
  9003.     command in Insert mode.  This option is reset when 'compatible' or
  9004.     'paste' is set.
  9005.  
  9006.                  *'rightleft'* *'rl'* *'norightleft'* *'norl'*
  9007. rightleft (rl)        toggle    (default off)
  9008.             local to window
  9009.             {not in Vi}
  9010.             {only when compiled with RIGHTLEFT defined}
  9011.     When on, display orientation becomes right-to-left, i.e., character
  9012.     that are stored in the file apear from the right to the left.  Using
  9013.     this option, it is possible to edit files for languages that are
  9014.     written from the right to the left such as Hebrew and Arabic.  This
  9015.     option is per window, so it is possible to edit mixed files
  9016.     simultaneously, or to view the same file in both ways (this is
  9017.     sometimes usefull when editing Hebrew TeX--XeT files).  See
  9018.     |vim_rlh.txt|.
  9019.  
  9020.                      *'ruler'* *'ru'* *'noruler'* *'noru'*
  9021. ruler (ru)        toggle    (default off)
  9022.             global
  9023.             {not in Vi}
  9024.     Show the line and column number of the cursor position in the status
  9025.     line, separated by a comma.  If there are characters in the line that
  9026.     take two positions on the screen, both the "real" column and the
  9027.     screen column are shown, separated with a dash.  For an empty line
  9028.     "0-1" is shown.  For an empty buffer the line number will also be
  9029.     zero: "0,0-1".  This option is reset when the 'paste' option is set.
  9030.     If you don't want to see the ruler all the time but want to know where
  9031.     you are, use "g CTRL-G" |g_CTRL-G|.
  9032.  
  9033.                         *'scroll'* *'scr'*
  9034. scroll (scr)        number    (default 'lines' / 2)
  9035.             local to window
  9036.     Number of lines to scroll with CTRL-U and CTRL-D commands.  Will be
  9037.     set to half the number of lines in the window when the window size
  9038.     changes.  If you give a count to the CTRL-U or CTRL-D command it will
  9039.     be used as the new value for 'scroll'.  Reset to 'lines' / 2 with
  9040.     ":set scroll=0".   {difference from vi: 'scroll' gives the number of
  9041.     screen lines instead of file lines, makes a difference when lines
  9042.     wrap}
  9043.  
  9044.                         *'scrolljump'* *'sj'*
  9045. scrolljump (sj)        number    (default 1)
  9046.             global
  9047.             {not in Vi}
  9048.     Minimal number of lines to scroll when the cursor gets off the
  9049.     screen (e.g., with "j").  Not used for scroll commands (e.g., CTRL-E,
  9050.     CTRL-D).  Useful if your terminal scrolls very slowly.
  9051.  
  9052.                         *'scrolloff'* *'so'*
  9053. scrolloff (so)        number    (default 0)
  9054.             global
  9055.             {not in Vi}
  9056.     Minimal number of screen lines to keep above and below the cursor.
  9057.     This will make some context visible around where you are working.  If
  9058.     you set it to a very large value (999) the cursor line will always be
  9059.     in the middle of the window (except at the start or end of the file or
  9060.     when long lines wrap).
  9061.  
  9062.                         *'sections'* *'sect'*
  9063. sections (sect)        string    (default "SHNHH HUnhsh")
  9064.             global
  9065.     Specifies the nroff macros that separate sections.  These are pairs of
  9066.     two letters (See section 6.4 |object_motions|).
  9067.  
  9068.                         *'secure'* *'nosecure'*
  9069. secure            toggle    (default off)
  9070.             global
  9071.             {not in Vi}
  9072.     When on, ":autocmd", shell and write commands are not allowed in
  9073.     ".vimrc" and ".exrc" in the current directory and map commands are
  9074.     displayed.  Switch it off only if you know that you will not run into
  9075.     problems, or when the 'exrc' option is off.  On Unix this option is
  9076.     only used if the ".vimrc" or ".exrc" is not owned by you.  This can be
  9077.     dangerous if the systems allows users to do a "chown".  You better set
  9078.     'secure' at the end of your ~/.vimrc then.
  9079.  
  9080.                         *'shell'* *'sh'*
  9081. shell (sh)        string    (default $SHELL or "sh",
  9082.                     MS-DOS and Win32: "command",
  9083.                     OS/2: "cmd")
  9084.             global
  9085.     Name of the shell to use for ! and :! commands.  When changing the
  9086.     value also check the 'shelltype', 'shellpipe' and 'shellredir'
  9087.     options.  It is allowed to give an argument to the command, e.g.
  9088.     "csh -f".  See |option_backslash| about including spaces and
  9089.     backslashes.  Environment variables are expanded |:set_env|.
  9090.  
  9091.                         *'shellcmdflag'* *'shcf'*
  9092. shellcmdflag (shcf)    string    (default: "-c", MS-DOS and Win32, when 'shell'
  9093.                     does not contain "sh" somewhere: "/c")
  9094.             global
  9095.             {not in Vi}
  9096.     Flag passed to the shell to execute "!" and ":!" commands; e.g.,
  9097.     "bash.exe -c ls" or "command.com /c dir".  For the MS-DOS-like
  9098.     systems, the default is set according to the value of 'shell', to
  9099.     reduce the need to set this option by the user.  It's not used for
  9100.     OS/2 (EMX figures this out itself).  See |option_backslash| about
  9101.     including spaces and backslashes.  See |win32_shell| for Win32.
  9102.  
  9103.                         *'shellpipe'* *'sp'*
  9104. shellpipe (sp)        string    (default ">", "| tee", "|& tee" or "2>&1| tee")
  9105.             global
  9106.             {not in Vi}
  9107.     String to be used to put the output of the ":make" command in the
  9108.     error file.  See also |:make_makeprg|.  See |option_backslash| about
  9109.     including spaces and backslashes.
  9110.     For the Amiga and MS-DOS the default is ">".  The output is directly
  9111.     saved in a file and not echoed to the screen.
  9112.     For Unix the default it "| tee".  The stdout of the compiler is saved
  9113.     in a file and echoed to the screen.  If the 'shell' option is "csh" or
  9114.     "tcsh" after initializations, the default becomes "|& tee".  If the
  9115.     'shell' option is "sh", "ksh", "zsh" or "bash" the default becomes
  9116.     "2>&1| tee".  This means that stderr is also included.
  9117.     The initialization of this option is done after reading the ".vimrc"
  9118.     and the other initializations, so that when the 'shell' option is set
  9119.     there, the 'shellpipe' option changes automatically, unless it was
  9120.     explicitly set before.
  9121.     When 'shellpipe' is set to an empty string, no redirection of the
  9122.     ":make" output will be done.  This is useful if you use a 'makeprg'
  9123.     that writes to 'errorfile' by itself.  If you want no piping, but do
  9124.     want to include the 'errorfile', set 'shellpipe' to a single space.
  9125.     Don't forget to precede the space with a backslash: ":set sp=\ ".
  9126.     In the future pipes may be used for filtering and this option will
  9127.     become obsolete (at least for Unix).
  9128.  
  9129.                         *'shellquote'* *'shq'*
  9130. shellquote (shq)    string    (default: ""; MS-DOS and Win32, when 'shell'
  9131.                     contains "sh" somewhere: "\"")
  9132.             global
  9133.             {not in Vi}
  9134.     Quoting character(s) passed to the shell to execute "!" and ":!"
  9135.     commands.  This is an empty string by default.  Only known to be
  9136.     useful for third-party shells on MS-DOS-like systems, such as the MKS
  9137.     Korn Shell or bash, where it should be "\"".  The default is adjusted
  9138.     according the value of 'shell', to reduce the need to set this option
  9139.     by the user.  See |win32_shell| for Win32.
  9140.  
  9141.                         *'shellredir'* *'srr'*
  9142. shellredir (srr)    string    (default ">", ">&" or ">%s 2>&1")
  9143.             global
  9144.             {not in Vi}
  9145.     String to be used to put the output of a filter in a temporary file.
  9146.     See also |:!|.  See |option_backslash| about including spaces and
  9147.     backslashes.
  9148.     The name of the temporary file can be represented by "%s" if necessary
  9149.     (the file name is appended automatically if no %s appears in the value
  9150.     of this option).
  9151.     The default is ">".  For Unix, if the 'shell' option is "csh", "tcsh"
  9152.     or "zsh" during initializations, the default becomes ">&".  If the
  9153.     'shell' option is "sh", "ksh" or "bash" the default becomes
  9154.     ">%s 2>&1".  This means that stderr is also included.
  9155.     The initialization of this option is done after reading the ".vimrc"
  9156.     and the other initializations, so that when the 'shell' option is set
  9157.     there, the 'shellredir' option changes automatically unless it was
  9158.     explicitly set before.
  9159.     In the future pipes may be used for filtering and this option will
  9160.     become obsolete (at least for Unix).
  9161.  
  9162.                         *'shelltype'* *'st'*
  9163. shelltype (st)        number    (default 0)
  9164.             global
  9165.             {not in Vi}
  9166.     On the Amiga this option influences the way how the commands work
  9167.     which use a shell.
  9168.     0 and 1: always use the shell
  9169.     2 and 3: use the shell only to filter lines
  9170.     4 and 5: use shell only for ':sh' command
  9171.     When not using the shell, the command is executed directly.
  9172.  
  9173.     0 and 2: use "shell 'shellcmdflag' cmd" to start external commands
  9174.     1 and 3: use "shell cmd" to start external commands
  9175.  
  9176.                    *'shiftround'* *'sr'* *'noshiftround'* *'nosr'*
  9177. shiftround (sr)        toggle    (default off)
  9178.             global
  9179.             {not in Vi}
  9180.     Round indent to multiple of 'shiftwidth'.  Applies to > and <
  9181.     commands.  CTRL-T and CTRL-D in Insert mode always round the indent to
  9182.     a multiple of 'shiftwidth' (this is vi compatible).
  9183.  
  9184.                         *'shiftwidth'* *'sw'*
  9185. shiftwidth (sw)        number    (default 8)
  9186.             local to buffer
  9187.     Number of spaces to use for each step of (auto)indent.
  9188.  
  9189.                         *'shortmess'* *'shm'*
  9190. shortmess (shm)        string    (default "")
  9191.             global
  9192.             {not in Vi}
  9193.     This option helps to avoid all the "Hit return" messages caused by
  9194.     file messages, for example  with CTRL-G, and to avoid some other
  9195.     messages.  It is a list of flags:
  9196.      flag    meaning when present
  9197.       f    use "(3 of 5)" instead of "(file 3 of 5)"
  9198.       i    use "[noeol]" instead of "[Incomplete last line]"
  9199.       l    use "999L, 888C" instead of "999 lines, 888 characters"
  9200.       m    use "[+]" instead of "[Modified]"
  9201.       n    use "[New]" instead of "[New File]"
  9202.       r    use "[RO]" instead of "[readonly]"
  9203.       w    use "[w]" instead of "written" for file write message.
  9204.       x    use "[tx]" instead of "[textmode]" and "[notx]" instead of
  9205.         "[notextmode]"
  9206.       a    all of the above abbreviations
  9207.  
  9208.       o    overwrite message for writing a file with subsequent message
  9209.         for reading a file (useful for ":wn" or when 'autowrite' on)
  9210.       s    don't give "search hit BOTTOM, continuing at TOP" or "search
  9211.         hit TOP, continuing at BOTTOM" messages
  9212.       t    trunctate file message at the start if it is too long to fit
  9213.         on the command line, "<" will appear in the left most column.
  9214.       W    don't give "written" or "[w]" when writing a file
  9215.  
  9216.     This gives you the opportunity to avoid that a change between buffers
  9217.     requires you to hit return, but still gives as useful a message as
  9218.     possible for the space available.  To get the whole message that you
  9219.     would have got with 'shm' empty, use ":file!"
  9220.     Useful values:
  9221.         shm=    No abbreviation of message.
  9222.         shm=a    Abbreviation, but no loss of information.
  9223.         shm=at    Abbreviation, and truncate message when necessary.
  9224.  
  9225.                  *'shortname'* *'sn'* *'noshortname'* *'nosn'*
  9226. shortname (sn)        toggle    (default off)
  9227.             local to buffer
  9228.             {not in Vi, not in MS-DOS versions}
  9229.     Filenames are assumed to be 8 characters plus one extension of 3
  9230.     characters.  Multiple dots in file names are not allowed.  When this
  9231.     option is on, dots in filenames are replaced with underscores when
  9232.     adding an extension (".~" or ".swp").  This option is not available
  9233.     for MS-DOS, because then it would always be on.  This option is useful
  9234.     when editing files on an MS-DOS compatible filesystem, e.g., messydos
  9235.     or crossdos.
  9236.  
  9237.                         *'showbreak'* *'sbr'*
  9238. showbreak (sbr)        string    (default "")
  9239.             global
  9240.             {not in Vi}
  9241.     String to put at the start of lines that have been wrapped.  Useful
  9242.     values are "> " or "+++ ".  Only printable characters are allowed,
  9243.     excluding <Tab> and comma (in a future version the comma might be used
  9244.     to separate the part that is shown at the end and at the start of a
  9245.     line).
  9246.  
  9247.                      *'showcmd'* *'sc'* *'noshowcmd'* *'nosc'*
  9248. showcmd (sc)        toggle    (default on, off for Unix)
  9249.             global
  9250.             {not in Vi}
  9251.     Show (partial) command in status line.  Set this option off if your
  9252.     terminal is slow.
  9253.  
  9254.                  *'showmatch'* *'sm'* *'noshowmatch'* *'nosm'*
  9255. showmatch (sm)        toggle    (default off)
  9256.             global
  9257.     When a bracket is inserted, briefly jump to the matching one.  The
  9258.     jump is only done if the match can be seen on the screen.
  9259.     A Beep is given if there is no match (no matter if the match can be
  9260.     seen or not).  This option is reset when the 'paste' option is set.
  9261.     When the 'm' flag is not included in 'cpoptions', typing a character
  9262.     will immediately move the cursor back to where it belongs.
  9263.  
  9264.                  *'showmode'* *'smd'* *'noshowmode'* *'nosmd'*
  9265. showmode (smd)        toggle    (default on, off when compiled with COMPATIBLE
  9266.                 defined)
  9267.             global
  9268.     If in Insert, Replace or Visual mode put a message on the last line.
  9269.     Use the 'M' flag in 'highlight' to set the type of highlighting for
  9270.     this message.
  9271.  
  9272.                         *'sidescroll'* *'ss'*
  9273. sidescroll (ss)        number    (default 0)
  9274.             global
  9275.             {not in Vi}
  9276.     The minimal number of columns to scroll horizontally.  Used only when
  9277.     the 'wrap' option is off and the cursor is moved off of the screen.
  9278.     When it is zero the cursor will be put in the middle of the screen.
  9279.     When using a slow terminal set it to a large number or 0.  When using
  9280.     a fast terminal use a small number or 1.  Not used for "zh" and "zl"
  9281.     commands.
  9282.  
  9283.                    *'smartcase'* *'scs'* *'nosmartcase'* *'noscs'*
  9284. smartcase (scs)        toggle    (default off)
  9285.             global
  9286.             {not in Vi}
  9287.     Override the 'ignorecase' option if the search pattern contains upper
  9288.     case characters.  Only used when the search pattern is typed and
  9289.     'ignorecase' option is on.  Used for the commands "/", "?", "n", "N",
  9290.     ":g" and ":s".  Not used for "*", "#", "gd", tag search, etc..
  9291.  
  9292.                  *'smartindent'* *'si'* *'nosmartindent'* *'nosi'*
  9293. smartindent (si)    toggle    (default off)
  9294.             local to buffer
  9295.             {not in Vi}
  9296.             {Only included when compiled with SMARTINDENT defined,
  9297.             check with ":version"}
  9298.     Do smart autoindenting when starting a new line.  Works best for C
  9299.     programs, but can also be used for other languages.  'cindent' does
  9300.     something like this, works better in most cases, but is more strict,
  9301.     see |C_indenting|.  When 'cindent' is on setting 'si' has no effect.
  9302.     Normally 'autoindent' should also be on when using 'smartindent'.
  9303.     An indent is automatically inserted:
  9304.     - After a line ending in '{'.
  9305.     - After a line starting with a keyword from 'cinwords'.
  9306.     - Before a line starting with '}' (only with the "O" command).
  9307.     When typing '}' as the first character in a new line, that line is
  9308.     given the same indent as the matching '{'.
  9309.     When typing '#' as the first character in a new line, the indent for
  9310.     that line is removed, the '#' is put in the first column.  The indent
  9311.     is restored for the next line.  If you don't want this, use this
  9312.     mapping: ":inoremap # X^H#", where ^H is entered with CTRL-V CTRL-H.
  9313.     When using the ">>" command, lines starting with '#' are not shifted
  9314.     right.
  9315.     'smartindent' is reset when the 'paste' option is set.
  9316.  
  9317.                  *'smarttab'* *'sta'* *'nosmarttab'* *'nosta'*
  9318. smarttab (sta)        toggle    (default off)
  9319.             global
  9320.             {not in Vi}
  9321.     When on, a <Tab> in front of a line inserts 'shiftwidth' positions,
  9322.     'tabstop' in other places.  When off a <Tab> always inserts 'tabstop'
  9323.     positions, 'shiftwidth' is only used for ">>" and the like.  See also
  9324.     section 4.3.4 |ins_expandtab|.
  9325.  
  9326.                    *'splitbelow'* *'sb'* *'nosplitbelow'* *'nosb'*
  9327. splitbelow (sb)        toggle    (default off)
  9328.             global
  9329.             {not in Vi}
  9330.     When on, spliting a window will put the new window below the current
  9331.     one.
  9332.  
  9333.                *'startofline'* *'sol'* *'nostartofline'* *'nosol'*
  9334. startofline (sol)    toggle    (default on)
  9335.             global
  9336.             {not in Vi}
  9337.     When on the commands listed below move the cursor to the first
  9338.     blank of the line.  When off the cursor is kept in the same column
  9339.     (if possible).  This applies to the commands: CTRL-D, CTRL-U, CTRL-B,
  9340.     CTRL-F, "G", "H", "M", "L", , and to the commands "d", "<<" and ">>"
  9341.     with a linewise operator and with "%" with a count.  This option is
  9342.     set when the 'compatible' option is set.
  9343.  
  9344.                         *'suffixes'* *'su'*
  9345. suffixes (su)        string    (default ".bak,~,.o,.h,.info,.swp")
  9346.             global
  9347.             {not in Vi}
  9348.     Files with these suffixes are ignored when multiple files match a
  9349.     wildcard.  See |suffixes|.  Commas can be used to separate the
  9350.     suffixes.  Spaces after the comma are ignored.  A dot is also seen as
  9351.     the start of a suffix.  To include a dot or comma in a suffix, precede
  9352.     it with a backslash (see |option_backslash| about including spaces and
  9353.     backslashes).
  9354.  
  9355.                         *'swapsync'* *'sws'*
  9356. swapsync (sws)        string    (default "fsync")
  9357.             global
  9358.             {not in Vi}
  9359.     When this option is not empty a swap file is synced to disk after
  9360.     writing to it.  This takes some time, especially on busy unix systems.
  9361.     When this option is empty parts of the swap file may be in memory and
  9362.     not written to disk.  When the system crashes you may lose more work.
  9363.     On Unix the system does a sync now and then without Vim asking for it,
  9364.     so the disadvantage of setting this option off is small.  On some
  9365.     systems the swap file will not be written at all.  For a unix system
  9366.     setting it to "sync" will use the sync() call instead of the default
  9367.     fsync(), which may work better on some systems.
  9368.  
  9369.                     *'tabstop'* *'ts'*
  9370. tabstop (ts)        number    (default 8)
  9371.             local to buffer
  9372.     Number of spaces that a <Tab> in the file counts for.  (See also
  9373.     ":retab" command in 11.3 |:retab|).
  9374.  
  9375.                         *'taglength'* *'tl'*
  9376. taglength (tl)        number    (default 0)
  9377.             global
  9378.     If non-zero, tags are significant up to this number of characters.
  9379.  
  9380.                  *'tagrelative'* *'tr'* *'notagrelative'* *'notr'*
  9381. tagrelative (tr)    toggle    (default on, off when compiled with COMPATIBLE
  9382.                 defined)
  9383.             global
  9384.             {not in Vi}
  9385.     If on and using a tag file in another directory, file names in that
  9386.     tag file are relative to the directory where the tag file is.  When
  9387.     the 'compatible' option is set, this option is reset.
  9388.  
  9389.                         *'tags'* *'tag'*
  9390. tags (tag)        string    (default "./tags,tags", when compiled with
  9391.                 Emacs tags enabled: "./tags,./TAGS,tags,TAGS")
  9392.             global
  9393.     Filenames for the tag command, separated by spaces or commas.  To
  9394.     include a space or comma in a filename, precede it with a backslash
  9395.     (see |option_backslash| about including spaces and backslashes).
  9396.     When a file name starts with "./", the '.' is replaced with the path
  9397.     of the current file.  But only when the 'd' flag is not included in
  9398.     'cpoptions'.  Environment variables are expanded |:set_env|.  Also see
  9399.     |tags_option|.
  9400.     When Vim was compiled with EMACS_TAGS defined Emacs-style tag files
  9401.     are also supported.  They are automatically recognized.  The default
  9402.     value becomes "./tags,./TAGS,tags,TAGS".  If ":version" shows
  9403.     "+emacs_tags" then the Emacs tags support is included.  {Vi: default
  9404.     is "tags /usr/lib/tags"}
  9405.  
  9406.                         *'term'*
  9407. term            string    (default is $TERM, if that fails:
  9408.                      on Unix: "ansi"
  9409.                         on Amiga: "amiga"
  9410.                        on MS-DOS: "pcterm"
  9411.                          on OS/2: "os2ansi"
  9412.                        on Win 32: "win32")
  9413.             global
  9414.     Name of the terminal.  Used for choosing the terminal control
  9415.     characters.  Environment variables are expanded |:set_env|.
  9416.     For example:
  9417.         :set term=$TERM
  9418.     See |termcap|.
  9419.  
  9420.                         *'terse'* *'noterse'*
  9421. terse            toggle    (default off)
  9422.             global
  9423.             {not in Vi}
  9424.     When set: Add 's' flag to 'shortmess' option (this makes the message
  9425.     for a search that hits the start or end of the file not being
  9426.     displayed).  When reset: Remove 's' flag from 'shortmess' option.  {Vi
  9427.     shortens a lot of messages}
  9428.  
  9429.                    *'textauto'* *'ta'* *'notextauto'* *'nota'*
  9430. textauto (ta)        toggle    (default on, off when compiled with COMPATIBLE
  9431.                 defined)
  9432.             global
  9433.             {not in Vi}
  9434.     When starting to edit a file a check is done for the line separator.
  9435.     If all lines end in <CR> <NL> 'textmode' is set, otherwise 'textmode'
  9436.     is reset.  When reading a file, the same is done, but this happens
  9437.     like 'textmode' has been set appropriately for that file only, the
  9438.     option is not changed.  See |textmode_io|.
  9439.  
  9440.                    *'textmode'* *'tx'* *'notextmode'* *'notx'*
  9441. textmode (tx)        toggle    (MS-DOS, Win32 and OS/2: default on, others:
  9442.                 default off)
  9443.             local to buffer
  9444.             {not in Vi}
  9445.     When off, <NL> separates lines.  When on, <CR> <NL> separates lines
  9446.     and CTRL-Z at end of file is ignored.  Only used when reading and
  9447.     writing files.  Set automatically when starting to edit a file and
  9448.     'textauto' is on.  See |textmode_io|.
  9449.  
  9450.                         *'textwidth'* *'tw'*
  9451. textwidth (tw)        number    (default 0)
  9452.             local to buffer
  9453.             {not in Vi}
  9454.     Maximum width of text that is being inserted.  A longer line will be
  9455.     broken after white space to get this width.  A zero value disables
  9456.     this.  'textwidth' is set to 0 when the 'paste' option is set.  When
  9457.     'textwidth' is zero, 'wrapmargin' may be used.  See also
  9458.     'formatoptions' and |ins_textwidth|.
  9459.  
  9460.                  *'tildeop'* *'top'* *'notildeop'* *'notop'*
  9461. tildeop (top)        toggle    (default off)
  9462.             global
  9463.             {not in Vi}
  9464.     When on: The tilde command "~" behaves like an operator.
  9465.  
  9466.                 *'timeout'* *'to'* *'notimeout'* *'noto'*
  9467. timeout    (to)        toggle (default on)
  9468.             global
  9469.                         *'ttimeout'* *'nottimeout'*
  9470. ttimeout        toggle (default off)
  9471.             global
  9472.             {not in Vi}
  9473.     These two options together determine the behaviour when part of a
  9474.     mapped key sequence or keyboard code has been received:
  9475.  
  9476.     timeout        ttimeout    action
  9477.     off        off        no time out
  9478.     on        on or off    time out on :mappings and key codes
  9479.     off        on        time out on key codes
  9480.  
  9481.     If there is no time out, Vim will wait until either the complete
  9482.     mapping or key sequence has been received, or it is clear that there
  9483.     is no mapping or key sequence for the received characters.  For
  9484.     example: if you have mapped "vl" and Vim has received 'v', the next
  9485.     character is needed to see if the 'v' is followed by an 'l'.  With a
  9486.     time out Vim will wait for about 1 second for the next character to
  9487.     arrive.  After that the already received characters are interpreted
  9488.     as single characters.  The waiting time can be changed with the
  9489.     'timeoutlen' option.
  9490.     On slow terminals or very busy systems time out may cause
  9491.     malfunctioning cursor keys.  If both options are off, Vim waits
  9492.     forever after an entered <Esc> if there are key codes that start
  9493.     with <Esc>.  You will have to type <Esc> twice.  If you do not have
  9494.     problems with key codes, but would like to have :mapped key
  9495.     sequences not time out in 1 second, set the ttimeout option and
  9496.     reset the timeout option.
  9497.  
  9498.                         *'timeoutlen'* *'tm'*
  9499. timeoutlen (tm)        number    (default 1000)
  9500.             global
  9501.             {not in all versions of Vi}
  9502.                         *'ttimeoutlen'* *'ttm'*
  9503. ttimeoutlen (ttm)    number    (default -1)
  9504.             global
  9505.             {not in Vi}
  9506.     The time in milliseconds that is waited for a key code or mapped key
  9507.     sequence to complete.  Normally only 'timeoutlen' is used and
  9508.     'ttimeoutlen' is -1.  When a different timeout value for key codes is
  9509.     desired set 'ttimeoutlen' to a non-negative number.
  9510.  
  9511.         ttimeoutlen    mapping delay       key code delay
  9512.                < 0          'timeoutlen'       'timeoutlen'
  9513.               >= 0          'timeoutlen'       'ttimeoutlen'
  9514.  
  9515.     The timeout only happens when the 'timeout' and 'ttimeout' options
  9516.     tell so.  A useful setting would be
  9517.         :set timeout timeoutlen=3000 ttimeoutlen=100
  9518.     (time out on mapping after three seconds, time out on key codes after
  9519.     a tenth of a second).
  9520.  
  9521.                         *'title'* *'notitle'*
  9522. title            toggle    (default off, on when title can be restored)
  9523.             global
  9524.             {not in Vi}
  9525.     When on the title of the window will be set to "VIM - filename",
  9526.     where filename is the name of the file currently being edited.  Only
  9527.     works if the terminal supports setting window titles (currently Amiga
  9528.     console, Unix xterm and iris-ansi).
  9529.                                 *X11*
  9530.     When Vim was compiled with HAVE_X11 defined, the original title will
  9531.     be restored if possible.  The output of ":version" will include "+X11"
  9532.     when HAVE_X11 was defined, otherwise it will be "-X11".  This also
  9533.     works for the icon name |'icon'|.
  9534.     If the title cannot be restored, it is set to "Thanks for flying Vim".
  9535.     You will have to restore the title outside of Vim then.  When using an
  9536.     xterm from a remote machine you can use this command:
  9537.         rsh machine_name xterm -display $DISPLAY &
  9538.     then the WINDOWID environment variable should be inherited and the
  9539.     title of the window should change back to what it should be after
  9540.     exiting Vim (rather than using the "Thanks..." message).
  9541.  
  9542.                                 *'titlelen'*
  9543. titlelen        number    (default 85)
  9544.             global
  9545.             {not in Vi}
  9546.     Gives the percentage of 'columns' to use for the length of the window
  9547.     title.  When the title is longer, only the end of the path name is
  9548.     shown.  A '>' character is used to indicate this.  Using a percentage
  9549.     makes this adapt to the width of the window.  But it won't work
  9550.     perfectly, because the actual number of characters available also
  9551.     depends on the font used and other things in the title bar.  When
  9552.     'titlelen' is zero the full path is used.  Otherwise, values from 1 to
  9553.     30000 can be used.
  9554.  
  9555.                  *'ttybuiltin'* *'tbi'* *'nottybuiltin'* *'notbi'*
  9556. ttybuiltin (tbi)    toggle    (default on)
  9557.             global
  9558.             {not in Vi}
  9559.     When on, the builtin termcaps are searched before the external ones.
  9560.     When off the builtin termcaps are searched after the external ones.
  9561.     When this option is changed, you should set the 'term' option next for
  9562.     the change to take effect, for example:
  9563.         :set notbi term=$TERM
  9564.     See also |termcap|.
  9565.  
  9566.                      *'ttyfast'* *'tf'* *'nottyfast'* *'notf'*
  9567. ttyfast (tf)        toggle    (default off, on when 'term' is xterm, hpterm,
  9568.                     sun-cmd, scren, dtterm or iris-ansi)
  9569.             global
  9570.             {not in Vi}
  9571.     Indicates a fast terminal connection.  More characters will be sent to
  9572.     the screen for redrawing, instead of using insert/delete line
  9573.     commands.  Improves smoothness of redrawing when there are multiple
  9574.     windows and the terminal does not support a scrolling region.
  9575.     Also enables the extra writing of characters at the end of each screen
  9576.     line for lines that wrap.  This helps when using copy/paste with the
  9577.     mouse in an xterm and other terminals.
  9578.  
  9579.                         *'ttyscroll'* *'tsl'*
  9580. ttyscroll (tsl)        number    (default 999)
  9581.             global
  9582.     Maximum number of lines to scroll the screen.  If there are more lines
  9583.     to scroll the window is redrawn.  For terminals where scrolling is
  9584.     very slow and redrawing is not slow this can be set to a small number,
  9585.     e.g., 3, to speed up displaying.
  9586.  
  9587.                         *'ttytype'* *'tty'*
  9588. ttytype    (tty)        string    (default from $TERM)
  9589.             global
  9590.     Alias for 'term', see above.
  9591.  
  9592.                         *'undolevels'* *'ul'*
  9593. undolevels (ul)        number    (default 100, 1000 for Unix and OS/2, 0 when
  9594.                 compiled with COMPATIBLE defined)
  9595.             global
  9596.             {not in Vi}
  9597.     Maximum number of changes that can be undone.  Set to 0 for Vi
  9598.     compatibility: one level of undo and 'u' undoes itself.  Set to a
  9599.     negative number for no undo at all (saves memory).
  9600.  
  9601.                         *'updatecount'* *'uc'*
  9602. updatecount (uc)    number    (default 200, 0 when compiled with COMPATIBLE
  9603.                 defined)
  9604.             global
  9605.             {not in Vi}
  9606.     After typing this many characters the swap file will be written to
  9607.     disk.  When zero no swap file will be created at all (see chapter on
  9608.     recovery |crash_recovery|).  'updatecount' is set to zero by starting
  9609.     Vim with the "-n" option, see |starting|.  When editing in readonly
  9610.     mode this option will be initialized to 10000.  Also see |'swapsync'|.
  9611.  
  9612.                         *'updatetime'* *'ut'*
  9613. updatetime (ut)        number    (default 4000)
  9614.             global
  9615.             {not in Vi}
  9616.     If this many milliseconds nothing is typed the swap file will be
  9617.     written to disk (see chapter on recovery |crash_recovery|).
  9618.  
  9619.                     *'viminfo'* *'vi'*
  9620. viminfo (vi)        string    (default "")
  9621.             global
  9622.             {not in Vi}
  9623.             {only included when Vim was compiled with VIMINFO
  9624.             defined.  ":version" shows "+viminfo" if it was}
  9625.     When non-empty, the viminfo file is read upon startup and written
  9626.     when exiting Vim (see |viminfo_file|).  The string should be a comma
  9627.     separated list of parameters, each consisting of a single character
  9628.     identifying the particular parameter, followed by a number or string
  9629.     which specifies the value of that parameter.  If a particular
  9630.     character is left out, then the default value is used for that
  9631.     parameter.  The following is a list characters and their meanings.
  9632.         char     value
  9633.          '    Maximum number of previously edited files for which
  9634.             the marks are remembered.  This parameter must always
  9635.             be included when 'viminfo' is non-empty.
  9636.          f    Whether file marks need to be stored.  If zero, file
  9637.              marks ('0 to '9, 'A to 'Z) are not stored.  When not
  9638.             present or when non-zero, they are all stored.  '0 is
  9639.             used for the current cursor position (when exiting or
  9640.             when doing ":wviminfo").
  9641.          r    Removable media.  The argument is a string (up to the
  9642.             next ',').  This parameter can be given several times.
  9643.             Each specifies the start of a path for which no marks
  9644.             will be stored.  This is to avoid removable media.
  9645.             For MS-DOS you could use "ra:,rb:", for Amiga
  9646.             "rdf0:,rdf1:,rdf2:".  Case is ignored.  Maximum length
  9647.             of each 'r' argument is 50 characters.
  9648.          "    Maximum number of lines saved for each register.  If
  9649.             zero then registers are not saved.  When not included,
  9650.             all lines are saved.  Dont forget to put a backslash
  9651.             before the ", otherwise it will be recognized as the
  9652.             start of a comment!
  9653.          :    Maximum number of items in the command line history to
  9654.             be saved.  When not included, the value of 'history'
  9655.             is used.
  9656.          /    Maximum number of items in the search pattern history
  9657.             to be saved.  If non-zero, then the previous search
  9658.             and substitute patterns are also saved.  When not
  9659.             included, the value of 'history' is used.
  9660.          n    Name of the viminfo file.  The name must immediately
  9661.             follow the 'n'.  Must be the last one!  If the "-i"
  9662.             argument was given when starting Vim, that filename
  9663.             overrides the one given here with 'viminfo'.
  9664.             Environment variables are expanded when opening the
  9665.             file, not when setting the option.
  9666.     Example:
  9667.         :set viminfo='50,\"1000,:0,n~/vim/viminfo
  9668.     means that marks will be remembered for the last 50 files you edited,
  9669.     contents of registers (up to 1000 lines each) will be remembered,
  9670.     command line history will not be saved, and since '/' is not
  9671.     specified, the default will be used, that is, save all of the search
  9672.     history, and also the previous search and substitute patterns.
  9673.     And the name of the file to use is "~/vim/viminfo".
  9674.  
  9675.             *'visualbell'* *'vb'* *'novisualbell'* *'novb'* *beep*
  9676. visualbell (vb)        toggle    (default off)
  9677.             global
  9678.             {not in Vi}
  9679.     Use visual bell instead of beeping.  The terminal code to display the
  9680.     visual bell is given with 't_vb'.  When no beep of flash is wanted,
  9681.     use ":set vb t_vb=".  Does not work on the Amiga, you always get a
  9682.     screen flash.  Also see 'errorbells'.
  9683.  
  9684.                         *'warn'* *'nowarn'*
  9685. warn            toggle    (default on)
  9686.             global
  9687.     Give a warning message when a shell command is used while the buffer
  9688.     has been changed.
  9689.  
  9690.              *'weirdinvert'* *'wiv'* *'noweirdinvert'* *'nowiv'*
  9691. weirdinvert (wiv)    toggle    (default off)
  9692.             global
  9693.             {not in Vi}
  9694.     Set this option for terminals that have a weird inversion method.
  9695.     Makes the start/end invert code outputted before every character.
  9696.     Slows down terminal I/O a lot, but it makes Visual mode work.
  9697.  
  9698.                         *'whichwrap'* *'ww'*
  9699. whichwrap (ww)        string    (default "b,s", "" when compiled with
  9700.                 COMPATIBLE defined)
  9701.             global
  9702.             {not in Vi}
  9703.     Allow specified keys that move the cursor left/right to wrap to the
  9704.     previous/next line when the cursor is on the first/last character in
  9705.     the line.  Concatenate characters to allow this for these keys:
  9706.         char   key      mode
  9707.          b    <BS>     Normal and Visual
  9708.          s    <Space>     Normal and Visual
  9709.          h    "h"     Normal and Visual
  9710.          l    "l"     Normal and Visual
  9711.          <    <Left>     Normal and Visual
  9712.          >    <Right>      Normal and Visual
  9713.          [    <Left>     Insert and Replace
  9714.          ]    <Right>     Insert and Replace
  9715.     For example:
  9716.         ":set ww=<,>,[,]"
  9717.     allows wrap only when cursor keys are used.
  9718.     When the movement keys are used in combination with a delete or change
  9719.     operator, the newline also counts for a character.  This makes "3h"
  9720.     different from "3dh" when the cursor crosses the end of a line.  This
  9721.     is also true for "x" and "X", because they do the same as "dl" and
  9722.     "dh".  If you use this, you may also want to use the mapping
  9723.     ":map <BS> X" to make backspace delete the character in front of the
  9724.     cursor.  When 'compatible' is set, 'whichwrap' is set to "".
  9725.  
  9726.                         *'wildchar'* *'wc'*
  9727. wildchar (wc)        number    (default <Tab>, CTRL-E when compiled with
  9728.                 COMPATIBLE defined)
  9729.             global
  9730.             {not in Vi}
  9731.     Character you have to type to start wildcard expansion in the
  9732.     command line.  CTRL-E is used when the 'compatible' option is set.
  9733.     The character is not recognized when used inside a macro.  Although
  9734.     'wc' is a number option, you can set it to a special key: ":set
  9735.     wc=<Esc>".
  9736.  
  9737.                         *'winheight'* *'wh'*
  9738. winheight (wh)        number    (default 0)
  9739.             global
  9740.             {not in Vi}
  9741.     Minimal number of lines for the current window.  If the current
  9742.     window is smaller, its size is increased, at the cost of the height
  9743.     of other windows.  Set it to 999 to make the current window always
  9744.     fill the screen.  Set it to a small number for normal editing.  The
  9745.     height is not adjusted after one of the commands to change the
  9746.     height of the current window.
  9747.  
  9748.                         *'wrap'* *'nowrap'*
  9749. wrap            toggle    (default on)
  9750.             local to window
  9751.             {not in Vi}
  9752.     When on, lines longer than the width of the window will wrap and
  9753.     displaying continues on the next line.  When off lines will not wrap
  9754.     and only part of long lines will be displayed.  When the cursor is
  9755.     moved to a part that is not shown, the screen will scroll horizontally
  9756.     (also see 'sidescroll' option and |wrap_off|).  If you want to break
  9757.     long lines, see 'textwidth'.
  9758.  
  9759.                         *'wrapmargin'* *'wm'*
  9760. wrapmargin (wm)        number    (default 0)
  9761.             local to buffer
  9762.     Number of characters from the right window border where wrapping
  9763.     starts.  When typing text beyond this limit, a newline will be
  9764.     inserted and inserting continues on the next line.  When 'textwidth'
  9765.     is non-zero, this option is not used.  See also 'formatoptions' and
  9766.     |ins_textwidth|.  {Vi: works differently and less useful}
  9767.  
  9768.                    *'wrapscan'* *'ws'* *'nowrapscan'* *'nows'*
  9769. wrapscan (ws)        toggle    (default on)
  9770.             global
  9771.     Searches wrap around the end of the file.
  9772.  
  9773.                    *'writeany'* *'wa'* *'nowriteany'* *'nowa'*
  9774. writeany (wa)        toggle    (default off)
  9775.             global
  9776.     Allows writing to any file with no need for "!" override.
  9777.  
  9778.                  *'writebackup'* *'wb'* *'nowritebackup'* *'nowb'*
  9779. writebackup (wb)    toggle    (default on, off when compiled with WRITEBACKUP
  9780.                  not defined or COMPATIBLE defined)
  9781.             global
  9782.             {not in Vi}
  9783.     Make a backup before overwriting a file.  The backup is removed after
  9784.     the file was successfully written, unless the 'backup' option is
  9785.     also on.  Reset this option if your file system is almost full.  See
  9786.     the table in section 5.4 for another explanation |backup_table|.
  9787.  
  9788.                         *'writedelay'* *'wd'*
  9789. writedelay (wd)        number    (default 0)
  9790.             global
  9791.             {not in Vi}
  9792.     The number of microseconds to wait for each character sent to the
  9793.     screen.  When non-zero, characters are sent to the terminal one by
  9794.     one.  For MS-DOS pcterm this does not work.  For debugging purposes.
  9795.  
  9796.  
  9797. 20. Terminal information                *terminal_info*
  9798. ========================
  9799.  
  9800. Vim uses information about the terminal you are using to fill the screen and
  9801. recognize what keys you hit.  If this information is not correct the screen
  9802. may be messed up or keys may not be recognized.  The actions which have to be
  9803. performed on the screen are accomplished by outputting a string of
  9804. characters.  Special keys produce a string of characters.  These strings are
  9805. stored in the terminal options, see section 20.2 |terminal_options|.
  9806.  
  9807.  
  9808. 20.1 Startup                        *startup_terminal*
  9809.  
  9810. When Vim is started a default terminal type is assumed.  For the Amiga this is
  9811. a standard CLI window, for MS-DOS the pc terminal, for Unix an ansi terminal.
  9812. A few other terminal types are always available, see below |builtin_terms|.
  9813.  
  9814. You can give the terminal name with the '-T' Vim argument.  If it is not given
  9815. Vim will try to get the name from the TERM environment variable.
  9816.  
  9817.                             *termcap* *terminfo*
  9818. On Unix the terminfo database or termcap file is used.  This is referred to as
  9819. "termcap" in all the documentation.  At compile time, when running configure,
  9820. the choice whether to use terminfo or termcap is done automatically.  When
  9821. running Vim the output of ":version" will show "+terminfo" if terminfo is
  9822. used.  If terminfo is not used "-terminfo" is shown.
  9823.  
  9824. On non-Unix systems a termcap is only available if Vim was compiled with
  9825. TERMCAP defined.
  9826.  
  9827.                             *builtin_terms*
  9828. Which builtin terminals are available depends on a few defines in feature.h,
  9829. which needs to be set at compile time:
  9830.     define        output of ":version"    terminals builtin
  9831. NO_BUILTIN_TCAPS    -builtin_terms        none
  9832. SOME_BUILTIN_TCAPS    +builtin_terms        most common ones (default)
  9833. ALL_BUILTIN_TCAPS    ++builtin_terms        all available
  9834.  
  9835. You can see a list of available builtin terminals with ":set term=xxx".
  9836.  
  9837. If the termcap code is included Vim will try to get the strings for the
  9838. terminal you are using from the termcap file and the builtin termcaps.  Both
  9839. are always used, if an entry for the terminal you are using is present.  Which
  9840. one is used first depends on the 'ttybuiltin' option:
  9841.  
  9842. 'ttybuiltin' on        1: builtin termcap    2: external termcap
  9843. 'ttybuiltin' off    1: external termcap    2: builtin termcap
  9844.  
  9845. If an option is missing in one of them, it will be obtained from the other
  9846. one.  If an option is present in both, the one first encountered is used.
  9847.  
  9848. Which external termcap file is used varies from system to system and may
  9849. depend on the environment variables "TERMCAP" and "TERMPATH".  See "man
  9850. tgetent".
  9851.  
  9852. For normal editing the terminal will be put into "raw" mode.  The strings
  9853. defined with 't_ti' and 't_ks' will be sent to the terminal.  Normally this
  9854. puts the terminal in a state where the termcap codes are valid and activates
  9855. the cursor and function keys.  When Vim exits the terminal will be put back
  9856. into the mode it was before Vim started.  The strings defined with 't_te' and
  9857. 't_ke' will be sent to the terminal.  On the Amiga with commands that execute
  9858. an external command (e.g., "!!") the terminal will be put into Normal mode for
  9859. a moment.  This means that you can stop the output to the screen by hitting a
  9860. printing key.  Output resumes when you hit <BS>.
  9861.  
  9862.                             *cs7-problem*
  9863. Note: If the terminal settings are changed after running Vim, you might have
  9864. an illegal combination of settings.  This has been reported on Solaris 2.5
  9865. with "stty cs8 parenb", which is restored as "stty cs7 parenb".  Use
  9866. "stty cs8 -parenb -istrip" instead, this is restored correctly.
  9867.  
  9868. Some termcap entries are wrong in the sense that after sending 't_ks' the
  9869. cursor keys send codes different from the codes defined in the termcap.  To
  9870. avoid this you can set 't_ks' (and 't_ke') to empty strings.  This must be
  9871. done during initialization (see 3.4 |initialization|), otherwise its too late.
  9872.  
  9873. Some termcap entries assume that the highest bit is always reset.  For
  9874. example: The cursor-up entry for the amiga could be ":ku=\EA:".  But the Amiga
  9875. really sends "\233A".  This works fine if the highest bit is reset, e.g., when
  9876. using an Amiga over a serial line.  If the cursor keys don't work, try the
  9877. entry ":ku=\233A:".
  9878.  
  9879. Some termcap entries have the entry ":ku=\E[A:".  But the Amiga really sends
  9880. "\233A".  On output "\E[" and "\233" are often equivalent, on input they
  9881. aren't.  You will have to change the termcap entry, or change the key code with
  9882. the :set command to fix this.
  9883.  
  9884. Many cursor key codes start with an <Esc>.  Vim must find out if this a single
  9885. hit of the <Esc> key or the start of a cursor key sequence.  It waits for a
  9886. next character to arrive.  If it does not arrive within one second a single
  9887. <Esc> is assumed.  On very slow systems this may fail, causing cursor keys not
  9888. to work sometimes.  If you discover this problem reset the 'timeout' option.
  9889. Vim will wait for the next character to arrive after an <Esc>.  If you want to
  9890. enter a single <Esc> you must type it twice.  Resetting the 'esckeys' option
  9891. avoids this problems in Insert mode, but you lose the possibility to use
  9892. cursor and function keys in Insert mode.
  9893.  
  9894. On the Amiga the recognition of window resizing is activated only when the
  9895. terminal name is "amiga" or "builtin_amiga".
  9896.  
  9897. Some terminals have confusing codes for the cursor keys.  The televideo 925 is
  9898. such a terminal.  It sends a CTRL-H for cursor-left.  This would make it
  9899. impossible to distinguish a backspace and cursor-left.  To avoid this problem
  9900. CTRL-H is never recognized as cursor-left.
  9901.  
  9902.                     *vt100_cursor_keys* *xterm_cursor_keys*
  9903. Other terminals (e.g., vt100 and xterm) have cursor keys that send <Esc>OA,
  9904. <Esc>OB, etc.  Unfortunately these are valid commands in insert mode: Stop
  9905. insert, Open a new line above the new one, start inserting 'A', 'B', etc.
  9906. Instead of performing these commands Vim will recognize this key sequence as a
  9907. cursor key movement.  To avoid this you could use these settings:
  9908.     :set notimeout        " don't timeout on mappings
  9909.     :set ttimeout        " do timeout on terminal key codes
  9910.     :set timeoutlen=100    " timemout in 100 msec
  9911. This requires the keys to be hit withing 100msec.  When you type you normally
  9912. are not that fast.  The cursor key codes arrive within 100 msec, so they are
  9913. still recognized.
  9914.  
  9915. The default termcap entry for xterm on sun and other platforms does not
  9916. contain the entry for scroll regions.  Add ":cs=\E[%i%d;%dr:" to the xterm
  9917. entry in /etc/termcap and everything should work.
  9918.  
  9919.                             *xterm_end_home_keys*
  9920. On some systems (at least on FreeBSD with X386 3.1.2) the codes that the <End>
  9921. and <Home> keys send contain a <Nul> character.  To make these keys send the
  9922. proper key code, add these lines to your ~/.Xdefaults file:
  9923.  
  9924. *VT100.Translations:        #override \n\
  9925.         <Key>Home: string("0x1b") string("[7~") \n\
  9926.         <Key>End: string("0x1b") string("[8~")
  9927.  
  9928.  
  9929. 20.2 Terminal options                    *terminal_options*
  9930.  
  9931. The terminal options can be set just like normal options.  But they are not
  9932. shown with the ":set all" command.  Instead use ":set termcap".
  9933.  
  9934. It is always possible to change individual strings by setting the
  9935. appropriate option.  For example:
  9936.  
  9937.     :set t_ce=^V^[[K    (CTRL-V, <Esc>, [, K)
  9938.  
  9939. {Vi: no terminal options.  You have to exit Vi, edit the termcap entry and
  9940. try again}
  9941.  
  9942. The options are listed below.  The associated termcap code is always equal to
  9943. the last two characters of the option name.  Two termcap codes are required:
  9944. Cursor positioning and clear screen.
  9945.  
  9946. OUTPUT CODES
  9947.     option    meaning
  9948.  
  9949.     t_AL    add number of blank lines            *t_AL* *'t_AL'*
  9950.     t_al    add new blank line                *t_al* *'t_al'*
  9951.     t_cd    clear to end of screen                *t_cd* *'t_cd'*
  9952.     t_ce    clear to end of line                *t_ce* *'t_ce'*
  9953.     t_cl    clear screen (required!)            *t_cl* *'t_cl'*
  9954.     t_cm    cursor motion (required!)            *t_cm* *'t_cm'*
  9955.     t_CS    if non-empty, cursor relative to scroll region    *t_CS* *'t_CS'*
  9956.     t_cs    define scrolling region                *t_cs* *'t_cs'*
  9957.     t_da    if non-empty, lines from above scroll down    *t_da* *'t_da'*
  9958.     t_db    if non-empty, lines from below scroll up    *t_db* *'t_db'*
  9959.     t_DL    delete number of lines                *t_DL* *'t_DL'*
  9960.     t_dl    delete line                    *t_dl* *'t_dl'*
  9961.     t_ke    out of "keypad transmit" mode            *t_ke* *'t_ke'*
  9962.     t_ks    put terminal in "keypad transmit" mode        *t_ks* *'t_ks'*
  9963.     t_md    bold mode                    *t_md* *'t_md'*
  9964.     t_me    Normal mode (undoes t_mr and t_md)        *t_me* *'t_me'*
  9965.     t_mr    reverse (invert) mode                *t_mr* *'t_mr'*
  9966.                                 *t_ms* *'t_ms'*
  9967.     t_ms    if non-empty, cursor can be moved in standout/inverse mode
  9968.     t_RI    cursor number of chars right            *t_RI* *'t_RI'*
  9969.     t_se    standout end                    *t_se* *'t_se'*
  9970.     t_so    standout mode                    *t_so* *'t_so'*
  9971.     t_sr    scroll reverse (backward)            *t_sr* *'t_sr'*
  9972.     t_te    out of "termcap" mode                *t_te* *'t_te'*
  9973.     t_ti    put terminal in "termcap" mode            *t_ti* *'t_ti'*
  9974.     t_ue    underline end                    *t_ue* *'t_ue'*
  9975.     t_us    underline mode                    *t_us* *'t_us'*
  9976.     t_vb    visual bell                    *t_vb* *'t_vb'*
  9977.     t_ve    cursor visible                    *t_ve* *'t_ve'*
  9978.     t_vi    cursor invisible                *t_vi* *'t_vi'*
  9979.     t_vs    cursor very visible                *t_vs* *'t_vs'*
  9980.     t_ZH    italics mode                    *t_ZH* *'t_ZH'*
  9981.     t_ZR    italics end                    *t_ZR* *'t_ZR'*
  9982.  
  9983. KEY CODES
  9984. Note: Use the <> form if possible
  9985.  
  9986.     option    name        meaning
  9987.  
  9988.     t_ku    <Up>        arrow up            *t_ku* *'t_ku'*
  9989.     t_kd    <Down>        arrow down            *t_kd* *'t_kd'*
  9990.     t_kr    <Right>        arrow right            *t_kr* *'t_kr'*
  9991.     t_kl    <Left>        arrow left            *t_kl* *'t_kl'*
  9992.         <S-Up>        shift arrow up
  9993.         <S-Down>    shift arrow down
  9994.     t_%i    <S-Right>    shift arrow right        *t_%i* *'t_%i'*
  9995.     t_#4    <S-Left>    shift arrow left        *t_#4* *'t_#4'*
  9996.     t_k1    <F1>        function key 1            *t_k1* *'t_k1'*
  9997.     t_k2    <F2>        function key 2             *t_k2* *'t_k2'*
  9998.     t_k3    <F3>        function key 3             *t_k3* *'t_k3'*
  9999.     t_k4    <F4>        function key 4             *t_k4* *'t_k4'*
  10000.     t_k5    <F5>        function key 5             *t_k5* *'t_k5'*
  10001.     t_k6    <F6>        function key 6             *t_k6* *'t_k6'*
  10002.     t_k7    <F7>        function key 7             *t_k7* *'t_k7'*
  10003.     t_k8    <F8>        function key 8             *t_k8* *'t_k8'*
  10004.     t_k9    <F9>        function key 9             *t_k9* *'t_k9'*
  10005.     t_k;    <F10>        function key 10         *t_k;* *'t_k;'*
  10006.     t_F1    <F11>        function key 11         *t_F1* *'t_F1'*
  10007.     t_F2    <F12>        function key 12         *t_F2* *'t_F2'*
  10008.         <S-F1)        shifted function key 1
  10009.         <S-F2>        shifted function key 2
  10010.         <S-F3>        shifted function key 3
  10011.         <S-F4>        shifted function key 4
  10012.         <S-F5>        shifted function key 5
  10013.         <S-F6>        shifted function key 6
  10014.         <S-F7>        shifted function key 7
  10015.         <S-F8>        shifted function key 8
  10016.         <S-F9>        shifted function key 9
  10017.         <S-F10>        shifted function key 10
  10018.         <S-F11>        shifted function key 11
  10019.         <S-F12>        shifted function key 12
  10020.     t_%1    <Help>        help key            *t_%1* *'t_%1'*
  10021.     t_&8    <Undo>        undo key            *t_&8* *'t_&8'*
  10022.     t_kI    <Insert>    insert key            *t_kI* *'t_kI'*
  10023.     t_kD    <Delete>    delete key            *t_kD* *'t_kD'*
  10024.     t_kb    <BS>        backspace key            *t_kb* *'t_kb'*
  10025.     t_kh    <Home>        home key            *t_kh* *'t_kh'*
  10026.     t_@7    <End>        end key                *t_@7* *'t_@7'*
  10027.     t_kP    <PageUp>    page-up key            *t_kP* *'t_kP'*
  10028.     t_kN    <PageDown>    page-down key            *t_kN* *'t_kN'*
  10029.     t_K1    <kHome>        keypad home key            *t_K1* *'t_K1'*
  10030.     t_K4    <kEnd>        keypad end key            *t_K4* *'t_K4'*
  10031.     t_K3    <kPageUp>    keypad page-up key        *t_K3* *'t_K3'*
  10032.     t_K5    <kPageDown>    keypad page-down key        *t_K5* *'t_K5'*
  10033.  
  10034. Note about t_so and t_mr: When the termcap entry "so" is not present the
  10035. entry for "mr" is used.  And vice versa.  The same is done for "se" and "me".
  10036. If your terminal supports both inversion and standout mode, you can see two
  10037. different modes.  If you terminal supports only one of the modes, both will
  10038. look the same.
  10039.  
  10040. If inversion or other highlighting does not work correctly, try setting the
  10041. 'weirdinvert' option.  This makes the start-highlight or end-highlight termcap
  10042. code to be outputted before every character.  This slows down terminal I/O a
  10043. lot, but it makes inversion work on some terminals.
  10044.  
  10045. Some termcaps do not include an entry for 'cs' (scroll region), although the
  10046. terminal does support it.  For example: xterm on a sun.  You can use the
  10047. builtin_xterm or define t_cs yourself.  For example:
  10048.  
  10049.     :set t_cs=^V^[[%i%d;%dr
  10050.  
  10051. Where ^V is CTRL-V and ^[ is <Esc>.
  10052.  
  10053. Unfortunately it is not possible to deduct from the termcap how cursor
  10054. positioning should be done when using a scrolling region: Relative to the
  10055. beginning of the screen or relative to the beginning of the scrolling region.
  10056. Most terminals use the first method.  A known exception is the MS-DOS console
  10057. (pcterm).  The 't_CS' option should be set to any string when cursor
  10058. positioning is relative to the start of the scrolling region.  It should be
  10059. set to an empty string otherwise.  It is default "yes" when 'term' is
  10060. "pcterm".
  10061.  
  10062. Note for xterm users: The shifted cursor keys normally don't work.  You can
  10063.     make them work with the xmodmap command and some mappings in Vim.
  10064.  
  10065.     Give these commands in the xterm:
  10066.         xmodmap -e "keysym Up = Up F13"
  10067.         xmodmap -e "keysym Down = Down F16"
  10068.         xmodmap -e "keysym Left = Left F18"
  10069.         xmodmap -e "keysym Right = Right F19"
  10070.  
  10071.     And use these mappings in Vim:
  10072.         :map <t_F3> <S-Up>
  10073.         :map! <t_F3> <S-Up>
  10074.         :map <t_F6> <S-Down>
  10075.         :map! <t_F6> <S-Down>
  10076.         :map <t_F8> <S-Left>
  10077.         :map! <t_F8> <S-Left>
  10078.         :map <t_F9> <S-Right>
  10079.         :map! <t_F9> <S-Right>
  10080.  
  10081. Instead of, say, <S-Up> you can use any other command that you want to use the
  10082. shift-cursor-up key for.  (Note: To help people that have a Sun keyboard with
  10083. left side keys F14 is not used because it is confused with the undo key; F15
  10084. is not used, because it does a window-to-front; F17 is not used, because it
  10085. closes the window.  On other systems you can probably use them)
  10086.  
  10087.  
  10088. 20.3 Window size                    *window_size*
  10089.  
  10090. [This is about the size of the whole window Vim is using, not a window that is
  10091. created with the :split command]
  10092.  
  10093. If you are running Vim on an Amiga and the terminal name is "amiga" or
  10094. "builtin_amiga", the amiga-specific window resizing will be enabled.  On Unix
  10095. systems three methods are tried to get the window size:
  10096.  
  10097. - an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
  10098. - the environment variables "LINES" and "COLUMNS"
  10099. - from the termcap entries "li" and "co"
  10100.  
  10101. If everything fails a default size of 24 lines and 80 columns is assumed.  If
  10102. a window-resize signal is received the size will be set again.  If the window
  10103. size is wrong you can use the 'lines' and 'columns' options to set the
  10104. correct values.
  10105.  
  10106. One command can be used to set the screen size:
  10107.  
  10108.                             *:mod* *:mode*
  10109. :mod[e] [mode]
  10110.  
  10111. Without argument this only detects the screen size.  With MS-DOS it is
  10112. possible to switch screen mode.  [mode] can be one of these values:
  10113.     "bw40"        40 columns black&white
  10114.     "c40"        40 columns color
  10115.     "bw80"        80 columns black&white
  10116.     "c80"        80 columns color (most people use this)
  10117.     "mono"        80 columns monochrome
  10118.     "c4350"        43 or 50 lines EGA/VGA mode
  10119.     number        mode number to use, depends on your video card
  10120.  
  10121.  
  10122. 20.4 Slow and fast terminals            *slow_fast_terminal*
  10123.                         *slow_terminal*
  10124.  
  10125. If you have a fast terminal you may like to set the 'ruler' option.  The
  10126. cursor position is shown in the status line.  If you are using horizontal
  10127. scrolling ('wrap' option off) consider setting 'sidescroll' to a small
  10128. number.
  10129.  
  10130. If you have a slow terminal you may want to reset the 'showcmd' option.
  10131. The command characters will not be shown in the status line.  If the terminal
  10132. scrolls very slowly, set the 'scrolljump' to 5 or so.  If the cursor is moved
  10133. off the screen (e.g., with "j") Vim will scroll 5 lines at a time.  Another
  10134. possibility is to reduce the number of lines that Vim uses with the command
  10135. "z<height><CR>".
  10136.  
  10137. If the characters from the terminal are arriving with more than 1 second
  10138. between them you might want to set the 'timeout' and/or 'ttimeout' option.
  10139. See the "Options" chapter |options|.
  10140.  
  10141. If your terminal does not support a scrolling region, but it does support
  10142. insert/delete line commands, scrolling with multiple windows may make the
  10143. lines jump up and down.  If you don't want this set the 'ttyfast' option.
  10144. This will redraw the window instead of scroll it.
  10145.  
  10146. If your terminal scrolls very slowly, but redrawing is not slow, set the
  10147. 'ttyscroll' option to a small number, e.g., 3.  This will make Vim redraw the
  10148. screen instead of scrolling, when there are more than 3 lines to be scrolled.
  10149.  
  10150. If you are using Vim over a slow serial line, you might want to try running
  10151. Vim inside the "screen" program.  Screen will optimize the terminal I/O quite
  10152. a bit.
  10153.  
  10154. If you are testing termcap options, but you cannot see what is happening,
  10155. you might want to set the 'writedelay' option.  When non-zero, one character
  10156. is sent to the terminal at a time (does not work for MS-DOS).  This makes the
  10157. screen updating a lot slower, making it possible to see what is happening.
  10158.  
  10159.                             *hpterm*
  10160. When you are using an hpterm you probably run into a few problems.  The best
  10161. thing to do is to use an xterm instead.  If you want to use an hpterm for some
  10162. reason, try (re)setting some options:
  10163.     :set    t_sr=
  10164.     :set    t_al=
  10165.     :set    t_dl=
  10166.     :set    ttyfast            redraw screen instead of scrolling
  10167.  
  10168.     :set    weirdinvert        makes highlighting work better, but
  10169.                     slows down screen updating a lot
  10170.  
  10171.  
  10172. 20.5 Settings depending on terminal        *term_dependent_settings*
  10173.  
  10174. If you want to set options or mappings, depending on the terminal name, you
  10175. can do this best before starting Vim.  Use commands in your .login or .cshrc
  10176. to change the behaviour of Vim.  The most easy way is to change the VIMINIT
  10177. environment variable, depending on the value of $TERM.  Example:
  10178.  
  10179. case "$TERM" in
  10180.     console) export VIMINIT="so ~/.vimrc.con"
  10181.       xterm) export VIMINIT="so ~/.vimrc.X"
  10182.     vt[12]*) export VIMINIT="so ~/.vimrc.dec"
  10183.           *) export VIMINIT="so ~/.vimrc.common"
  10184. esac
  10185.  
  10186. These commands need to be adjusted for the shell you are using.
  10187.  
  10188. The "~/.vimrc.con", "~/.vimrc.X" and "~/.vimrc.doc" files can contain a line
  10189. "so ~/.vimrc.common", to include the common settings for all terminals.
  10190.  
  10191.  
  10192. 21. Differences from Vi and Ex                *vi_differences*
  10193. ==============================
  10194.  
  10195. Throughout this document differences between Vim and Vi/Ex are given in
  10196. curly braces.  This chapter only lists what has not been mentioned in
  10197. previous chapters.  Also see |vim_diff.txt| for an overview.
  10198.  
  10199.  
  10200. 21.1 Missing commands                    *missing_commands*
  10201.  
  10202. A large number of the "Ex" commands (the commands that start with a colon)
  10203. are included.  However, there is no Ex mode.
  10204.  
  10205. These commands are in Vi, but not in Vim.
  10206.  
  10207. Q            {Vi: go to Ex mode} See |pseudo-Q|.
  10208.  
  10209. :a[ppend]        {Vi: append text}        *:a* *:append*
  10210. :c[hange]        {Vi: replace lines}        *:c* *:change*
  10211. :i[nsert]        {Vi: insert text}        *:i* *:insert*
  10212. :o[pen]            {Vi: start editing in open mode}*:o* *:open*
  10213. :z            {Vi: print some lines}        *:z*
  10214.  
  10215.  
  10216. 21.2 Missing options                    *missing_options*
  10217.  
  10218. These options are in the Unix Vi, but not in Vim.  If you try to set one of
  10219. them you won't get an error message, but the value is not used and cannot be
  10220. printed.
  10221.  
  10222. autoprint (ap)        toggle    (default on)        *'autoprint'* *'ap'*
  10223. beautify (bf)        toggle    (default off)        *'beautify'* *'bf'*
  10224. flash (fl)        toggle    (default ??)        *'flash'* *'fl'*
  10225. graphic (gr)        toggle    (default off)        *'graphic'* *'gr'*
  10226. hardtabs (ht)        number    (default 8)        *'hardtabs'* *'ht'*
  10227.     number of spaces that a <Tab> moves on the display
  10228. mesg            toggle    (default on)        *'mesg'*
  10229. novice            toggle    (default ??)        *'novice'*
  10230. open            toggle    (default on)        *'open'*
  10231. optimize (op)        toggle    (default off)        *'optimize'* *'op'*
  10232. prompt            toggle    (default on)        *'prompt'*
  10233. redraw            toggle    (default off)        *'redraw'*
  10234. slowopen (slow)        toggle    (default off)        *'slowopen'* *'slow'*
  10235. sourceany        toggle    (default off)        *'sourceany'*
  10236. tagstack (tgst)        toggle  (default on)        *'tagstack'* *'tgst'*
  10237.     enables the tagstack and ":pop".
  10238. window (wi)        number    (default 23)        *'window'* *'wi'*
  10239. w300            number    (default 23)        *'w300'*
  10240. w1200            number    (default 23)        *'w1200'*
  10241. w9600            number    (default 23)        *'w9600'*
  10242.  
  10243.  
  10244. 21.3 Limits                        *limits*
  10245.  
  10246. Vim has only a few limits for the files that can be edited {Vi: can not handle
  10247. <Nul> characters and characters above 128, has limited line length, many other
  10248. limits}.
  10249.  
  10250. Maximum line length       On machines with 16-bit ints (Amiga and MS-DOS real
  10251.                mode): 32767, otherwise 2147483647 characters.
  10252.                Longer lines are split.
  10253. Maximum number of lines       2147483647 lines.
  10254. Maximum file size       Only limited by available disk space for the swap
  10255.                file.
  10256. Length of a file name       Unix and Win32: 1024 characters, otherwise 256
  10257.                characters.
  10258. Length of an expanded string option
  10259.                Unix and Win32: 1024 characters, otherwise 256
  10260.                characters
  10261. Maximum display width       Unix and Win32: 1024 characters, otherwise 255
  10262.                characters
  10263. Maximum lhs of a mapping   50 characters.
  10264.  
  10265. Information for undo and registers are kept in memory, thus when making (big)
  10266. changes the amount of (virtual) memory available limits the number of undo
  10267. levels and the text that can be kept in registers.  Other things are also kept
  10268. in memory:  Command line history, error messages for Quickfix mode, etc.
  10269.  
  10270.  
  10271. CONTENTS            *reference_contents* *ref* *reference*
  10272.  
  10273. [Note: The commands for multiple windows and buffers are explained in
  10274. a different file, see |vim_win.txt|]
  10275.  
  10276.  1. Introduction            |intro|
  10277.  2. Notation                |notation|
  10278.  3. Starting Vim            |starting|
  10279.     3.1 Vim arguments            |vim_arguments|
  10280.     3.2 Workbench (Amiga only)        |workbench|
  10281.     3.3 Vim window (Amiga only)        |amiga_window|
  10282.     3.4 Initialization            |initialization|
  10283.     3.5 Suspending                |suspend|
  10284.     3.6 The viminfo file            |viminfo_file|
  10285.  4. Modes                |vim_modes|
  10286.     4.1 Introduction
  10287.     4.2 Switching from mode to mode        |mode_switching|
  10288.     4.3 Insert and Replace mode        |mode_ins_repl|
  10289.         4.3.1 special keys            |ins_special_keys|
  10290.         4.3.2 special special keys        |ins_special_special|
  10291.         4.3.3 'textwidth' option        |ins_textwidth|
  10292.         4.3.4 'expandtab' option        |ins_expandtab|
  10293.         4.3.5 Replace mode            |replace_mode|
  10294.         4.3.6 Insert mode completion        |ins_completion|
  10295.     4.4 Command-line mode            |mode_cmdline|
  10296.         4.4.1 Command line editing        |cmdline_editing|
  10297.         4.4.2 Command line completion        |cmdline_completion|
  10298.         4.4.3 Ex command lines            |cmdline_lines|
  10299.         4.4.4 Ex command line ranges        |cmdline_ranges|
  10300.         4.4.5 Ex special characters        |cmdline_special|
  10301.     4.5 The window contents            |window_contents|
  10302.     4.6 Abbreviations            |abbreviations|
  10303.     4.7 Digraphs                |digraphs|
  10304.     4.8 Using the mouse            |mouse_using|
  10305.     4.9 Online help                |online_help|
  10306.  5. Editing files            |edit_files|
  10307.     5.1 Introduction            |edit_intro|
  10308.     5.2 Editing a file            |edit_a_file|
  10309.     5.3 The argument list            |argument_list|
  10310.     5.4 Writing and quitting        |write_quit|
  10311.     5.5 Using the QuickFix mode        |quickfix|
  10312.     5.6 Editing binary files        |edit_binary|
  10313.     5.7 Automatic commands            |autocommand|
  10314.  6. Cursor motions            |cursor_motions|
  10315.     6.1 Left-right motions            |left_right_motions|
  10316.     6.2 Up-down motions            |up_down_motions|
  10317.     6.3 Word motions            |word_motions|
  10318.     6.4 Text object motions            |object_motions|
  10319.     6.5 Text object selection        |object_select|
  10320.     6.6 Pattern searches            |pattern_searches|
  10321.     6.7 Various motions            |various_motions|
  10322.  7. Scrolling                |scrolling|
  10323.  8. Tags and special searches        |tags_and_searches|
  10324.     8.1 Tags                |tag_commands|
  10325.     8.2 Identifier searches            |include_search|
  10326.  9. Inserting text            |inserting|
  10327. 10. Deleting text            |deleting|
  10328. 11. Changing text            |changing|
  10329.     11.1 Delete and insert            |delete_insert|
  10330.     11.2 Simple changes            |simple_change|
  10331.     11.3 Complex changes            |complex_change|
  10332.     11.4 Formatting text            |formatting|
  10333.     11.5 Formatting C programs        |C_indenting|
  10334. 12. Copying and moving text        |copy_move|
  10335. 13. Visual mode                |Visual_mode|
  10336. 14. Various commands            |various|
  10337. 15. Repeating commands            |repeating|
  10338.     15.1 Single repeats            |single_repeat|
  10339.     15.2 Multiple repeats            |multi_repeat|
  10340.     15.3 Complex repeats            |complex_repeat|
  10341. 16. Undo and redo            |undo_redo|
  10342. 17. Key mapping                |key_mapping|
  10343. 18. Recovery after a crash        |crash_recovery|
  10344.     18.1 The swap file            |swap_file|
  10345.     18.2 Recovery                |recovery|
  10346. 19. Options                |options|
  10347.     19.1 Setting options            |set_option|
  10348.     19.2 Automatically setting options    |auto_setting|
  10349.     19.3 Saving settings            |save_settings|
  10350.     19.4 Options summary            |option_summary|
  10351. 20. Terminal information        |terminal_info|
  10352.     20.1 Startup                |startup|
  10353.     20.2 Terminal options            |terminal_options|
  10354.     20.3 Window size            |window_size|
  10355.     20.4 Slow and fast terminals        |slow_fast_terminal|
  10356.     20.5 Settings depending on terminal    |term_dependent_settings|
  10357. 21. Differences from Vi and Ex        |vi_differences|
  10358.     21.1 Missing commands            |missing_commands|
  10359.     21.2 Missing options            |missing_options|
  10360.     21.3 Limits                |limits|
  10361.  
  10362.  vim:tw=78:ts=8:sw=8:
  10363.