home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / vim-2.0.lha / Vim-2.0 / doc / reference.doc < prev    next >
Encoding:
Text File  |  1993-12-15  |  176.2 KB  |  4,305 lines

  1.  
  2.  
  3.  
  4.             Vim reference manual
  5.  
  6.              By Bram Moolenaar
  7.  
  8.                version 2.0
  9.  
  10.  
  11.  1. Introduction
  12.  2. Notation
  13.  3. Starting Vim
  14.  4. Modes
  15.  5. Editing files
  16.  6. Cursor motions
  17.  7. Scrolling
  18.  8. Tags
  19.  9. Inserting text
  20. 10. Deleting text
  21. 11. Changing text
  22. 12. Copying and moving text
  23. 13. Visual mode
  24. 14. Various commands
  25. 15. Repeating commands
  26. 16. Undo and redo
  27. 17. Key mapping
  28. 18. Recovery after a crash
  29. 19. Options
  30. 20. Terminal information
  31. 21. Differences from Vi and Ex
  32. 22. Credits
  33.  
  34.  
  35.     1. Introduction
  36.  
  37. Vim stands for Vi IMproved. It used to be Vi IMitation, but that does not
  38. really cover it anymore. Vim is a text editor which includes almost all the
  39. commands from the Unix program "Vi". It is very useful for editing programs
  40. and other ASCII text. All commands are given with the keyboard. There is no
  41. mouse support and there are no menus. This gives the advantage that you can
  42. keep your fingers on the keyboard and your eyes on the screen.
  43.  
  44. Throughout this manual the differences between Vi and Vim are mentioned in 
  45. curly braces. Read the file "difference.doc" for a summary of the 
  46. differences.
  47.  
  48. This manual refers to Vim on the Commodore Amiga computer. On other 
  49. computers and on terminals there may be small differences. For MSDOS this 
  50. is documented in msdos.doc. For UNIX this is in unix.doc.
  51.  
  52. This manual is a reference for all the Vim commands and options. A basic
  53. knowledge of "Vi" is assumed. A summary of this manual can be found in the 
  54. file vim.hlp. It can be accessed from within Vim with the <HELP> key (in 
  55. MSDOS <F1>) and with the command ":help". The 'helpfile' option can be 
  56. set to the name of the help file, so you can put it in any place you like.
  57.  
  58.  
  59.     2. Notation
  60.  
  61. []        Characters in square brackets are optional.
  62.  
  63. [count]        An optional number that may precede the command to multiply
  64.         or iterate the command. If no number is given a count of one
  65.         is used, unless otherwise noted. Note that in this manual
  66.         the [count] is not mentioned in the description of the
  67.         command, but only in the explanation. This was done to make
  68.         the commands easier to lookup. If the "sc" option is on, the
  69.         (partially) entered count is shown at the bottom of the
  70.         window. You can use <DEL> to erase the last digit.
  71.  
  72. ["x]        An optional register designation where text can be stored.
  73.         The x is a single character between <a> and <z> or <A> and
  74.         <Z> or <">, and in some cases (with the put command) between
  75.         <0> and <9>, <%> or <.>. The uppercase and lower case letter
  76.         designate the same register, but the lower case letter is
  77.         used to overwrite the previous register contents, while the
  78.         uppercase letter is used to append to the previous register
  79.         contents. Without the ""x" or with """" the stored text is
  80.         put into the unnamed register. See also "Copying and moving
  81.         text".
  82.  
  83. {}        Curly braces denote parts of the command which must appear, 
  84.         but can take a number of different values. The differences 
  85.         between Vim and Vi are also given in curly braces (this will 
  86.         be clear from the context).
  87.  
  88. {motion}    A command that moves the cursor. They are listed in chapter 
  89.         6. This is used after an "operator" command to move over the 
  90.         text that is to be operated upon. If the motion includes a 
  91.         count and the operator also had a count, the two counts are 
  92.         multiplied. For example: "2d3w" deletes six words.
  93.  
  94. {visual}    A piece of text that is started with the "v", "V" or CTRL-V
  95.         command and ended by the cursor position. This is used
  96.         before an "operator" to highlight the text that is to be
  97.         operated upon. See the chapter on Visual mode.
  98.  
  99. <character>    A special character from the table below or a single ASCII
  100.         character.
  101.  
  102. <char1-char2>    A single character from the range <char1> to <char2>. For
  103.         example: <a-z> is a lower case letter. Multiple ranges may be
  104.         concatenated. For example: <a-zA-Z0-9> is any alphanumeric
  105.         character.
  106.  
  107. CTRL-<char>    <char> typed as a control character, that is, typing <char>
  108.         while holding the CTRL key down. The case of <char> does not
  109.         matter, thus CTRL-A and CTRL-a are equivalent.
  110.  
  111. 'option'    An option, or parameter, that can be set to a value is
  112.         enclosed in single quotes. See chapter 19.
  113.  
  114. "command"    In examples the commands you can type are enclosed in double
  115.         quotes.
  116.  
  117.  
  118. notation    meaning             equivalent decimal value
  119. -----------------------------------------------------------------------
  120. <NUL>        zero            CTRL_@  000 (internally 010)
  121. <BELL>      bell            CTRL-G    007
  122. <BS>        backspace        CTRL-H    008
  123. <TAB>       tab            CTRL-I    009
  124. <LF>        linefeed        CTRL-J    010
  125. <FF>        formfeed        CTRL-L    012
  126. <CR>        carriage return        CTRL-M    013
  127. <ESC>       escape            CTRL-[    027
  128. <SPACE>        space                032
  129. <DEL>       delete                127
  130. <C_UP>        cursor-up            128 (msdos: 176)
  131. <C_DOWN>    cursor-down            129 (msdos: 177)
  132. <C_LEFT>    cursor-left            130 (msdos: 178)
  133. <C_RIGHT>    cursor-right            131 (msdos: 179)
  134. <SC_UP>        shift-cursor-up            132 (msdos: 180)
  135. <SC_DOWN>    shift-cursor-down        133 (msdos: 181)
  136. <SC_LEFT>    shift-cursor-left        134 (msdos: 182)
  137. <SC_RIGHT>    shift-cursor-right        135 (msdos: 183)
  138. <F1> - <F10>    function keys 1 to 10        136 - 145 (msdos: 184 - 193)
  139. <SF1> - <SF10>    shift-function keys 1 to 10    146 - 155 (msdos: 194 - 203)
  140. HELP>        help key            156 (msdos: 204)
  141. <UNDO>        undo key            157 (msdos: 205)
  142. -----------------------------------------------------------------------
  143. Note: The shifted cursor keys, the help key and the undo key are only
  144. available on a few terminals. On some terminals the function keys 11 to 20
  145. are used instead of the shifted function keys. On the Amiga shifted function
  146. key 10 produces a code (CSI) that is also used by key sequences. It will be
  147. recognized only after typing another key.
  148.  
  149.  
  150.     3. Starting Vim
  151.  
  152. 3.1 Command line
  153.  
  154. Most often Vim is started to edit a single file with the command
  155.  
  156.     vim file
  157.  
  158. More generally Vim is started with:
  159.  
  160.     vim [options] [filelist]
  161.  
  162. If the filelist is missing, the editor will start with an empty buffer.
  163. Otherwise exactly one out of the following six may be used to choose one or
  164. more files to be edited.
  165.  
  166. file ..        A list of file names. The first one will be the current file 
  167.         and read into the buffer. The cursor will be positioned on 
  168.         the first line of the buffer.
  169.  
  170. +[num] file ..    Same as the above, but the cursor will be positioned on line
  171.         "num". If "num" is missing, the cursor will be positioned on
  172.         the last line.
  173.  
  174. +/{pat} file ..    Same as the above, but the cursor will be positioned on the
  175.         first line containing "pat" in the current file (see the 
  176.         section "pattern searches" for the available search 
  177.         patterns).
  178.  
  179. +{command} file ..
  180. -c {command} file ..
  181.         Same as the above, but "command" will be executed after the 
  182.         file has been read. "command" is interpreted as an Ex 
  183.         command. If the "command" contains spaces it must be 
  184.         enclosed in double quotes (this depends on the shell that is 
  185.         used). Example: vim "+set si" main.c
  186.  
  187. -t {tag}    A tag. "tag" is looked up in the tags file, the associated 
  188.         file becomes the current file and the associated command is 
  189.         executed. Mostly this is used for C programs. In that case 
  190.         "tag" should be a function name. The effect is that the file 
  191.         containing that function becomes the current file and the 
  192.         cursor is positioned on the start of the function (see the 
  193.         section "tag searches").
  194.  
  195. -e [errorfile]    QuickFix mode. The file with the name [errorfile] is read
  196.         and the first error is displayed. If [errorfile] is not
  197.         given, the 'errorfile' option is used for the file name
  198.         (default "AztecC.Err" for the Amiga, "errors" for other
  199.         systems). See section 5.5: "using the QuickFix mode".
  200.  
  201. The options, if present, must precede the filelist. The options may be given 
  202. in any order.
  203.  
  204. -r        Recovery mode. The autoscript file is read to recover a 
  205.         crashed editing session. It has almost the same effect as 
  206.         "-s file.vim". See the chapter "Recovery after a crash".
  207.  
  208. -v        View mode. The 'readonly' option will be set and no 
  209.         autoscript file will be written (see -n below). You can 
  210.         still edit the buffer, but will be prevented from 
  211.         accidentally overwriting a file. If you forgot that you are 
  212.         in View mode and did make some changes, you can overwrite 
  213.         a file by adding an exclamation mark to the Ex command, as in 
  214.         ":w!". The 'readonly' option can be reset with ":set noro" 
  215.         (see the options chapter). Calling the executable "view" 
  216.         has the same effect as the -v option. If your system does 
  217.         not support links and you do not want to have the executable 
  218.         twice you could make an alias: "alias view vim -v".
  219.  
  220. -b        Binary mode. The 'textauto', 'textmode' and 'expandtab'
  221.         options will be reset. The 'textwidth' option is set to 0.
  222.         'modelines' is set to 0. The 'binary' option is set. This is
  223.         done after reading the .vimrc/.exrc files but before reading
  224.         a file. See also 5.6: "Editing binary files".
  225.  
  226. -n        No autoscript file will be written. Recovery after a crash 
  227.         will be impossible. Handy if you want to edit a file on a 
  228.         very slow medium (e.g. floppy). Can also be done with ":set 
  229.         uc=0". You can switch it on again by setting the 'uc' option 
  230.         to some value, e.g. ":set uc=100" (only do this if the 
  231.         buffer was not changed yet).
  232.  
  233. -x        Do not restart Vim to open a new window. This option should 
  234.         be used when Vim is started by a program that will wait for 
  235.         the edit session to finish (e.g. mail or readnews). See 
  236.         section 3.3.
  237.  
  238. -T {terminal}    Set the terminal type to "terminal". This influences the 
  239.         codes that Vim will send to your terminal. This is normally 
  240.         not needed, because Vim will be able to find out what type 
  241.         of terminal you are using (See chapter 20).
  242.  
  243. -d {device}    The "device" is opened to be used for editing. Normally you 
  244.         would use this to set the window position and size:
  245.         "-d con:x/y/width/height", e.g. "-d con:30/10/600/150". But 
  246.         you can also use it to start editing on another device, e.g. 
  247.         AUX:. This only works on the Amiga.
  248.  
  249. -s {scriptin}    The script file "scriptin" is read. The characters in the 
  250.         file are interpreted as if you had typed them. The same can 
  251.         be done with the command ":source! {scriptin}". If the end 
  252.         of the file is reached before the editor exits, further 
  253.         characters are read from the keyboard. See also the section 
  254.         "complex repeats".
  255.  
  256. -w {scriptout}    All the characters that you type are recorded in the file
  257.         "scriptout", until you exit Vim. This is useful if you want 
  258.         to create a script file to be used with "vim -s" or 
  259.         ":source!". See also the section "complex repeats".
  260.  
  261. Example for using a script file to change a name in several files:
  262.     Create a file "subs.vi" containing substitute commands and a :wq
  263.     command:
  264.  
  265.         :%s/Jones/Smith/g
  266.         :%s/Allen/Peter/g
  267.         :wq
  268.  
  269.     Execute Vim on all files you want to change:
  270.  
  271.         foreach i ( *.let ) vim -s subs.vi $i
  272.  
  273. If the executable is called "view" Vim will start in Readonly mode. This is 
  274. useful if you can make a hard or symbolic link from "view" to "vim".
  275. Starting in Readonly mode can also be done with "vim -v". 
  276.  
  277.  
  278. 3.2 Workbench (Amiga only)
  279.  
  280. Vim can be started from the workbench by clicking on its icon twice. It will
  281. then start with an empty buffer.
  282.  
  283. Vim can be started to edit one or more files by using a "Project" icon. The
  284. "Default Tool" of the icon must be the full pathname of the Vim executable. 
  285. The name of the ".info" file must be the same as the name of the text file. 
  286. By clicking on this icon twice, Vim will be started with the filename as 
  287. current filename, which will be read into the buffer (if it exists). You can 
  288. edit multiple files by pressing the shift key while clicking on icons, and 
  289. clicking twice on the last one. The "Default Tool" for all these icons must 
  290. be the same.
  291.  
  292. It is not possible to give arguments to Vim, other than filenames, from the
  293. workbench.
  294.  
  295.  
  296. 3.3 Vim window (Amiga only)
  297.  
  298. Vim will run in the CLI window where it was started. If Vim was started with 
  299. the "run" or "runback" command, or if Vim was started from the workbench, it 
  300. will open a window of its own.
  301.  
  302. Technical detail:
  303.     To open the new window a little trick is used. As soon as Vim 
  304.     recognizes that it does not run in a normal CLI window, it will 
  305.     create a script file in t:. This script file contains the same 
  306.     command as how Vim was started, and an "endcli" command. This script 
  307.     file is then executed with a "newcli" command (the "c:run" and 
  308.     "c:newcli" commands are required for this to work). The script file 
  309.     will hang around until reboot, or until you delete it. This method 
  310.     is required to get the ":sh" and ":!" commands to work correctly. 
  311.     But when Vim was started with the -e option (Quickfix mode) or with 
  312.     the -x option, this method is not used. The reason for this is that 
  313.     when a compiler starts Vim with the -e option it will wait for a 
  314.     return code. With the script trick the compiler cannot get the 
  315.     return code. The -x option can be used when Vim is started by a mail 
  316.     program which also waits for the edit session to finish. As a 
  317.     consequence the ":sh" and ":!" commands are not available when the 
  318.     -e or -x option is used.
  319.  
  320. Vim will automatically recognize the window size and react to window 
  321. resizing. Under Amiga DOS 1.3 it is advised to use the fastfonts program 
  322. "FF" to speed up display redrawing.
  323.  
  324.  
  325. 3.4 Initialization
  326.  
  327. When Vim starts running it does initializations in the following order. If
  328. an environment variable is used, it is executed as a single Ex command line.
  329. Multiple commands must be separated with <|>. If a file is used, each line
  330. is executed as an Ex command line.
  331.  
  332. 1.  Four places are searched for initializations. The first that exists is 
  333.     used, the others are ignored.
  334.      1. The environment variable VIMINIT
  335.      2. The file "s:.vimrc" (for Unix: "$HOME/.vimrc")
  336.      3. The environment variable EXINIT
  337.      4. The file "s:.exrc" (for Unix: "$HOME/.exrc")
  338.  
  339. 2.  If the 'exrc' option is set (default is 'noexrc'), the current directory
  340.     is searched for two files. The first that exists is used, the other is
  341.     ignored.
  342.      1. The file ".vimrc"
  343.      2. The file ".exrc"
  344.  
  345. 3.  The environment variable SHELL, if it exists, is used to set the 
  346.     'shell' option. With MSDOS the COMPSPEC variable is used if SHELL does
  347.     not exist.
  348.  
  349. 4.  The environment variable TERM, if it exists, is used to set the 'term'
  350.     option.
  351.  
  352. The first can be used to set your default settings and mappings for all edit 
  353. sessions. The second one for sessions in a certain directory (note that the
  354. 'exrc' option is default off). See the section "Saving settings" for how to
  355. create a file with commands to recreate the current settings.
  356.  
  357. If the VIMINIT environment variable or ".vimrc" exist the EXINIT and ".exrc" 
  358. are skipped. This can be used to initialize Vim without interfering with 
  359. another version of Vi.
  360.  
  361. On the Amiga two types of environment variables exist. The ones set with the
  362. DOS 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3 
  363. manual. The environment variables set with the old Manx Set command (before 
  364. version 5.0) are not recognized.
  365.  
  366. On MS-DOS systems Vim assumes that all the "_vimrc" and "_exrc" files have
  367. <CR><LF> pairs as line separators. This will give problems if you have a
  368. file with only <LF>s and have a line like ":map xx yy^M". The trailing ^M
  369. will be ignored.
  370.  
  371. While reading the ".vimrc" or the ".exrc" file in the current directory some
  372. commands can be disabled for security reasons by setting the 'secure'
  373. option. Otherwise it would be possible to create a .exrc that contains nasty
  374. commands, which another user may automatically execute when he starts Vim it
  375. that directory. The disabled commands are the ones that start a shell and
  376. the ones that write to a file. The ":map" commands are echoed, so you can
  377. see which keys are being mapped.
  378.  
  379. You can reset the 'secure' option in the EXINIT or VIMINIT environment
  380. variable or in the global ".exrc" or ".vimrc" file. This is not possible in
  381. ".vimrc" or ".exrc" in the current directory, for obvious reasons.
  382.  
  383. On unix systems this only happens if you are not the owner of the ".vimrc" 
  384. or ".exrc" file. Warning: If you unpack an archive that contains a .exrc 
  385. file, it will be owned by you. You won't have the security protection. Check 
  386. the .exrc file before you start Vim in that directory, or reset the 'exrc' 
  387. option. 
  388.  
  389.  
  390. 3.5 Suspending
  391.  
  392. CTRL-Z                Suspend the editor. Same as ":stop".
  393.  
  394. :sus[pend][!]        or
  395. :st[op][!]            Suspend the editor. If the <!> is not given,
  396.                 the buffer was changed, autowrite is set and 
  397.                 a filename is known, the buffer will be 
  398.                 written.
  399.  
  400. On many UNIX systems it is possible to suspend Vim with CTRL-Z. This is only 
  401. possible in Command mode (see next chapter). Vim will continue if you make it 
  402. the foreground job again. On other systems CTRL-Z will start a new shell. 
  403. This is the same as the ":sh" command. Vim will continue if you exit from the 
  404. shell.
  405.  
  406.  
  407.     4. Modes
  408.  
  409. 4.1 Introduction
  410.  
  411. Vim has four basic modes:
  412.  
  413. Command mode        In Command mode you can enter all the editor
  414.             commands. If you start the editor you are in this 
  415.             mode (unless you have set the 'insertmode' option, 
  416.             see below).
  417.  
  418. Insert mode        In Insert mode the text you type is inserted into the
  419.             buffer. If the 'showmode' option is set (which is
  420.             default), the string "-- INSERT --" is shown at the
  421.             bottom of the window.
  422.  
  423. Replace mode        Replace mode is a special case of Insert mode. You
  424.             can do the same things as in Insert mode, but for 
  425.             each character you enter (except some special 
  426.             characters) one character of the existing text is 
  427.             deleted. If the 'showmode' option is set (which is 
  428.             default), the string "-- REPLACE --" is shown at the 
  429.             bottom of the window.
  430.  
  431. Command_line mode    In Command_line mode you can enter one line of text
  432.             at the bottom of the window. This is for the Ex
  433.             commands <:>, the pattern search commands <?></> and
  434.             the filter command <!>.
  435.  
  436. More explanation on the insert, replace and Command_line mode is further on 
  437. in this chapter.
  438.  
  439.  
  440. 4.2 Switching from mode to mode
  441.  
  442. If for any reason you do not know in which mode you are, you can always get
  443. back to Command mode by typing <ESC> twice. You will know you are back in
  444. Command mode when you see the screen flash or hear the bell after you type
  445. <ESC>.
  446.  
  447. - go from Command mode to Insert mode by giving one of the commands
  448.   "iIaAoOcCsS".
  449. - go from Command mode to Replace mode with the "R" command (not the "r"
  450.   command!).
  451. - go from Command mode to Command_line mode with the one of the commands
  452.   ":/?!".
  453.  
  454. - go from insert or Replace mode to Command mode with <ESC> (twice in some
  455.   rare cases).
  456. - go from Command_line mode to Command mode by:
  457.    - hitting <CR> or <LF>, which causes the entered command to be executed
  458.    - deleting the complete line (e.g. with CTRL-U) and giving a final <BS>
  459.    - hitting CTRL-C or <ESC>, which quits the command line without executing
  460.      the command.
  461.   In the last case <ESC> may be the character defined with the 'wildchar'
  462.   option, and start filename completion. You can ignore that and type <ESC>
  463.   again. {vi: when hitting <ESC> the command line is executed. This is
  464.   unexpected for most people, therefore it was changed in Vim. But when the
  465.   <ESC> is part of a mapping the command line is executed. If you want the
  466.   vi behaviour also when typing <ESC> use ":cmap ^V<ESC> ^V^M"}
  467.  
  468. If the 'insertmode' option is set, editing a file will start in Insert mode.
  469.  
  470.  
  471. 4.3 Insert and Replace mode
  472.  
  473. In insert and Replace mode the following characters have a special meaning,
  474. other characters are inserted directly. To insert one of these special
  475. characters into the buffer, precede it with CTRL-V. To insert a <NUL> 
  476. character use "CTRL-V CTRL-@" or "CTRL-V 000". On some systems you have to
  477. use "CTRL-V 003" to insert a CTRL-C.
  478.  
  479. char        action
  480. -----------------------------------------------------------------------
  481. CTRL-@        Insert previously inserted text and stop insert. {Vi: only
  482.         when typed as first char, only up to 128 chars}
  483. CTRL-A        Insert previously inserted text. {not in Vi}
  484. CTRL-C        Quit insert mode, back to command mode.
  485. CTRL-D        Delete one shiftwidth of indent at the start of the current 
  486.         line. See also 'shiftround' option. When preceded with <^>
  487.         or <0> delete all indent in the current line. With <^> the
  488.         indent is restored in the next line. This is useful when
  489.         inserting a label. {Vi: CTRL-D works only when used after
  490.         autoindent}
  491. CTRL-E        Insert the character which is below the cursor. {not in Vi}
  492. CTRL-H <BS>    Delete the character before the cursor (see below). {Vi: 
  493.         does not delete autoindents}
  494. CTRL-I <TAB>    Insert a tab. If the 'expandtab' option is on, the
  495.         equivalent number of spaces is inserted (use CTRL-V <TAB> to
  496.         avoid the expansion).
  497. CTRL-J <LF>    Begin new line.
  498. CTRL-K {char1} {char2}
  499.         Enter digraph (see 4.7). {not in Vi}
  500. CTRL-M <CR>    Begin new line.
  501. CTRL-O        Execute one Command mode command. See below. {not in Vi}
  502. CTRL-P        Toggle the 'revins' option. {not in Vi}
  503. CTRL-R <0-9a-z"%>
  504.         Insert the contents of a numbered or named register. The
  505.         text is inserted as if you typed it, but mappings and
  506.         abbreviations are not used. If you have options like
  507.         'textwidht' or 'autoindent' set, this will influence what
  508.         will be inserted. Use <"> for the unnamed register,
  509.         containing the text of the last delete or yank. Use <%> for
  510.         the current file name.  See the chapter on copying and
  511.         moving text about registers. {not in Vi}
  512. CTRL-T        Insert one shiftwidth of indent at the start of the current 
  513.         line. See also 'shiftround' option. {Vi: only when in 
  514.         autoindent}
  515. CTRL-U        Delete all entered characters in the current line (see 
  516.         below).
  517. CTRL-V        Insert next non-digit literally. Up to three digits form the 
  518.         decimal value of a single byte. The non-digit and the three
  519.         digits are not considered for mapping. {Vi: no decimal byte
  520.         entry}
  521. CTRL-W        Delete the word before the cursor (see below). See the 
  522.         section "word motions" for the definition of a word.
  523. CTRL-Y        Insert the character which is above the cursor. {not in Vi}
  524. CTRL-[ or <ESC>    End insert or Replace mode, back to Command mode.
  525. <DEL>        Same as CTRL-H <BS>
  526. -----------------------------------------------------------------------
  527.  
  528. The effect of the <BS>, <DEL>, CTRL-W and CTRL-U depends on the 'backspace' 
  529. option (unless 'revins' is set):
  530.  
  531. backspace    action
  532.  option
  533.    0       delete stops in column 1 and start position of insert
  534.    1       delete stops at start position of insert
  535.    2       delete always, CTRL-W and CTRL-U stop once at start position of 
  536.           insert
  537.  
  538. If the 'backspace' option is non-zero and the cursor is in column 1 when one 
  539. of the three keys is used, the current line is joined with the previous 
  540. line. This effectively deletes the newline in front of the cursor. {Vi: does 
  541. not cross lines, does not delete past start position of insert}
  542.  
  543. With CTRL-V followed by one, two or three digits you can enter the decimal 
  544. value of a byte, except 10. Normally CTRL-V is followed by three digits. The 
  545. formed byte is inserted as soon as you type the third digit. If you type 
  546. only one or two digits and then a non-digit, the decimal value of those one 
  547. or two digits form the byte. After that the non-digit is dealt with in the 
  548. normal way. If you enter a value of 10, it will end up in the file as a 0.
  549. The 10 is a <LF>, which is used internally to represent the <NUL> character.
  550. When writing the buffer to a file the <LF> character is translated into
  551. <NUL>. The <LF> character is written at the end of each line. Thus if you
  552. want to insert a <LF> character in a file you will have to make a line
  553. break.
  554.  
  555.  
  556. special keys
  557.  
  558. The following keys are special. They stop the current insert, do something 
  559. and then restart insertion. This means you can do something without getting 
  560. out of Insert mode. This is very handy if you prefer to use the Insert mode 
  561. all the time, just like editors that don't have a separate Command mode. You 
  562. may also want to set the 'backspace' option to 2 and set the 'insertmode' 
  563. option. You can use CTRL-O if you want to map a function key to a command.
  564.  
  565. The changes (inserted or deleted characters) before and after these keys can 
  566. be undone separately. Only the last change can be redone and always behaves 
  567. like an "i" command.
  568.  
  569. char        action
  570. -----------------------------------------------------------------------
  571. <C_UP>        cursor one line up
  572. <C_DOWN>    cursor one line down
  573. <C_LEFT>    cursor one character left
  574. <C_RIGHT>    cursor one character right
  575. <SC_UP>        move window one page up
  576. <SC_DOWN>    move window one page down
  577. <SC_LEFT>    cursor one word back (like "b" command)
  578. <SC_RIGHT>    cursor one word forward (like "w" command)
  579. CTRL-O        execute one command and return to Insert mode
  580. -----------------------------------------------------------------------
  581.  
  582. The CTRL-O command has one side effect: If the cursor was beyond the end of 
  583. the line it will be put on the last character in the line.
  584. The shifted cursor keys are not available on all terminals.
  585.  
  586.  
  587. 'textwidth' option
  588.  
  589. The 'textwidth' option can be used to automatically break a line before it 
  590. gets too long. Set the 'textwidth' option to the desired maximum line 
  591. length. If you then type more characters (not spaces or tabs), the 
  592. last word will be put on a new line (unless it is the only word on the 
  593. line). If you set 'textwidth' to 0, this feature is disabled. Vi has the
  594. 'wrapmargin' option, but it does not do what you want. For compatibility, if
  595. you set the 'wrapmargin' option, 'textwidth' will be set to (columns -
  596. 'wrapmargin'), where columns is the width of the display.
  597.  
  598. If you want to format a block of text you can use the "Q" operator. Type "Q" 
  599. and a movement command to move the cursor to the end of the block. In many 
  600. cases the command "Q}" will do what you want (format until the end of 
  601. paragraph). Or you can use visual mode: hit "v", move to the end of the
  602. block and hit "Q".
  603.  
  604.  
  605. 'expandtab' option
  606.  
  607. If the 'expandtab' option is set, spaces will be used to fill the amount of
  608. whitespace of the tab. If you want to enter a real <TAB> type CTRL-V first.
  609. The 'expandtab' option is default off. Note that in Replace mode a single
  610. character is replaced by several spaces. The result of this is that the
  611. number of characters in the line increases. Backspacing will delete one
  612. space at a time. The original text will be put back in a place where you
  613. would not expect it.
  614.  
  615.  
  616. typing backwards
  617.  
  618. If the 'revins' (reverse insert) option is set, inserting happens backwards.
  619. This can be used to type Hebrew. When inserting characters the cursor is not
  620. moved and the text moves rightwards. A <BS> deletes the character under the
  621. cursor. CTRL-W and CTRL-U also work in the opposite direction. <BS>, CTRL-W
  622. and CTRL-U do not stop at the start of insert or end of line, no matter how
  623. the 'backspace' option is set.
  624.  
  625. In Replace mode the cursor is moved leftwards. <BS> will restore the
  626. character right of the cursor.
  627.  
  628. In insert or Replace mode the 'revins' option can be toggled with CTRL-P.
  629.  
  630. If the 'showmode' option is set, "-- REVERSE INSERT --" or
  631. "-- REVERSE REPLACE --" will be shown in the status line.
  632.  
  633.  
  634. Replace mode
  635.  
  636. In Replace mode one character in the line is deleted for every character you 
  637. type. If there is no character to delete (at the end of the line), the 
  638. typed character is appended (as in Insert mode). Thus the number of 
  639. characters in a line stays the same until you get to the end of the line.
  640.  
  641. Be careful with <TAB> characters. If you type a normal printing character in 
  642. its place, the number of characters is still the same, but the number of 
  643. columns will become smaller.
  644.  
  645. If you delete characters in Replace mode (with <BS>, <DEL>, CTRL-W or
  646. CTRL-U), you really delete your changes. The characters that were replaced
  647. are restored. If you had typed past the existing text, the characters you
  648. added are deleted.
  649.     All this only works in the current line. If you have started a new line
  650. (replaced a character with a <CR>) Vim no longer remembers what happened in
  651. the previous line. If you backspace over the newline (only possible if the
  652. 'backspace' option is non-zero), the two lines will be joined again, but
  653. typing further backspaces will not restore the original text. Only the
  654. cursor is moved.
  655.     If the 'expandtab' option is set, a <TAB> will replace one character
  656. with several spaces. When backspacing over these spaces, the original text
  657. will appear in a position where you would not expect it.
  658.  
  659.  
  660. 4.4 Command_line mode
  661.  
  662. Command_line mode is used to enter Ex commands <:>, search patterns </><?>
  663. and filter commands <!>.
  664.  
  665.  
  666. 4.4.1 Command line editing
  667.  
  668. Normal characters are inserted in front of the cursor position. You can move
  669. around in the command line with the left and right cursor keys. {Vi: can 
  670. only alter the last character in the line}
  671.  
  672. The command lines that you enter are remembered in a history table. You can
  673. recall them with the up and down cursor keys. Use the 'history' option to 
  674. set the number of lines that are remembered (default 20).
  675.  
  676. CTRL-V        Insert next non-digit literally. Up to three digits form the 
  677.         decimal value of a single byte. The non-digit and the three
  678.         digits are not considered for mapping. This works the same
  679.         way as in Insert mode (see above).
  680. <C_LEFT>    cursor left
  681. <C_RIGHT>    cursor right
  682. <SC_LEFT>    cursor one word left
  683. <SC_RIGHT>    cursor one word right
  684. CTRL-B        cursor to begin of command line
  685. CTRL-E        cursor to end of command line
  686.  
  687. <BS>        delete the character in front of the cursor
  688. <DEL>        delete the character under the cursor (at end of line:
  689.         character in front of the cursor)
  690. CTRL-W        delete the word in front of the cursor
  691. CTRL-U        remove all characters
  692.  
  693.         Note: if the command line becomes empty with one of the
  694.         delete commands, command line mode is quit.
  695.  
  696. {char1} <BS> {char2}    or
  697. CTRL-K {char1} {char2}
  698.         enter digraph (see 4.7). {not in Vi}
  699.  
  700. <CR> or <LF>    start entered command
  701. <ESC>        when typed: quit command line without executing
  702.         in macros: start entered command
  703. CTRL-C        quit command line without executing
  704.  
  705. <C_UP>        recall older command line from history
  706. <C_DOWN>    recall more recent command line from history
  707.  
  708. <SC_UP>        recall older command line from history, which begin matches 
  709.         the current command line.
  710. <SC_DOWN>    recall more recent command line from history, which begin 
  711.         matches the current command line.
  712.  
  713. CTRL-D        list filenames that match the pattern in front of the cursor
  714. 'wildchar' option
  715.         do filename completion on the pattern in front of the cursor
  716.         (Note: does not work inside a macro)
  717. CTRL-K {char1} {char2}
  718.         enter digraph (see 4.7). {not in Vi}
  719. CTRL-N        after 'wildchar' with multiple matches: go to next match;
  720.         otherwise: recall more recent command line from history
  721. CTRL-P        after 'wildchar' with multiple matches: go to previous match;
  722.         otherwise: recall older command line from history
  723. CTRL-A        do filename completion on the pattern in front of the cursor
  724.         and insert all matches
  725. CTRL-L        do filename completion on the pattern in front of the cursor
  726.         and insert the longest common part
  727.  
  728. The 'wildchar' option defaults to <TAB> (CTRL-E when compiled with 
  729. COMPATIBLE; in a previous version <ESC> was used). In the pattern for 
  730. CTRL-D and 'wildchar' standard Amiga wildcards are accepted, plus the <*> 
  731. and <?> characters.
  732.  
  733. For filename completion you can use the 'suffixes' option to set a priority 
  734. between files with almost the same name. If there are multiple matches, 
  735. those files with an extension that is in the 'suffixes' option are ignored.
  736. The default is ".bak.o.h.info.vim", which means that files with the
  737. extensions ".bak", ".o", ".h", ".info" and ".vim" are sometimes ignored. It
  738. is impossible to ignore suffixes with two dots. Examples:
  739.  
  740. pattern:    files:                match:
  741. test*        test.c test.h test.o        test.c
  742. test*        test.h test.o            test.h and test.o
  743. test*        test.i test.h test.c        test.i and test.c
  744.  
  745. If there is more than one matching file (after ignoring the ones matching
  746. the 'suffixes' option) the message "Too many file names" is given. The first
  747. file name is inserted. You can get to the others by entering 'wildchar',
  748. CTRL-N or CTRL-P. All files are included then, also the ones with extensions
  749. matching the 'suffixes' option.
  750.  
  751. The <SC_UP> and <SC_DOWN> keys take the current command line as search 
  752. string. The beginning of the next/previous command lines are compared against 
  753. this string. The fist line that matches is the new command line. When typing 
  754. these two keys repeatedly, the same string is used again. For example this 
  755. can be used to find the previous substitute command: Type ":s" and then 
  756. <SC_UP>. The same could be done by typing <C_UP> a number of times until the 
  757. desired command line is shown. (Note: the shifted arrow keys do not work on
  758. all terminals) 
  759.  
  760.  
  761. 4.4.2 Ex command lines
  762.  
  763. The Ex commands have a few specialities:
  764.  
  765. <"> or <#> at the start of a line causes the whole line to be ignored. <"> 
  766. after a command causes the rest of the line to be ignored. This can be used 
  767. to add comments.
  768.  
  769. <|> can be used to separate commands, so you can give multiple commands in 
  770. one line. The commands ":global", "vglobal" and  ":!" see the <|> as their
  771. argument, and can therefore not be followed by another command. If you want
  772. <|> to be included in a command, precede it with <\>. Note that this is
  773. confusing (inherited from vi). If you give a command with ":!" you don't
  774. have to use a backslash, with ":r !" you have to. And with ":g" the <|> is
  775. included in the command, with ":s" it is not. Examples:
  776.     :!ls | wc        view the output of two commands
  777.     :r !ls \| wc        insert the same output in the text
  778.     :%g/foo/p|>        moves all matching lines one shiftwidth
  779.     :%s/foo/bar/|>        moves one line one shiftwidth
  780.  
  781. When the character <%> or <#> is used where a filename is expected, they are 
  782. expanded to the current and alternate filename (see the chapter "editing 
  783. files").
  784.  
  785. Embedded spaces in filenames are allowed if one filename is expected as
  786. argument. Trailing spaces will be ignored, unless escaped with a backslash
  787. or CTRL-V. Note that the ":next" command uses spaces to separate file names.
  788. Escape the spaces to include them in a file name. Example:
  789.     :next foo\ bar goes\ to school\ 
  790. starts editing the three files "foo bar", "goes to" and "school ".
  791.  
  792. When you want to use the special characters <"> or  <|> in a command, or want
  793. to use <%> or <#> in a filename, precede them with a backslash. The backslash
  794. is not required in a range and in the ":substitute" command.
  795.  
  796.  
  797. 4.4.3 Ex command line ranges
  798.  
  799. Some Ex commands accept a line range in front of them. This is noted as
  800. [range]. It consists of one or more line specifiers, separated with <,> or 
  801. <;>. When separated with <;> the cursor position will be set to that line 
  802. before interpreting the next line specifier. The default line specifier for 
  803. most commands is the cursor position, but the commands ":write" and 
  804. ":global" have the whole file (1,$) as default. If more line specifiers are 
  805. given than required for the command, the first one(s) will be ignored.
  806.  
  807. Line numbers may be specified with:
  808.     {number}    an absolute line number
  809.     .        the current line
  810.     $        the last line in the file
  811.     %        equal to 1,$ (the entire file)
  812.     't        position of mark t (lower case)
  813.     /{pattern}[/]    the next line where {pattern} matches
  814.     ?{pattern}[?]    the previous line where {pattern} matches
  815.  
  816. Each may be followed (several times) by <+> or <-> and an optional number. 
  817. This number is added or subtracted from the preceding line number. If the 
  818. number is omitted, 1 is used.
  819.  
  820. The "/" and "?" may be preceded with another address. The search starts from
  821. there. The "/" and "?" after {pattern} are required to separate the pattern
  822. from anything that follows.
  823.  
  824. The {number} must be between 0 and the number of lines in the file. A 0 is 
  825. interpreted as a 1, except with the commands tag, pop and read.
  826.  
  827. Examples:
  828.     .+3        three lines below the cursor
  829.     /that/+1    the line below the next line containing "that"
  830.     .,$        from current line until end of file
  831.     0/that        the first line containing "that"
  832.  
  833. Some commands allow for a count after the command. This count is used as the
  834. number of lines to be used, starting with the line given in the last line
  835. specifier (the default is the cursor line).
  836.  
  837. Examples:
  838.     :s/x/X/g 5    substitute <x> by <X> in the current line and four
  839.             following lines
  840.     :23d 4        delete lines 23, 24, 25 and 26
  841.  
  842.  
  843. 4.5 The window contents
  844.  
  845. In command and Insert/Replace mode the screen window will show the current
  846. contents of the buffer: What You See Is What You Get. {Vi: when changing 
  847. text a <$> is placed on the last changed character; The window is not always 
  848. updated on slow terminals} Lines longer than the window width will wrap,
  849. unless the 'wrap' option is off (see below). The bottom lines in the window
  850. may start with one of these two characters:
  851.  
  852. <@>     The next line is too long to fit in the window.
  853. <~>    Below the last line in the buffer.
  854.  
  855. If the bottom line is completely filled with <@>, the line that is at the 
  856. top of the window is too long to fit in the window. If the cursor is on this 
  857. line you can't see what you are doing, because this part of the line is not 
  858. shown. However, the part of the line before the <@>s can be edited normally. 
  859. {Vi: gives an "internal error" on lines that do not fit in the window}
  860.  
  861. If the 'wrap' option is off, long lines will not wrap. Only the part that
  862. fits on the screen is shown. If the cursor is moved to a part of the line
  863. that is not shown, the screen is scrolled horizontally. The advantage of
  864. this method is that columns are shown as they are and lines that cannot fit
  865. on the screen can be edited. The disadvantage is that you cannot see all the
  866. characters of a line at once. The 'sidescroll' option can be set to the
  867. minimal number of columns to scroll. {Vi: has no 'wrap' option}
  868.  
  869. All normal ASCII characters are displayed directly on the screen. The <TAB> 
  870. is replaced by the number of spaces that it represents. Other non-printing 
  871. characters are replaced by "^<char>", where <char> is the non-printing 
  872. character with 64 added. Thus character 7 (bell) will be shown as "^G". 
  873. Characters between 127 and 160 are replaced by "~<char>", where <char> is 
  874. the character with 64 subtracted. These characters occupy more than one 
  875. position on the screen. The cursor can only be positioned on the first one.
  876.  
  877. If you set the 'number' option, all lines will be preceded with their 
  878. number.
  879.  
  880. If you set the 'list' option, <TAB> characters will not be shown as several
  881. spaces, but as "^I". A <$> will be placed at the end of the line, so you can
  882. find trailing blanks.
  883.  
  884. In Command_line mode only the command line itself is shown correctly. The
  885. display of the buffer contents is updated as soon as you go back to Command
  886. mode.
  887.  
  888. Some commands hand over the window to external commands (e.g. ":shell" and
  889. "="). After these commands are finished the window may be clobbered with 
  890. output from the external command, so it needs to be redrawn. This is also 
  891. the case if something is displayed on the status line that is longer than 
  892. the width of the window. If you are expected to have a look at the screen 
  893. before it is redrawn, you get this message:
  894.  
  895.         Press RETURN or enter command to continue
  896.  
  897. After you type a key the screen will be redrawn and Vim continues. If you 
  898. type <CR>, <SP> or <LF> nothing else happens. If you type any other key, it 
  899. will be interpreted as (the start of) a new command. {Vi: only <:> commands 
  900. are interpreted}
  901.  
  902. The last line of the window is used for status and other messages. The 
  903. status messages will only be used if an option is on:
  904.  
  905. status message            option        default    unix default
  906. current mode             'showmode'    on        on
  907. command characters        'showcmd'    on        off
  908. cursor position            'ruler'        off        off
  909.  
  910. The current mode is "-- INSERT --" or "-- REPLACE --". The command 
  911. characters are those that you typed but were not used yet. {Vi: does not
  912. show the characters you typed or the cursor position}
  913.  
  914. If you have a slow terminal you can switch off the status messages to speed 
  915. up editing:
  916.     :set nosc noru nosm
  917.  
  918. If there is an error, an error message will be shown for at least one second 
  919. (in reverse video). {Vi: error messages may be overwritten with other 
  920. messages before you have a chance to read them}
  921.  
  922. Some commands show how many lines were affected. Above which threshold this
  923. happens can be controlled with the 'report' option (default 2).
  924.  
  925. On the Amiga Vim will run in a CLI window. The name Vim and the full name of
  926. the current filename will be shown in the title bar. When the window is
  927. resized, Vim will automatically redraw the window. You may make the window as
  928. small as you like, but if it gets too small not a single line will fit in it.
  929. Make it at least 40 characters wide to be able to read most messages on the
  930. last line.
  931.  
  932. On most Unix systems window resize works ok.  {Vi: not ok}
  933.  
  934.  
  935. 4.6 Abbreviations
  936.  
  937. Abbreviations are used in insert mode, Replace mode and Command_line mode.
  938. If you enter a word that is an abbreviation, it is replaced by the word it
  939. stands for. Only whole words are recognized. A word is made up of letters,
  940. digits and <_>. You have to type a character other than a letter, digit, or
  941. <_> in front of the word and after the word before the abbreviation is
  942. recognized. The word may also begin at the start of a line and at the
  943. position where the insertion started. You may also type a <CR> or <LF> after
  944. the word.
  945.  
  946. Example: ":ab foo four old otters". Note that spaces in the <rhs> are
  947. allowed and included in the replacement string. If you now insert the word
  948. "foo" with a space before and after it, it will be replaced by "four old
  949. otters". If you would type "foobar" or "barfoo" nothing happens.
  950.  
  951. To avoid the abbreviation in insert mode type part of the abbreviation, exit
  952. insert mode with <ESC>, re-enter insert mode with "a" and type the rest. In
  953. Command_line mode you can type CTRL-V twice somewhere in the abbreviation to
  954. avoid it to be replaced. A CTRL-V in front of a normal character is mostly
  955. ignored otherwise.
  956.  
  957. There are no default abbreviations.
  958.  
  959. Abbreviations are disabled if the 'paste' option is set.
  960.  
  961. :ab[breviate]        list all abbreviations. The character in the first
  962.             column indicates the mode where the abbreviation is
  963.             used: 'i' for insert mode, 'c' for Command_line
  964.             mode, '!' for both.
  965.  
  966. :ab[breviate] <lhs>    list the abbreviations that start with <lhs>
  967.  
  968. :ab[breviate] <lhs> <rhs>
  969.             add abbreviation for <lhs> to <rhs>. If <lhs> already
  970.             existed it is replaced with the new <rhs>. <rhs> may
  971.             contain spaces.
  972.  
  973. :una[bbreviate] <lhs>    remove abbreviation for <lhs> from the list
  974.  
  975. :norea[bbrev] [lhs] [rhs]
  976.             same as ":ab", but no remapping for this <rhs> {not
  977.             in Vi}
  978.  
  979. :ca[bbrev] [lhs] [rhs]    same as ":ab", but for Command_line mode only. {not
  980.             in Vi}
  981.  
  982. :cuna[bbrev] <lhs>    same as ":una", but for Command_line mode only. {not
  983.             in Vi}
  984.  
  985. :cnorea[bbrev] [lhs] [rhs]
  986.             same as ":ab", but for Command_line mode only and no
  987.             remapping for this <rhs> {not in Vi}
  988.  
  989. :ia[bbrev] [lhs] [rhs]    same as ":ab", but for insert mode only. {not in Vi}
  990.  
  991. :iuna[bbrev] <lhs>    same as ":una", but for insert mode only. {not in
  992.             Vi}
  993.  
  994. :inorea[bbrev] [lhs] [rhs]
  995.             same as ":ab", but for insert mode only and no
  996.             remapping for this <rhs> {not in Vi}
  997.  
  998.  
  999. 4.7 Digraphs
  1000.  
  1001. :dig[raphs]        show currently defined digraphs. {not in Vi}
  1002.  
  1003. :dig[raphs] {char1}{char2} {number} ...
  1004.             Add digraph {char1}{char2} to the list. {number} is 
  1005.             the decimal representation of the character.
  1006.  
  1007. Digraphs are used to enter characters that normally cannot be entered by 
  1008. an ordinary keyboard. These are mostly accented characters which have the 
  1009. eighth bit set. The digraphs are easier to remember than the decimal number
  1010. that can be entered with CTRL-V (see above).
  1011.  
  1012. Vim must have been compiled with the 'digraphs' option enabled. If not, the 
  1013. ":digraph" command will display an error message.
  1014.  
  1015. There are two methods to enter digraphs:
  1016.     CTRL-K {char1} {char2}        or
  1017.     {char1} <BS> {char2}
  1018. The first is always available. The second only when the 'digraph' option is 
  1019. set.
  1020.  
  1021. Once you have entered the digraph the character is treated like a normal 
  1022. character, taking up only one character in the file and on the screen. 
  1023. Example:
  1024.     <|> <BS> <|>    will enter the double <|> character (166)
  1025.     <a> <BS> <^>    will enter an <a> with a hat (226)
  1026.     CTRL-K <-> <->    will enter a minus sign (173)
  1027.  
  1028. The default digraphs are listed in the file digraph.doc. They are meant for 
  1029. the Amiga character set, which is some international standard. With another 
  1030. character set they may be illogical.
  1031.  
  1032. If you accidently typed an <a> that should be an <e>, you will type <a> <BS> 
  1033. <e>. But that is a digraph, so you will not get what you want. To avoid this, 
  1034. use <DEL> instead of <BS>.
  1035.  
  1036.  
  1037.     5. Editing files
  1038.  
  1039. 5.1 Introduction
  1040.  
  1041. Editing a file with Vim means:
  1042.  
  1043. 1. reading the file into the internal buffer
  1044. 2. changing the buffer with editor commands
  1045. 3. writing the buffer into a file
  1046.  
  1047. As long as you don't write the buffer, the original file remains unchanged. 
  1048. If you start editing a file (read a file into the buffer), the file name is 
  1049. remembered as the "current filename".
  1050.  
  1051. If there already was a current filename, then that one becomes the alternate 
  1052. file name. Up to 20 older alternate filenames are remembered in a list. When 
  1053. you enter a filename, for editing (e.g. with ":e filename") or writing (e.g. 
  1054. with (:w filename"), the filenames shift one down in this list. You can use 
  1055. this list to remember which files you edited and to quickly switch from one 
  1056. file to another with the CTRL-^ command (e.g. to copy text). {Vi: only one 
  1057. alternate filename}
  1058.  
  1059. In Ex commands (the ones that start with a colon) <%> is replaced by the
  1060. current filename and <#> is replaced by the alternate filename. The older
  1061. alternate filenames are "#1", "#2", ..., "#9". "#0" is the same as "#". "#<"
  1062. is replaced by the current filename with the extension deleted (everything
  1063. after and including the last '.' in the file name).
  1064.  
  1065. CTRL-G        or
  1066. :f[ile]            Prints the current filename (as typed) and the
  1067.             cursor position.
  1068.  
  1069. {count}CTRL-G        Prints the current filename with full path and the
  1070.             cursor position.
  1071.  
  1072. :f[ile] {name}        Sets the current filename to {name}.
  1073.  
  1074. :files            Lists the alternate filenames.
  1075.  
  1076. Vim will remember the full path name of a file name that you enter. In most
  1077. cases when the file name is displayed only the name you typed is shown, but
  1078. the full path name is being used if you used the ":cd" command.
  1079.  
  1080. When writing the buffer, the default is to use the current filename. Thus 
  1081. when you give the "ZZ" or ":wq" command, the original file will be 
  1082. overwritten. If you do not want this, the buffer can be written into another 
  1083. file by giving a filename argument to the ":write" command. For example:
  1084.     
  1085.     vim testfile
  1086.     [change the buffer with editor commands]
  1087.     :w newfile
  1088.     :q
  1089.  
  1090. This will create a file "newfile", that is a modified copy of "testfile". 
  1091. The file "testfile" will remain unchanged. Anyway, if the 'backup' option is 
  1092. set, Vim renames the original file before it will be overwritten. You can 
  1093. use this file if you discover that you need the original file. The name of 
  1094. the backup file is the same as the original file with ".bak" appended. Any 
  1095. <.> is replaced by <_> on MSDOS machines, when Vim has detected that an 
  1096. MSDOS-like filesystem is being used (e.g. messydos or crossdos) and when the 
  1097. 'shortname' option is set.
  1098.  
  1099. Technical: On the Amiga you can use 30 characters for a file name. But on an 
  1100.        MSDOS-compatible filesystem only 8 plus 3 characters are 
  1101.        available. Vim tries to detect the type of filesystem when it is 
  1102.        creating the .vim file. If an MSDOS-like filesystem is suspected, 
  1103.        a flag is set that has the same effect as setting the 'shortname' 
  1104.        option. This flag will be reset as soon as you start editing a 
  1105.        new file. The flag will be used when making the filename for the 
  1106.        ".vim" and ".bak" files for the current file. But when you are 
  1107.        editing a file in a normal filesystem and write to an MSDOS-like 
  1108.        filesystem the flag will not have been set. In that case the 
  1109.        creation of the ".bak" file may fail and you will get an error 
  1110.        message. Use the 'shortname' option in this case.
  1111.  
  1112. Vim remembers whether you have changed the buffer. You are protected from
  1113. losing the changes you made. If you try to quit without writing, or want to
  1114. start editing another file, this will be refused. In order to overrule this
  1115. protection add a <!> to the command. The changes will then be lost. For
  1116. example: ":q" will not work if the buffer was changed, but ":q!" will. To see
  1117. whether the buffer was changed use the "CTRL-G" command. The message includes
  1118. the string "[Modified]" if the buffer has been changed.
  1119.  
  1120.  
  1121. 5.2 Editing a file
  1122.  
  1123. :e[dit] [+pat]        Edit the current file, unless changes have been made.
  1124.  
  1125. :e[dit]! [+pat]        Edit the current file always. Discard any changes to
  1126.             the buffer.
  1127.  
  1128. :e[dit] [+pat] {file}    Edit {file}, unless changes have been made.
  1129.  
  1130. :e[dit]! [+pat] {file}    Edit {file} always. Discard any changes to the
  1131.             buffer.
  1132.  
  1133. :e[dit] #[count]        Edit the [count]th alternate filename (as shown by
  1134.                         :files). Omitting [count] is equivalent to CTRL-^.
  1135.  
  1136. :ex [+pat] [file]    Same as :edit. {Vi: go from visual to Ex mode}
  1137.  
  1138. :vi[sual] [+pat] [file]    Same as :edit. {Vi: go from Ex to Visual mode}
  1139.  
  1140. [count]CTRL-^        Edit [count]th alternate file (equivalent to ":e
  1141.             #[count]"). Without count this gets you to the
  1142.             previously edited file. This is a quick way to
  1143.             toggle between two (or more) files. If the
  1144.             'autowrite' option is set and the buffer was
  1145.             changed, write it.
  1146.  
  1147. :cd            On non-Unix systems: Print the current directory
  1148.             name. On Unix systems: Change the current directory
  1149.             to the home directory.
  1150.  
  1151. :cd {path}        Change the current directory to {path}. Does not
  1152.             change the meaning of an already entered file name,
  1153.             because its full path name is remembered.
  1154.  
  1155. :chd[ir] [path]        Same as :cd.
  1156.  
  1157. :pwd            Print the current directory name. {Vi: no pwd}
  1158.  
  1159. These commands are used to start editing a single file. This means that the
  1160. file is read into the buffer and the current filename is set. You may use the
  1161. ":cd" command to get to another directory, so you will not have to type that 
  1162. directory name in front of the filenames. One warning: After using ":cd" the
  1163. full path name will be used for reading and writing files. On some networked
  1164. file systems this may cause problems. The result of using the full path name
  1165. is that the file names currently in use will remain refering to the same
  1166. file. Example: If you have a file a:test and a directory a:vim the commands
  1167. ":e test" ":cd vim" ":w" will overwrite the file a:test and not write
  1168. a:vim/test. But if you do ":w test" the file a:vim/test will be written,
  1169. because you gave a new file name and did not refer to a file name before the
  1170. ":cd".
  1171.  
  1172. You can use the ":e!" command if you messed up the buffer and want to start 
  1173. all over again. The ":e" command is only useful if you have changed the 
  1174. current filename.
  1175.  
  1176. The [+pat] can be used to position the cursor in the newly opened file:
  1177.     +        Start at the last line.
  1178.     +{num}        Start at line {num}.
  1179.     +/{pat}        Start at first line containing {pat}. {pat} must not
  1180.             contain any spaces.
  1181.     +{command}    Execute {command} after opening the new file.
  1182.             {command} is an Ex command. It must not contain 
  1183.             spaces.
  1184.  
  1185. When reading a file when the 'textmode' option is off (default for
  1186. non-MSDOS) the <LF> character is interpreted as end-of-line. If 'textmode'
  1187. is on (default for MSDOS), <CR><LF> is also interpreted as end-of-line.
  1188.  
  1189. When writeing a file when the 'textmode' option is off a <LF> character is
  1190. used to separate lines. When the 'textmode' option is on <CR><LF> is used.
  1191.  
  1192. You can read a file with 'textmode' set and write it with 'textmode' reset.
  1193. This will replace all <CR><LF> pairs by <LF>. If you read a file with
  1194. 'textmode' reset and write with 'textmode' set, all <LF> characters will be
  1195. replaced by <CR><LF>.
  1196.  
  1197. If you start editing a new file and the 'textauto' option is set, Vim will
  1198. try to detect whether the lines in the file are separated by a single <LF>
  1199. (as used on Unix and Amiga) or by a <CR><LF> pair (MSDOS). It reads up to
  1200. the first <LF> and checks if there is a <CR> in front of it. If there is the
  1201. 'textmode' option is set, otherwise it is reset. If the 'textmode' option is
  1202. set on non-MSDOS systems the message "[textmode]" is shown to remind you
  1203. that something unusual is happening. On MSDOS systems you get the message
  1204. "[notextmode]" if the 'textmode' option is not set.
  1205.  
  1206. Before editing binary, executable or Vim script files you should set the
  1207. 'textmode' and 'textauto' options off. With 'textmode' on you risc that
  1208. single <LF> characters are unexpectedly replaced with <CR><LF>. A simple way
  1209. to do this is by starting Vim with the "-b" option.
  1210.  
  1211.  
  1212. 5.3 The file list
  1213.  
  1214. If you give more than one filename when starting Vim, this list is remembered
  1215. as the file list. You can use this list with the following commands:
  1216.  
  1217. :ar[gs]            Print the file list, with the current file in "[]".
  1218.  
  1219. :[count]n[ext]        Edit [count] next file, unless changes have been 
  1220.             made and the 'autowrite' option is off {Vi: no 
  1221.             count}.
  1222.  
  1223. :[count]n[ext]!        Edit [count] next file, discard any changes to the 
  1224.             buffer {Vi: no count}.
  1225.  
  1226. :n[ext] [+pat] {filelist}
  1227.             Define {filelist} as the new list of files and edit
  1228.             the first one, unless changes have been made and the
  1229.             'autowrite' option is off.
  1230.  
  1231. :n[ext]! [+pat] {filelist}
  1232.             Define {filelist} as the new list of files and edit
  1233.             the first one. Discard any changes to the buffer.
  1234.  
  1235. :[count]N[ext]        Edit [count] previous file in file list, unless 
  1236.             changes have been made and the 'autowrite' option is 
  1237.             off {Vi: no count}.
  1238.  
  1239. :[count]N[ext]!        Edit [count] previous file in file list. Discard any 
  1240.             changes to the buffer {Vi: no count}.
  1241.  
  1242. :[count]pre[vious]    Same as :Next {Vi: only in some versions}
  1243.  
  1244. :rew[ind]        Start editing the first file in the file list, unless
  1245.             changes have been made and the 'autowrite' option is
  1246.             off.
  1247.  
  1248. :rew[ind]!        Start editing the first file in the file list.
  1249.             Discard any changes to the buffer.
  1250.  
  1251. :[count]wn[ext]        Write current file and start editing the [count] 
  1252.             next file. {not in Vi}
  1253.  
  1254. :[count]wn[ext] {file}    Write current file to {file} and start editing the 
  1255.             [count] next file, unless {file} already exists and 
  1256.             the 'writeany' option is off. 
  1257.             {not in Vi}
  1258.  
  1259. :[count]wn[ext]! {file}    Write current file to {file} and start editing the 
  1260.             [count] next file. {not in Vi}
  1261.  
  1262. The [count] in the commands above defaults to one.
  1263.  
  1264. The wildcards in the file list are expanded and the filenames are sorted.
  1265. Thus you can use the command "vim *.c" to edit all the C files. From within 
  1266. Vim the command ":n *.c" does the same.
  1267.  
  1268. You are protected from leaving Vim if you are not editing the last file in 
  1269. the file list. This prevents you from forgetting that you were editing one 
  1270. out of several files. You can exit anyway, and save any changes, with the 
  1271. ":wq!" command. To lose any changes use the ":q!" command.
  1272.  
  1273.  
  1274. 5.4 Writing and quitting
  1275.  
  1276. :[range]w[rite][!]    Write the specified lines to the current file.
  1277.  
  1278. :[range]w[rite]    {file}    Write the specified lines to {file}, unless it
  1279.             already exists and the 'writeany' option is off.
  1280.  
  1281. :[range]w[rite]! {file}    Write the specified lines to {file}. Overwrite an
  1282.             existing file.
  1283.  
  1284. :[range]w[rite][!] >>    Append the specified lines to the current file.
  1285.  
  1286. :[range]w[rite][!] >> {file}
  1287.             Append the specified lines to {file}. <!> forces the
  1288.             write even if file does not exist.
  1289.  
  1290. :[range]w[rite] !{cmd}    Execute {cmd} with [range] lines as standard input
  1291.             (note the space in front of the <!>).
  1292.  
  1293. The default [range] for the ":w" command is the whole buffer (1,$).
  1294.  
  1295.  
  1296. :q[uit]         Quit, unless changes have been made or not editing 
  1297.             the last file in the file list.
  1298.  
  1299. :q[uit]!        Quit always, without writing.
  1300.  
  1301. :cq            Quit always, without writing, and return an error 
  1302.             code. Used for Manx's QuickFix mode (see 5.5).
  1303.  
  1304. :wq            Write the current file. Exit if not editing the
  1305.             last file in the file list.
  1306.  
  1307. :wq!            Write the current file and exit.
  1308.  
  1309. :wq {file}        Write to {file}. Exit if not editing the last
  1310.             file in the file list.
  1311.  
  1312. :wq! {file}        Write to {file} and exit.
  1313.  
  1314. :x[it][!] [file]    Like ":wq", but write only when changes have been
  1315.             made.
  1316.  
  1317. ZZ            Write current file, if modified, and exit (same as
  1318.             ":x").
  1319.  
  1320. If you write to an existing file (but do not append) while the 'backup' or 
  1321. 'writebackup' option is on, a backup of the original file is made. On Unix 
  1322. systems the file is copied, on other systems the file is renamed. After the 
  1323. file has been successfully written and when the 'writebackup' option is on 
  1324. and the 'backup' option is off, the backup file is deleted.
  1325.  
  1326. 'backup'    'writebackup'        action
  1327.    off             off        no backup made
  1328.    off             on            backup made, deleted afterwards
  1329.    on             off        backup made, not deleted
  1330.    on             on            backup made, not deleted (default)
  1331.  
  1332. On Unix systems:
  1333. When you write to an existing file, that file is truncated and then filled 
  1334. with the new text. This means that protection bits, owner and symbolic links 
  1335. are unmodified. The backup file however, is a new file, owned by the user 
  1336. who edited the file. If it is not possible to create the backup file in the 
  1337. same directory as the original file, the directory given with the 
  1338. 'backupdir' option is used (default: home directory).
  1339.  
  1340. If the creation of a backup file fails, the write is not done. If you want 
  1341. to write anyway add a <!> to the command.
  1342.  
  1343. If the 'textmode' option is set <CR><LF> is used for end-of-line. This is
  1344. default for MSDOS. On other systems the message "[textmode]" is shown to
  1345. remind you that an usual end-of-line marker was used. If the 'textmode' is
  1346. not set LF is used for end-of-line. On MSDOS the message "[notextmode]" is
  1347. shown. See also the 'textmode' and 'textauto' options.
  1348.  
  1349.  
  1350. 5.5 Using the QuickFix mode
  1351.  
  1352. Vim has a special mode to speedup the edit-compile-edit cycle. This is
  1353. inspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
  1354. The idea is to save the error messages from the compiler in a file and use
  1355. Vim to jump to the errors one by one. You can then examine each problem and
  1356. fix it, without having to remember all the error messages.
  1357.  
  1358. If you are using Manx's Aztec C compiler on the Amiga you should do the
  1359. following:
  1360. - Set the CCEDIT environment variable with the command
  1361.     mset "CCEDIT=vim -e"
  1362. - Compile with the -qf option. If the compiler finds any errors, Vim is 
  1363.   started and the cursor is positioned on the first error. The error message
  1364.   will be displayed on the last line. You can go to other errors with the
  1365.   commands mentioned below. You can fix the errors and write the file(s).
  1366. - If you exit Vim normally the compiler will re-compile the same file. If you
  1367.   exit with the :cq command, the compiler will terminate. Do this if you
  1368.   cannot fix the error, or if another file needs to be compiled first.
  1369.  
  1370. If you are using another compiler you should save the error messages in a
  1371. file and start Vim with "vim -e filename". An easy way to do this is with
  1372. the ":make" command (see below). The 'errorformat' option should be set to
  1373. match the error messages from your compiler (see below).
  1374.  
  1375. The following commands can be used if you are in QuickFix mode:
  1376.  
  1377. :cc [nr]        Display error [nr]. If [nr] is omitted, the same
  1378.             error is displayed again. {not in Vi}
  1379.  
  1380. :cn            Display the next error in the list that includes a
  1381.             file name. If there are no file names at all, go the
  1382.             the next error. {not in Vi}
  1383.  
  1384. :cp            Display the previous error in the list that includes
  1385.             a file name. If there are no file names at all, go
  1386.             the the previous error. {not in Vi}
  1387.  
  1388. :cq            Quit Vim with an error code, so that the compiler
  1389.             will not compile the same file again. {not in Vi}
  1390.  
  1391. :cf [errorfile]        Read the error file and jump to the first error.
  1392.             This is done automatically when Vim is started with
  1393.             the -e option. You can use this command when you
  1394.             keep Vim running while compiling. If you give the
  1395.             name of the errorfile, the 'errorfile' option will
  1396.             be set to [errorfile] {not in Vi}
  1397.  
  1398. :cl            List all errors. {not in Vi}
  1399.  
  1400. :make [arguments]    1. If the 'autowrite' option is set and the buffer
  1401.                was changed, write it.
  1402.             2. Any existing 'errorfile' is deleted.
  1403.             3. The program given with the 'makeprg' option is
  1404.                started (default "make") with the optional
  1405.                [arguments] and the output is saved in
  1406.                'errorfile' (for Unix it is also echoed on the
  1407.                screen).
  1408.             4. The 'errorfile' is then read and the first error
  1409.                is jumped to.
  1410.             5. The 'errorfile' is deleted.
  1411.             {not in Vi}
  1412.  
  1413. The name of the file can be set with the 'errorfile' option. The default is 
  1414. "AztecC.Err" for the Amiga and "errors" for other systems. The format of the
  1415. file from the Aztec compiler is:
  1416.  
  1417.     filename>linenumber:columnnumber:errortype:errornumber:errormessage
  1418.  
  1419.     filename    name of the file in which the error was detected
  1420.     linenumber    line number where the error was detected
  1421.     columnnumber    column number where the error was detected
  1422.     errortype    type of the error, normally a single <E> or <W>
  1423.     errornumber    number of the error (for lookup in the manual)
  1424.     errormessage    description of the error
  1425.  
  1426. Another compiler is likely to use a different format. You should set the
  1427. 'errorformat' option to a scanf-like string that describes the format. First
  1428. you need to know how scanf works. Look in the documentation of your C
  1429. compiler. Vim will understand eight conversion characters. Others are invalid.
  1430.     %f        file name (finds a string)
  1431.     %l        line number (finds a number)
  1432.     %c        column number (finds a number)
  1433.     %t        error type (finds a single character)
  1434.     %n        error number (finds a number)
  1435.     %m        error message (finds a string)
  1436.     %*<conv>    any scanf non-assignable conversion
  1437.     %%        the single <%> character
  1438.  
  1439. Examples:
  1440. "%f>%l:%c:%t:%n:%m"            for the AztecC.Err file
  1441. "%f:%l:\ %t%*[^0123456789]%n:\ %m"    for Aztec C error messages
  1442. "%f\ %l\ %t%*[^0123456789]%n:\ %m"    for SAS C
  1443. "\"%f\",%*[^0123456789]%l:\ %m"        default for generic C compilers
  1444.  
  1445. Note the backslash in front of a space and double quote. It is required for
  1446. the :set command.
  1447.  
  1448. The "%f" and "%m" conversions have to detect the end of the string. They
  1449. should be followed by a character that cannot be in the string. Everything
  1450. up to that character is included in the string. Be careful: "%f%l" will
  1451. include everything up to the first <%> in the file name. If the "%f" or "%m"
  1452. is at the end, everything up to the end of the line is included.
  1453.  
  1454. If a line is detected that does not completely match the 'errorformat', the
  1455. whole line is put in the error message and the entry is marked "not valid"
  1456. These lines are skipped with the ":cn" and ":cp" commands (unless there is
  1457. no valid line at all). You can use ":cl" to display all the error messages.
  1458.  
  1459. If the error format does not contain a file name Vim cannot switch to the
  1460. correct file. You will have to do this by hand.
  1461.  
  1462. If you have a compiler that produces error messages that do not fit in the
  1463. format string, you could write a program that translates the error messages
  1464. into this format. You can use this program with the ":make" command by
  1465. changing the 'makeprg' option. For example:
  1466.     ":set mp=make\ \\\|&\ error_filter".
  1467. The backslashes before the pipe character are required to avoid it to be
  1468. recognized as a command separator. The backslash before each space is
  1469. required for the set command.
  1470.  
  1471. The ":make" command executes the command given with the 'makeprg' option.
  1472. This is done by passing the command to the shell given with the 'shell'
  1473. option. This works almost like typing
  1474.  
  1475.     ":!{makeprg} >{errorfile} [arguments]".
  1476.  
  1477. {makeprg} is the string given with the 'makeprg' option. Any command can be
  1478. used, not just "make". Characters <%> and <#> are expanded as usual on a
  1479. command line. You can use "#<" to insert the current filename without
  1480. extension, for example ":set makeprg=make\ #<.o".
  1481.  
  1482. {errorfile} is the 'errorfile' option.
  1483.  
  1484. [arguments] is anything that is typed after ":make".
  1485.  
  1486. There are some restrictions to the Quickfix mode on the Amiga. The
  1487. compiler only writes the first 25 errors to the errorfile (Manx's
  1488. documentation does not say how to get more). If you want to find the others,
  1489. you will have to fix a few errors and exit the editor. After recompiling,
  1490. up to 25 remaining errors will be found.
  1491.  
  1492. On the Amiga, if Vim was started from the compiler, the :sh and :! commands
  1493. will not work, because Vim is then running in the same process as the
  1494. compiler and these two commands may guru the machine then.
  1495.  
  1496. If you insert or delete lines, mostly the correct error location is still 
  1497. found because hidden marks are used (Manx's Z editor does not do this). 
  1498. Sometimes, when the mark has been deleted for some reason, the message "line 
  1499. changed" is shown to warn you that the error location may not be correct. If 
  1500. you edit another file the marks are lost and the error locations may not be 
  1501. correct anymore.
  1502.  
  1503.  
  1504. 5.6 Editing binary files
  1505.  
  1506. Although Vim was made to edit text files, it is possible to edit binary
  1507. files. The "-b" command line option (b for binary) sets some options for
  1508. editing binary files ('binary' on, 'textwidth' to 0, 'textmode' and
  1509. 'textauto' off, 'modelines' to 0, 'expandtab' off). Setting the 'binary'
  1510. option has the same effect. Don't forget to do this before reading the file.
  1511.  
  1512. There are a few things to remember when editing binary files:
  1513. - When editing executable files the number of characters must not change.
  1514.   Use only the "R" or "r" command to change text. Do not delete characters
  1515.   with "x" or by backspacing.
  1516. - Set the 'textwidth' option to 0. Otherwise lines will unexpectedly be
  1517.   split in two.
  1518. - When there are not many end-of-line characters, the lines will become very
  1519.   long. If you want to edit a line that does not fit on the screen reset the
  1520.   'wrap' option. Horizontal scrolling is used then. If a line becomes too
  1521.   long (more than about 32767 characters on the Amiga, much more on 32-bit
  1522.   systems) you cannot edit that line. It is also possible that you get an
  1523.   "out of memory" error when reading the file.
  1524. - Make sure the 'textmode' and 'textauto' options are off before loading the
  1525.   file. In 'textmode' both <CR><LF> and <LF> are considered to end a line
  1526.   and when the file is written the <LF> will be replaced by <CR><LF>. The
  1527.   'modelines' option should also be off, because there may be a string like
  1528.   ":vi:" in the file that would give unpredictable results.
  1529. - <NUL> characters are shown on the screen as ^@. You can enter them with
  1530.   "CTRL-V CTRL-@" or "CTRL-V 000" {vi cannot handle <NUL> characters in the
  1531.   file}
  1532. - To insert a <LF> character in the file split up a line. When writing the
  1533.   buffer to a file a <LF> will be written for the end of line.
  1534. - Vim normally appends an end-of-line character at the end of the file if
  1535.   there is none. Setting the 'binary' option prevents this. If you want to
  1536.   add the final end-of-line, append an empty line at the end.
  1537.  
  1538.  
  1539.     6. Cursor motions
  1540.  
  1541. These commands move the cursor position. If the new position is off of the
  1542. screen, the screen is scrolled to show the cursor (see also 'scrolljump' 
  1543. option).
  1544.  
  1545. The motion commands can be used after other commands, called operators, to
  1546. have the command operate on the text that was moved over. That is the text
  1547. between the cursor position before and after the motion. If the motion
  1548. includes a count and the operator also had a count, the two counts are
  1549. multiplied. For example: "2d3w" deletes six words.
  1550.     The operator either affects whole lines, or the characters between 
  1551. the start and end position. Generally, motions that move between lines
  1552. affect lines (are linewise), and motions that move within a line affect
  1553. characters. However, there are some exceptions.
  1554.     A character motion is either inclusive or exclusive. When inclusive,
  1555. the start and end position of the motion are included in the operation.
  1556. When exclusive, the last character towards the end of the buffer is not
  1557. included. Linewise motions always include the start and end position.
  1558.     Which motions are linewise, inclusive or exclusive is mentioned 
  1559. below. There are however, two general exceptions:
  1560. 1. If the motion is exclusive and the end of the motion is in column 1, the 
  1561.    end of the motion is moved to the end of the previous line and the motion 
  1562.    becomes inclusive. Example: "}" ends at the first line after a paragraph, 
  1563.    but "V}" will not include that line.
  1564. 2. If the motion is exclusive, the end of the motion is in column 1 and the 
  1565.    start of the motion was at or before the first non-blank in the line, the 
  1566.    motion becomes linewise. Example: If a paragraph begins with some blanks 
  1567.    and you do "d}" while standing on the first non-blank, all the lines of 
  1568.    the paragraph are deleted, including the blanks. If you do a put now, the 
  1569.    deleted lines will be inserted below the cursor position.
  1570.  
  1571. Instead of first giving the operator and then a motion you can use Visual
  1572. mode: mark the start of the text with <v>, move the cursor to the end of the
  1573. text that is to be affected and then hit the operator. The text between the
  1574. start and the cursor position is highlighted, so you can see what text will
  1575. be operated upon. This allows much more freedom, but requires more key
  1576. strokes and has limited redo functionality. See the chapter on Visual mode.
  1577.  
  1578. If you want to know where you are in the file use the "CTRL-G" command. If 
  1579. you set the 'ruler' option, the cursor position is continuously shown in the 
  1580. status line (which slows down Vim a little).
  1581.  
  1582. NOTE: Experienced users prefer the hjkl keys because they are always right
  1583. under their fingers. Beginners often prefer the arrow keys, because they
  1584. do not know what the hjkl keys do. The mnemonic value of hjkl is clear from
  1585. looking at the keyboard. Think of j as an arrow pointing downwards.
  1586.  
  1587. 6.1 Left-right motions
  1588.  
  1589. h        or
  1590. <C_LEFT>    or
  1591. CTRL-H        or
  1592. <BS>            [count] characters to the left (exclusive).
  1593.  
  1594. l        or
  1595. <C_RIGHT>    or
  1596. <SPACE>            [count] characters to the right (exclusive).
  1597.  
  1598. 0            To the first character of the line (exclusive).
  1599.  
  1600. ^            To the first non-blank character of the line
  1601.             (exclusive).
  1602.  
  1603. $            To the end of line [count] from the cursor
  1604.             (inclusive).
  1605.  
  1606. |            To column [count] (inclusive).
  1607.  
  1608. f<char>            To [count]'th occurrence of <char> to the right. The
  1609.             cursor is placed on <char> (inclusive).
  1610.  
  1611. F<char>            To the [count]'th occurrence of <char> to the left.
  1612.             The cursor is placed on <char> (inclusive).
  1613.  
  1614. t<char>            Till before [count]'th occurrence of <char> to the
  1615.             right. The cursor is placed on the character left of 
  1616.             <char> (inclusive).
  1617.  
  1618. T<char>            Till after [count]'th occurrence of <char> to the
  1619.             left. The cursor is placed on the character right of
  1620.             <char> (inclusive).
  1621.  
  1622. ;            Repeat latest f, t, F or T [count] times.
  1623.  
  1624. ,            Repeat latest f, t, F or T in opposite direction
  1625.             [count] times.
  1626.  
  1627. These commands move the cursor to the specified column in the current line.
  1628. They stop at the first column and at the end of the line, except "$", which 
  1629. may move to one of the next lines.
  1630.  
  1631.  
  1632. 6.2 Up-down motions
  1633.  
  1634. k        or
  1635. <C_UP>        or
  1636. CTRL-P            [count] lines upward (linewise).
  1637.  
  1638. j        or
  1639. <C_DOWN>    or
  1640. CTRL-J        or
  1641. <LF>        or
  1642. CTRL-N            [count] lines downward (linewise).
  1643.  
  1644. -  <minus>        [count] lines upward, on the first non-blank
  1645.             character (linewise).
  1646.  
  1647. +        or
  1648. CTRL-M        or
  1649. <CR>            [count] lines downward, on the first non-blank
  1650.             character (linewise).
  1651.  
  1652. _  <underscore>        [count] - 1 lines downward, on the first non-blank
  1653.             character (linewise).
  1654.  
  1655. G            Goto line [count], default last line, on the first
  1656.             non-blank character (linewise).
  1657.  
  1658. :[range]        Set the cursor on the (last) specified line number
  1659.             (cannot be used with an operator).
  1660.  
  1661. {count}%        Go to {count} percentage in the file, column 1 
  1662.             (linewise). To compute the new line number this 
  1663.             formula is used: {count} * number-of-lines / 100.
  1664.             {not in Vi}
  1665.  
  1666. These commands move to the specified line. They stop when reaching the first 
  1667. or the last line. The first two commands put the cursor in the same column 
  1668. (if possible) as it was after the last command that changed the column, 
  1669. except after the "$" command, then the cursor will be put on the last 
  1670. character of the line.
  1671.  
  1672.  
  1673. 6.3 Word motions
  1674.  
  1675. <SC_RIGHT>    or
  1676. w            [count] words forward (exclusive).
  1677.  
  1678. W            [count] WORDS forward (exclusive).
  1679.  
  1680. e            Forward to the end of word [count] (inclusive).
  1681.  
  1682. E            Forward to the end of WORD [count] (inclusive).
  1683.  
  1684. <SC_LEFT>    or
  1685. b            [count] words backward (exclusive).
  1686.  
  1687. B            [count] WORDS backward (exclusive).
  1688.  
  1689. These commands move over words or WORDS. A word consists of a sequence of 
  1690. letters, digits and underscores, or a sequence of other non-blank 
  1691. characters, separated with white space (spaces, tabs, end of line). A WORD
  1692. consists of a sequence of non-blank characters, separated with white space.
  1693. An empty line is also considered to be a word and a WORD.
  1694.  
  1695. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is 
  1696. on a non-blank. This is because "cw" is interpreted as change-word, and a 
  1697. word does not include the following white space. {Vi: "cw" when on a blank 
  1698. followed by other blanks changes only the first blank; this is probably a 
  1699. bug, because "dw" deletes all the blanks}
  1700.  
  1701. Another special case: When using the "w" motion in combination with an 
  1702. operator and the last word moved over is at the end of a line, the end of 
  1703. that word becomes the end of the operated text, not the first word in the 
  1704. next line.
  1705.  
  1706. The original vi implementation of "e" is buggy. For example, the "e" command 
  1707. will stop on the first character of a line if the previous line was empty. 
  1708. But when you use "2e" this does not happen. In Vim "ee" and "2e" are the 
  1709. same, which is more logical. However, this causes a small incompatibility 
  1710. between vi and Vim.
  1711.  
  1712.  
  1713. 6.4 Text object motions
  1714.  
  1715. (            [count] sentences backward (exclusive).
  1716.  
  1717. )            [count] sentences forward (exclusive).
  1718.  
  1719. {            [count] paragraphs backward (exclusive).
  1720.  
  1721. }            [count] paragraphs forward (exclusive).
  1722.  
  1723. ]]            [count] sections forward or to the next <{> in the
  1724.             first column. When used after an operator, then the
  1725.             <}> in the first column. (linewise).
  1726.  
  1727. ][            [count] sections forward or to the next <}> in the
  1728.             first column (linewise).
  1729.  
  1730. [[            [count] sections backward or to the previous <{> in
  1731.             the first column (linewise).
  1732.  
  1733. []            [count] sections backward or to the previous <}> in
  1734.             the first column (linewise).
  1735.  
  1736. These commands move over three kinds of text objects.
  1737.  
  1738. A sentence is defined as ending at a <.>, <!> or <?> followed by either the 
  1739. end of a line, or by a space. {Vi: two spaces} Any number of closing <)>, 
  1740. <]>, <"> and <'> characters my appear after the <.>, <!> or <?> before the 
  1741. spaces or end of line. A paragraph and section boundary is also a sentence 
  1742. boundary.
  1743.  
  1744. A paragraph begins after each empty line, and also at each of a set of 
  1745. paragraph macros, specified by the pairs of characters in the 'paragraphs' 
  1746. option. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the 
  1747. macros ".IP", ".LP", etc. (these are nroff macros, the dot must be in the 
  1748. first column). A section boundary is also a paragraph boundary. Note that
  1749. this does not include a <{> or <}> in the first column.
  1750.  
  1751. A section begins after a form-feed in the first column and at each of a set
  1752. of section macros, specified by the pairs of characters in the 'sections'
  1753. option. The default is "SHNHH HUnhsh".
  1754.  
  1755. The "]" and "[" commands stop at the <{> or <}" in the first column. This is
  1756. useful to find the start or end of a function in a C program. Note that the
  1757. first character of the command determines the search direction and the
  1758. second character the type of brace found.
  1759.  
  1760.  
  1761. 6.5 Pattern searches
  1762.  
  1763. /{pattern}[/]        Search forward for the [count]'th occurrence of
  1764.             {pattern} (exclusive).
  1765.  
  1766. /{pattern}/{offset}    Search forward for the [count]'th occurrence of
  1767.             {pattern} and go {offset} lines up or down (see 
  1768.             below). (linewise).
  1769.  
  1770. /            Search forward for the [count]'th latest used
  1771.             pattern with latest used {offset}.
  1772.  
  1773. //{offset}        Search forward for the [count]'th latest used
  1774.             pattern with new {offset}. If {offset} is empty no
  1775.             offset is used.
  1776.  
  1777. *            Search forward for the [count]'th occurrence of the
  1778.             ident after or under the cursor (exclusive). {not in 
  1779.             Vi}
  1780.  
  1781. #            Search backward for the [count]'th occurrence of the
  1782.             ident after or under the cursor (exclusive). {not in 
  1783.             Vi}
  1784.  
  1785. ?{pattern}[?]        Search backward for the [count]'th previous
  1786.             occurrence of {pattern} (exclusive).
  1787.  
  1788. ?{pattern}?{offset}    Search backward for the [count]'th previous
  1789.             occurrence of {pattern} and go {offset} lines up or
  1790.             down (see below) (linewise).
  1791.  
  1792. ?            Search backward for the [count]'th latest used
  1793.             pattern with latest used {offset}.
  1794.  
  1795. ??{offset}        Search backward for the [count]'th latest used
  1796.             pattern with new {offset}. If {offset} is empty no
  1797.             offset is used.
  1798.  
  1799. n            Repeat the latest "/" or "?" [count] times. {Vi: no
  1800.             count}
  1801.  
  1802. N            Repeat the latest "/" or "?" [count] times in
  1803.             opposite direction. {Vi: no count}
  1804.  
  1805. CTRL-C            Interrupt current (search) command.
  1806.  
  1807. These commands search for the specified pattern. With "/" and "?" an 
  1808. additional offset may be given. There are two types of offsets: line offsets 
  1809. and character offsets. {the character offsets are not in Vi}
  1810.  
  1811. The offset gives the cursor positition relative to the found match:
  1812.     +[num]    [num] lines downwards, in column 1
  1813.     -[num]    [num] lines upwards, in column 1
  1814.     e[+num]    [num] characters to the right of the end of the match
  1815.     e[-num]    [num] characters to the left of the end of the match
  1816.     s[+num]    [num] characters to the right of the start of the match
  1817.     s[-num]    [num] characters to the left of the start of the match
  1818.     n        not an offset: search without setting the current position
  1819.             of the cursor (used internally for the :tags command)
  1820.  
  1821. If a <-> or <+> is given but [num] is omitted, a count of one will be used.
  1822.  
  1823. Examples:
  1824.  
  1825. pattern            cursor position
  1826. /test/+1        one line below "test", in column 1
  1827. /test/e            on the last t of "test"
  1828. /test/s+2        on the <s> of "test"
  1829.  
  1830. If one of these commands is used after an operator, the characters between 
  1831. the cursor position before and after the search is affected. However, if a 
  1832. line offset is given, the whole lines between the two cursor positions are 
  1833. affected.
  1834.  
  1835. The last used <pattern> and <offset> are remembered. They can be used to
  1836. repeat the search, possibly in another direction or with another count. Note
  1837. that only one <pattern> is remembered for all searches, including :s
  1838. (substitute). Each time an empty <pattern> is given, the previously used
  1839. <pattern> is used.
  1840.  
  1841. If the 'wrapscan' option is set (which is the default), searches wrap around 
  1842. the end of the buffer. If 'wrapscan' is not set, the backward search stops 
  1843. at the beginning and the forward search stops at the end of the buffer. If 
  1844. the pattern was not found the error message "pattern not found" is given, 
  1845. and the cursor will not be moved.
  1846.  
  1847. Patterns may contain special characters, depending on the setting of the
  1848. 'magic' option. The "*" and "#" commands search for the identifier currently
  1849. under the cursor. If there is no indentifier under the cursor, the first one 
  1850. to the right is used. This identifier may only contain letters, digits and 
  1851. underscores. Note that if you type with ten fingers, the characters are easy 
  1852. to remember: the "#" is under your left hand middle finger (search to the
  1853. left and up) and the "*" is under your right hand middle finger (search to
  1854. the right and down).
  1855.  
  1856. The definition of a pattern:
  1857.  
  1858. 1.  A pattern is one or more branches, separated by '\|'. It matches anything
  1859.     that matches one of the branches. Example: "foo\|bar" matches "foo" and
  1860.     "bar.
  1861.  
  1862. 2.  A branch is one or more pieces, concatenated. It matches a match for the
  1863.     first, followed by a match for the second, etc. Example: "foo[0-9]bar",
  1864.     first match "foo", then a digit and then "bar".
  1865.  
  1866. 3.  A piece is an atom, possibly followed by:
  1867.       'magic'    'nomagic'
  1868.       option    option
  1869.     *      \*        matches 0 or more of the preceding atom
  1870.     \+      \+        matches 1 or more of the preceding atom {not
  1871.                 in Vi}
  1872.     \?      \?        matches 0 or 1 of the preceding atom {not in
  1873.                 Vi}
  1874.     Examples:
  1875.        .*      .\*        match anything, also empty string
  1876.        .\+      .\+        match any non-empty string
  1877.        foo\?      foo\?        match "fo" and "foo"
  1878.  
  1879.  
  1880. 4.  An atom can be:
  1881.     - One of these five:
  1882.       magic    nomagic
  1883.     .      \.        matches any single character
  1884.     \<      \<        matches the beginning of a word
  1885.     \>      \>        matches the end of a word
  1886.     ^      ^        at beginning of pattern, matches start of
  1887.                 line
  1888.     $      $        at end of pattern, matches end of line
  1889.     - A pattern enclosed by escaped parentheses (e.g. "\(^a\)").
  1890.     - A single character, with no special meaning, matches itself
  1891.     - A backslash followed by a single character, with no special meaning,
  1892.       matches the single character.
  1893.     - A range. This is a sequence of characters enclosed in '[]' with the 
  1894.       'magic' option, or enclosed in '\[]' with the 'nomagic' option. It 
  1895.       normally matches any single character from the sequence. If the 
  1896.       sequence begins with <^>, it matches any single character NOT in the 
  1897.       sequence. If two characters in the sequence are separated by <->, this 
  1898.       is shorthand for the full list of ASCII characters between them (e.g. 
  1899.       '[0-9]' matches any decimal digit). To include a literal <]> in the 
  1900.       sequence, make it the first character (following a possible <^>). To 
  1901.       include a literal '\-', make it the first or last character.
  1902.  
  1903. If the 'ignorecase' option is set, the case of letters is ignored.
  1904.  
  1905. It is impossible to have a pattern that contains a line break.
  1906.  
  1907. Examples:
  1908. ^beep(            Probably the start of the C function "beep".
  1909.  
  1910. [a-zA-Z]$        Any alphabetic character at the end of a line.
  1911.  
  1912. \(^\|[^a-zA-Z0-9_]\)[a-zA-Z_]\+[a-zA-Z0-9_]*
  1913.             A C identifier (will stop in front of it).
  1914.  
  1915. [.!?][])"']*\($\|[ ]\)    A search pattern that finds the end of a sentence,
  1916.             with almost the same definition as the <)> command.
  1917.  
  1918. Technical detail:
  1919. <NUL> characters in the file are stored as <LF> in memory. In the display
  1920. they are shown as "^@". The translation is done when reading and writing
  1921. files. To match a <NUL> with a search pattern you can just enter CTRL-@ or
  1922. "CTRL-V 000". This is probably just what you expect. Internally the
  1923. character is replaced by a <LF> in the search pattern. What is unusual is
  1924. that typing CTRL_V CTRL_J also inserts a <LF>, thus also searches for a
  1925. <NUL> in the file. {vi cannot handle <NUL> characters in the file at all}
  1926.  
  1927.  
  1928. 6.6 Various motions
  1929.  
  1930. m<a-zA-Z>        Set mark <a-zA-Z> at cursor position (does not move 
  1931.             the cursor, this is not a motion command).
  1932.  
  1933. :[range]mar[k] <a-zA-Z>    Set mark <a-zA-Z> at last line number in [range], 
  1934.             column 0. Default is cursor line.
  1935.  
  1936. :[range]k<a-zA-Z>    Same as :mark, but the space before the mark name can
  1937.             be omitted.
  1938.  
  1939. '<a-z>            To the first non-blank character on the line with
  1940.             mark <a-z> (linewise).
  1941.  
  1942. '<A-Z>            To the first non-blank character on the line with
  1943.             mark <A-Z> in the correct file (linewise when in 
  1944.             same file, not a motion command when in other file). 
  1945.             {not in Vi}
  1946.  
  1947. `<a-z>            To the mark <a-z> (exclusive).
  1948.  
  1949. `<A-Z>            To the mark <A-Z> in the correct file (exclusive 
  1950.             when in same file, not a motion command when in 
  1951.             other file). {not in Vi}
  1952.  
  1953. :marks            List the current marks (not a motion command). {not 
  1954.             in Vi}
  1955.  
  1956. A mark is not visible in any way. It is just a position in the file that is
  1957. remembered. Do not confuse marks with named registers, they are totally 
  1958. unrelated.
  1959.  
  1960. Lowercase marks are only remembered as long as you stay in the current
  1961. file. If you start editing another file, change a character in a line or 
  1962. delete a line that contains a mark, that mark is erased. Lowercase marks can 
  1963. be used in combination with operators. For example: "d't" deletes the lines 
  1964. from the cursor position to mark <t>. Hint: Use mark <t> for Top, <b> for 
  1965. Bottom, etc..
  1966.  
  1967. Uppercase marks include the file name. {Vi: no uppercase marks} You can use 
  1968. them to jump from file to file. You can only use an uppercase mark with 
  1969. an operator if the mark is in the current file. As long as you stay in the 
  1970. current file the line number of the mark remains correct, even if you 
  1971. insert/delete lines. After changing files the line number may be wrong 
  1972. (keeping them correct would take too much time). To avoid this use a 
  1973. ":marks" command before abandoning a file, this will update the line numbers 
  1974. in the current file.
  1975.  
  1976.  
  1977. '[            To the first non-blank character on the first line 
  1978.             of the previously operated text or start of the last 
  1979.             putted text. {not in Vi}
  1980.  
  1981. `[            To the first character of the previously operated 
  1982.             text or start of the last putted text. {not in Vi}
  1983.  
  1984. ']            To the first non-blank character on the last line of 
  1985.             the previously operated text or end of the last 
  1986.             putted text. {not in Vi}
  1987.  
  1988. `]            To the last character of the previously operated 
  1989.             text or end of the last putted text. {not in Vi}
  1990.  
  1991. After executing an operator the Cursor is put at the beginning of the text 
  1992. that was operated upon. After a put command ("p" or "P") the cursor is 
  1993. sometimes placed at the first inserted line and somtimes on the last 
  1994. inserted character. The four commands above put the cursor at either
  1995. end. Example: After yanking 10 lines you want to go to the last one of them: 
  1996. "10Y']". After inserting several lines with the "p" command you want to jump 
  1997. to the lowest inserted line: "p']".
  1998.  
  1999. Note: After deleting text, the start and end positions are the same, except 
  2000. when using blockwise Visual mode. These commands do not work when no
  2001. operator or put command has been used yet in the current file. The position
  2002. may be incorrect after inserting text and ".p.
  2003.  
  2004.  
  2005. ''            To the first non-blank character of the line where
  2006.             the cursor was before the latest jump (linewise).
  2007.  
  2008. ``            To the position before latest jump (exclusive).
  2009.  
  2010. A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n", 
  2011. "N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and
  2012. the commands that start editing a new file. If you make the cursor "jump"
  2013. with one of these commands, the position of the cursor before the jump is
  2014. remembered. You can return to that position with the "''" and "``" command,
  2015. unless the line containing that position was changed or deleted.
  2016.  
  2017. CTRL-O            Go to [count] Older cursor position in jump list
  2018.             (not a motion command). {not in Vi}
  2019.  
  2020. CTRL-I            Go to [count] newer cursor position in jump list
  2021.             (not a motion command). {not in Vi}
  2022.  
  2023. :jumps            Print the jump list (not a motion command). {not in 
  2024.             Vi} 
  2025.  
  2026. Jumps are remembered in a jump list. With the CTRL-O and CTRL-I command you 
  2027. can go to cursor positions before older jumps, and back again. Thus you can 
  2028. move up and down the list.
  2029.  
  2030. For example, after three jump commands you have this jump list:
  2031.  
  2032.  jump line  file
  2033.    1     1  -current-
  2034.    2    70  -current-
  2035.    3  1154  -current-
  2036. >
  2037.  
  2038. You are currently in line 1167. If you then use the CTRL-O command, the 
  2039. cursor is put in line 1154. This results in:
  2040.  
  2041.  jump line  file
  2042.    1     1  -current-
  2043.    2    70  -current-
  2044. >  3  1154  -current-
  2045.    4  1167  -current-
  2046.  
  2047. The pointer will be set at the last used jump position. The next CTRL-O 
  2048. command will use the entry above it, the next CTRL-I command will use the 
  2049. entry below it. If the pointer is below the last entry, this indicates that 
  2050. you did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command 
  2051. will cause the cursor position to be added to the jump list, so you can get 
  2052. back to the postition before the CTRL-O. In this case this is line 1167.
  2053.  
  2054. With more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I 
  2055. you can go back to 1154 and 1167 again.
  2056.  
  2057. If you use a jump command, the current line number is inserted at the end of 
  2058. the jump list. If you used CTRL-O or CTRL-I just before that, the same line 
  2059. may be in the list twice. This may be a bit strange. Just try it and look at 
  2060. the jump list with the :jumps command. Note that this behaviour is different 
  2061. from the tag stack.
  2062.  
  2063. After the CTRL-O command that got you into line 1154 you could give another 
  2064. jump command (e.g. "G"). The jump list would then become:
  2065.  
  2066.  jump line  file
  2067.    1     1  -current-
  2068.    2    70  -current-
  2069.    3  1154  -current-
  2070.    4  1167  -current-
  2071.    5  1154  -current-
  2072. >
  2073.  
  2074. As long as you stay in the same file, the line numbers will be adjusted for 
  2075. deleted and inserted lines. If you go to another file the line numbers may 
  2076. be wrong (keeping them correct would take too much time). If you want to 
  2077. avoid this use a :jumps command before changing files. This will update the 
  2078. line numbers in the current file.
  2079.  
  2080. %            Find the next parenthesis or (curly/square) bracket
  2081.             on this line and go to its match (inclusive). Parens
  2082.             and braces preceded with a backslash are ignored.
  2083.             Parens and braces inside quotes are ignored, unless
  2084.             the number of parens/braces in a line is uneven and
  2085.             this line and the previous one does not end in a
  2086.             backslash. No count is allowed ({count}% jumps to a
  2087.             line {count} percentage down the file).
  2088.  
  2089. H            To line [count] from top (Home) of screen (default:
  2090.             first line on the screen) on the first non-blank 
  2091.             character (linewise).
  2092.  
  2093. M            To Middle line of screen, on the first non-blank
  2094.             character (linewise).
  2095.  
  2096. L            To line [count] from bottom of screen (default: Last
  2097.             line on the screen) on the first non-blank character 
  2098.             (linewise).
  2099.  
  2100.  
  2101.     7. Scrolling
  2102.  
  2103. Move edit window downwards (this means that more lines downwards in the text
  2104. buffer are seen):
  2105.  
  2106. CTRL-E            Window [count] lines downwards in the buffer
  2107.  
  2108. CTRL-D            Window Downwards in the buffer. The number of lines
  2109.             comes from the 'scroll' option (default: half a
  2110.             screen). If [count] given, first set 'scroll' option
  2111.             to [count].
  2112.  
  2113. <SC_DOWN>    or
  2114. CTRL-F            Window [count] pages Forwards (downwards) in the
  2115.             buffer.
  2116.  
  2117. Move edit window upwards (this means that more lines upwards in the text
  2118. buffer are seen): 
  2119.  
  2120. CTRL-Y            Window [count] lines upwards in the buffer.
  2121.  
  2122. CTRL-U            Window Upwards in the buffer. The number of lines
  2123.             comes from the 'scroll' option (default: half a
  2124.             screen). If [count] given, first set 'scroll' option
  2125.             to [count].
  2126.  
  2127. <SC_UP>        or
  2128. CTRL-B            Window [count] pages Backwards (upwards) in the
  2129.             buffer.
  2130.  
  2131. Window repositioning:
  2132.  
  2133. z<CR>            Redraw, line [count] at top of window (default
  2134.             cursor line).
  2135.  
  2136. z{height}<CR>        Redraw, make window {height} lines tall. This is
  2137.             useful to make the number of lines small when screen
  2138.             updating is very slow. Cannot make the height more
  2139.             than the physical screen height.
  2140.  
  2141. z.            Redraw, line [count] at center of window (default 
  2142.             cursor line).
  2143.  
  2144. z-            Redraw, line [count] at bottom of window (default 
  2145.             cursor line).
  2146.  
  2147. These commands move the contents of the window. If the cursor position is 
  2148. moved off of the window, the cursor is moved onto the window. A page is the 
  2149. number of lines in the window minus two. The mnemonics for these commands 
  2150. may be a bit confusing. Remember that the commands refer to moving the 
  2151. window upwards or downwards in the buffer. But when the window moves upwards 
  2152. in the buffer, the text in the window moves downwards on your screen.
  2153.  
  2154.  
  2155.     8. Tags
  2156.  
  2157. :ta[g][!] {ident}    Jump to the definition of {ident}, using the
  2158.             information in the tags file. Put {ident} in the tag
  2159.             stack. See below for [!].
  2160.  
  2161. CTRL-]            ":ta" to the identifier under or after cursor. Put 
  2162.             the identifier in the tag stack. {Vi: identifier 
  2163.             after the cursor}
  2164.  
  2165. CTRL-T            Jump to [count] older entry in the tag stack
  2166.             (default 1). {not in Vi}
  2167.  
  2168. :[count]po[p][!]    Jump to [count] older entry in tag stack (default 1).
  2169.             See below for [!]. {not in Vi}
  2170.  
  2171. :[count]ta[g][!]    Jump to [count] newer entry in tag stack (default 1).
  2172.             See below for [!]. {not in Vi}
  2173.  
  2174. :tags            Show the contents of the tag stack. The active
  2175.             entry is marked with a <>>. {not in Vi}
  2176.  
  2177. A tag is an identifier that appears in the "tags" file. It is a sort of label
  2178. that can be jumped to. For example: In C programs each function name can be 
  2179. used as a tag.
  2180.  
  2181. With the ":tag" command the cursor will be positioned on the tag. With the
  2182. CTRL-] command, the identifier on which the cursor is standing is used as the
  2183. tag. If the cursor is not on an identifier, the first identifier rightwards 
  2184. of the cursor is used.
  2185.  
  2186. If the tag is in the current file this will always work. Otherwise the
  2187. performed actions depend on whether the current file was changed, whether a !
  2188. is added to the command and on the 'autowrite' option:
  2189.  
  2190.   tag in       file        autowrite
  2191. current file  changed   !   option      action
  2192. -----------------------------------------------------------------------------
  2193.     yes         x    x     x      goto tag
  2194.     no         no    x     x      read other file, goto tag
  2195.     no        yes    yes    x   abondon current file, read other file, goto
  2196.                       tag
  2197.     no        yes    no    on  write current file, read other file, goto
  2198.                       tag
  2199.     no        yes    no   off  fail
  2200. -----------------------------------------------------------------------------
  2201.  
  2202. - If the tag is in the current file, the command will always work.
  2203. - If the tag is in another file and the current file was not changed, the 
  2204.   other file will be made the current file and read into the buffer.
  2205. - If the tag is in another file, the current file was changed and a ! is 
  2206.   added to the command, the changes to the current file are lost, the other 
  2207.   file will be made the current file and read into the buffer.
  2208. - If the tag is in another file, the current file was changed and the 
  2209.   'autowrite' option is set, the current file will be written, the other 
  2210.   file will be made the current file and read into the buffer.
  2211. - If the tag is in another file, the current file was changed and the 
  2212.   'autowrite' option is not set, the command will fail. If you want to save 
  2213.   the changes, use the ":w" command and then use ":tag" without an argument. 
  2214.   This works because the tag is put on the stack anyway. If you want to lose 
  2215.   the changes you can use the ":tag!" command.
  2216.  
  2217. The ":tag" command works very well for C programs. If you see a call to a
  2218. function and wonder what that function does, position the cursor inside of 
  2219. the function name and hit CTRL-]. This will bring you to the function 
  2220. definition. An easy way back is with the CTRL-T command. Also read about the 
  2221. tag stack below.
  2222.  
  2223. A tags file can be created with the external command 'ctags'. It will 
  2224. contain a tag for each function. Some versions of 'ctags' will also make a 
  2225. tag for each "#defined" macro.
  2226.  
  2227. The lines in the tags file should have this format:
  2228.  
  2229.     {tag}{separator}{filename}{separator}{command}
  2230.  
  2231. {tag}        the identifier
  2232. {separator}    one or more <TAB> or space characters
  2233. {filename}    the file that contains the definition of {tag}
  2234. {command}    the Ex command that positions the cursor on the tag (it can
  2235.         be any Ex command, but normally it is a search command like 
  2236.         "/^main").
  2237.  
  2238. The 'tags' option is a list of file names separated by spaces. Each of these 
  2239. files is searched for the tag. This can be used to use a different file than 
  2240. the default file "tags". It can also be used to access a common tags file. 
  2241. For example:
  2242.  
  2243. :set tags=tags\ s:commontags
  2244.  
  2245. The tag will first be searched for in the file "tags" in the current 
  2246. directory. If it is not found there the file "s:commontags" will be searched 
  2247. for the tag. The backslash is required for the space to be included in the 
  2248. string option.
  2249.  
  2250.  
  2251. The tags that you use are remembered in the tag stack. You can print this 
  2252. stack with the ":tags" command. The result looks like this:
  2253.  
  2254.   # TO tag      FROM line in file
  2255.   1 main               1  harddisk2:text/vim/test
  2256. > 2 FuncA             58  -current-
  2257.   3 FuncC            357  harddisk2:text/vim/src/amiga.c
  2258.  
  2259. This list shows the tags that you jumped to and the cursor position before that 
  2260. jump. The older tags are at the top, the newer at the bottom.
  2261.  
  2262. The <>> points to the active entry. This is the tag that will be used by the 
  2263. next ":tag" command. The CTRL-T and ":pop" command will use the position 
  2264. above the active entry.
  2265.  
  2266. The line number and file name are remembered to be able to get back to where 
  2267. you were before the tag command. As long as you stay within one file the 
  2268. line number will be correct, also when deleting/inserting lines. When you go 
  2269. to another file the line number may not always be correct (keeping them 
  2270. correct all the time would take too much time). To avoid this use the 
  2271. ":tags" command before abandoning a file, which will update the line numbers 
  2272. in the current file.
  2273.  
  2274. You can jump to previously used tags with several commands. Some examples:
  2275.  
  2276.     ":pop" or CTRL-T     to position before previous tag
  2277.     {count}CTRL_T        to position before {count} older tag
  2278.     ":tag"            to newer tag
  2279.     ":0tag"         to last used tag
  2280.  
  2281. The most obvious way to use this is while browsing through the call graph of 
  2282. a program. Consider the following call graph:
  2283.  
  2284.     main  --->  FuncA  --->  FuncC
  2285.           --->  FuncB
  2286.  
  2287. (Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
  2288. You can get from main to FuncA by using CTRL-] on the call to FuncA. Then 
  2289. you can CTRL-] to get to FuncC. If you now want to go back to main you can 
  2290. use CTRL-T twice. Then you can CTRL-] to FuncB.
  2291.  
  2292. If you issue a ":ta {ident}" or CTRL-] command, this tag is inserted at the 
  2293. bottom of the stack. If the stack was full (it can hold up to 20 entries),
  2294. the oldest entry is deleted and the older entries shift one position up
  2295. (their index number is decremented by one). If the last used entry was not
  2296. at the bottom, the entries below the last used one are moved to the top.
  2297. This means that an old branch in the call graph is not lost, but moved to
  2298. another place on the tag stack. The stack above would change to:
  2299.  
  2300.   # TO tag      FROM line in file
  2301.   1 FuncA             58  harddisk2:text/vim/src/main.c
  2302.   2 FuncC            357  harddisk2:text/vim/src/amiga.c
  2303.   3 main               1  harddisk2:text/vim/test
  2304.   4 FuncB             59  harddisk2:text/vim/src/main.c
  2305. >
  2306.  
  2307. In the call graph example: You can use this to go back from FuncB to FuncC 
  2308. by hitting CTRL-T twice. This may be a bit strange. Use the :tags command to 
  2309. find out what will happen with CTRL-T commands.
  2310.  
  2311.  
  2312.     9. Inserting text
  2313.  
  2314. The following commands can be used to insert new text into the buffer. They
  2315. can all be undone. The non-Ex commands can be repeated with the "." command.
  2316.  
  2317. a            Append text after the cursor [count] times.
  2318.  
  2319. A            Append text at the end of the line [count] times.
  2320.  
  2321. i            Insert text before the cursor [count] times.
  2322.  
  2323. I            Insert text before the first CHAR on the line
  2324.             [count] times.
  2325.  
  2326. o            Begin a new line below the cursor and insert text,
  2327.             repeat [count] times. {Vi: blank [count] screen
  2328.             lines}
  2329.  
  2330. O            Begin a new line above the cursor and insert text,
  2331.             repeat [count] times. {Vi: blank [count] screen
  2332.             lines}
  2333.  
  2334. These commands are used to start inserting text. They can be undone and
  2335. repeated. You can end Insert mode with <ESC>. See the section "Insert and
  2336. Replace mode" for the other special characters in Insert mode. The effect of
  2337. [count] takes place after Insert mode is exited.
  2338.  
  2339. :r[ead] {name}        Insert the file {name} below the cursor.
  2340.  
  2341. :{range}r[ead] {name}    Insert the file {name} below the specified line.
  2342.  
  2343. :r[ead] !{cmd}        Execute {cmd} and insert its standard output below
  2344.             the cursor.
  2345.  
  2346. These commands insert the contents of a file, or the output of a command, 
  2347. into the buffer. They can be undone. They cannot be repeated with the "." 
  2348. command. They work on a line basis, insertion starts below the line in which 
  2349. the cursor is, or below the specified line. To insert text above the first 
  2350. line use the command ":0r {name}".
  2351.  
  2352. The <LF> character is recognized as end-of-line marker. If the 'textmode'
  2353. option is set, a <CR> in front of an <LF> is ignored. The 'textmode' option
  2354. is default on for MSDOS.
  2355.  
  2356. If the 'textauto' option is set Vim tries to recognize the type of
  2357. end-of-line marker (see 5.2 how this is done). However, the 'textmode'
  2358. option will not be changed. Only while reading one file the text mode is
  2359. used or not.
  2360.  
  2361. On non-MSDOS systems the message "[textmode]" is shown if a file is read in
  2362. text mode, to remind you that something unusual is done. On MSDOS the
  2363. message "[notextmode]" is shown if a file is read without text mode.
  2364.  
  2365.  
  2366.     10. Deleting text
  2367.  
  2368. ["x]x            Delete [count] characters under and after the cursor
  2369.             [into register x] (not linewise).
  2370.  
  2371. ["x]X            Delete [count] characters before the cursor [into
  2372.             register x] (not linewise).
  2373.  
  2374. ["x]d{motion}        Delete text that is moved over [into register x]. 
  2375.             See below for exception.
  2376.  
  2377. ["x]dd            Delete [count] lines [into register x] (linewise).
  2378.  
  2379. ["x]D            Delete the characters under the cursor until the end
  2380.             of the line and [count]-1 more lines [into register 
  2381.             x]; synonym for d$ (not linewise).
  2382.  
  2383. {visual}["x]x    or
  2384. {visual}["x]d        Delete the highlighted text [into register x] (see
  2385.             the chapter on Visual mode). {not in Vi}
  2386.  
  2387. {visual}["x]X    or
  2388. {visual}["x]D        Delete the highlighted lines [into register x] (see
  2389.             the chapter on Visual mode). {not in Vi}
  2390.  
  2391. :[range]d[elete] [x]    Delete [range] lines (default: current line) [into
  2392.             register x].
  2393.  
  2394. :[range]d[elete] [x] {count}
  2395.             Delete {count} lines, starting with [range]
  2396.             (default: current line, see 4.4.3) [into register
  2397.             x].
  2398.  
  2399. These commands delete text. They can be repeated with the "." command
  2400. (except ":d") and undone. Use Visual mode to delete blocks of text. See
  2401. "copying" for an explanation of registers.
  2402.  
  2403. An exception for the d{motion} command: If the motion is not linewise, the 
  2404. start and end of the motion are not in the same line and before the start 
  2405. and after the end are only blanks, the delete becomes linewise. This means 
  2406. that the blank line that would remain is also deleted.
  2407.  
  2408.  
  2409. J            Join [count] lines, with a minimum of two lines.
  2410.  
  2411. {visual}J        Join the highlighted lines, with a minimum of two
  2412.             lines. {not in Vi}
  2413.  
  2414. :[range]j[oin][!]    Join [range] lines. Same as "J", except when [!] is
  2415.             given, then no spaces will be inserted or deleted.
  2416.  
  2417. :[range]j[oin][!] {count}
  2418.             Join {count} lines, starting with [range] (default:
  2419.             current line, see 4.4.3). Same as "J", except when
  2420.             [!] is given, then no spaces will be inserted or 
  2421.             deleted.
  2422.  
  2423. These commands delete the newline between lines. This has the effect of 
  2424. joining them into one line. They can be repeated (except ":j") and undone. 
  2425.  
  2426. One space is inserted in place of the <LF>, unless the line ended with a 
  2427. space, <TAB> or the next line started with a <)>. If the next line has 
  2428. leading white space it is deleted first. If the 'joinspaces' option is set, 
  2429. two spaces are inserted after a period.
  2430.  
  2431.  
  2432.     11. Changing text
  2433.  
  2434. The following commands can be used to change text, that is delete some text 
  2435. and insert something else, with one command. They can all be undone. The 
  2436. non-Ex commands can be repeated with the "." command.
  2437.  
  2438.  
  2439. 11.1 Delete and insert
  2440.  
  2441. R            Enter Replace mode: Each character you type replaces
  2442.             an existing character, starting with the character
  2443.             under the cursor. Repeat the entered text [count]-1
  2444.             times.
  2445.  
  2446. ["x]c{motion}        Delete {motion} text [into register x] and start
  2447.             insert.
  2448.  
  2449. ["x]cc            Delete [count] lines [into register x] and start
  2450.             insert (linewise).
  2451.  
  2452. ["x]C            Delete from the cursor position to the end of the
  2453.             line and [count]-1 more lines [into register x], and 
  2454.             start insert. Synonym for c$ (not linewise).
  2455.  
  2456. ["x]s            Delete [count] characters [into register x] and start
  2457.             insert (s stands for Substitute). Synonym for "cl"
  2458.             (not linewise).
  2459.  
  2460. ["x]S            Delete [count] lines [into register x] and start 
  2461.             insert. Synonym for "^cc" with 'autoindent' option 
  2462.             or "0cc" with 'noautoindent' option (not linewise).
  2463.  
  2464. {visual}["x]c    or
  2465. {visual}["x]r    or
  2466. {visual}["x]s        Delete the highlighted text [into register x] and
  2467.             start insert (see the chapter on Visual mode). {not
  2468.             in Vi}
  2469.  
  2470. {visual}["x]C    or
  2471. {visual}["x]R    or
  2472. {visual}["x]S        Delete the highlighted lines [into register x] and
  2473.             start insert (see the chapter on Visual mode). {not
  2474.             in Vi}
  2475.  
  2476. You can end Insert and Replace mode with <ESC>. See the section "Insert and
  2477. Replace mode" for the other special characters in these modes. The effect of
  2478. [count] takes place after Insert or Replace mode is exited. {Vi: does not
  2479. directly delete the text, but puts a <$> at the last deleted character}
  2480. See "Copying and moving text" for an explanation of registers.
  2481.  
  2482. Replace mode is just like Insert mode, except that for every character you 
  2483. enter, one character is deleted. If the end of a line is reached, further 
  2484. characters are appended (just like Insert mode). In Replace mode the 
  2485. backspace key restores the original text (if there was any) (see section
  2486. "Insert and Replace mode").
  2487.  
  2488. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is 
  2489. on a non-blank. This is because "cw" is interpreted as change-word, and a 
  2490. word does not include the following white space. {Vi: "cw" when on a blank 
  2491. followed by other blanks changes only the first blank; this is probably a 
  2492. bug, because "dw" deletes all the blanks}
  2493.  
  2494.  
  2495. 11.2 Simple changes
  2496.  
  2497. r<char>            Replace the character under the cursor by <char>. If
  2498.             <char> is a <CR> or <LF> the character will be
  2499.             replaced by a line break. If a [count] is given that
  2500.             many characters will be replaced by [count] <char>s
  2501.             or line breaks {Vi: "5r<CR>" replaces five
  2502.             characters with a single line break}
  2503.  
  2504. ~            'notildeop' option: switch case of the character
  2505.             under the cursor and move the cursor to the right.
  2506.             If a [count] is given do that many characters {Vi:
  2507.             no count}
  2508.  
  2509. ~{motion}        'tildeop' option: switch case of {motion} text. {Vi: 
  2510.             tilde cannot be used as an operator}
  2511.  
  2512. {visual}~        switch case of highlighted text (see the chapter on 
  2513.             Visual mode). {not in Vi}
  2514.  
  2515. {visual}U        Make highlighted text uppercase (see the chapter on 
  2516.             Visual mode). {not in Vi}
  2517.  
  2518. {visual}u        Make highlighted text lowercase (see the chapter on 
  2519.             Visual mode). {not in Vi}
  2520.  
  2521. CTRL-A            Add [count] to the number at or after the cursor.
  2522.             {not in Vi}
  2523.  
  2524. CTRL-S            Subtract [count] from the number at or after the 
  2525.             cursor. If your terminal has problems with CTRL-S
  2526.             read unix.doc. {not in Vi}
  2527.  
  2528. The CTRL-A and CTRL-S commands work for (signed) decimal numbers and 
  2529. unsigned octal and hexadecimal numbers. Numbers starting with '0x' or '0X' 
  2530. are assumed to be hexadecimal. To decide whether the hexadecimal number 
  2531. should be printed uppercase or not, the case of the rightmost letter in the 
  2532. number is considered. If there is no letter in the current number, the 
  2533. previously detected case is used. Numbers starting with a <0> are considered 
  2534. to be octal. Other numbers are decimal and may be preceded with a minus 
  2535. sign. If the cursor is on a number, that one will be used. Otherwise the 
  2536. number right of the cursor will be used.
  2537.  
  2538. The CTRL-A command is very useful in a macro. Example: How to make a 
  2539. numbered list.
  2540.  
  2541. 1. Create the first entry. The entry should start with a number.
  2542. 2. qa        - start recording into buffer <a>
  2543. 3. Y         - yank the entry
  2544. 4. p         - put a copy of the entry below the first one
  2545. 5. CTRL-A    - increment the number
  2546. 6. q         - stop recording
  2547. 7. <count>@a - repeat the yank, put and increment <count> times
  2548.  
  2549.  
  2550. <{motion}        Shift the {motion} lines one shiftwidth leftwards.
  2551.  
  2552. <<            Shift [count] lines one shiftwidth leftwards.
  2553.  
  2554. {visual}<        Shift the highlighted lines one shiftwidth leftwards
  2555.             (see the chapter on Visual mode). {not in Vi}
  2556.  
  2557. >{motion}        Shift {motion} lines one shiftwidth rightwards.
  2558.  
  2559. >>            Shift [count] lines one shiftwidth rightwards.
  2560.  
  2561. {visual}>        Shift the highlighted lines one shiftwidth
  2562.             rightwards (see the chapter on Visual mode). {not in
  2563.             Vi}
  2564.  
  2565. :[range]<        Shift [range] lines left.
  2566.  
  2567. :[range]< {count}    Shift {count} lines left, starting with [range]
  2568.             (default current line, see 4.4.3).
  2569.  
  2570. :[range]le[ft] [indent]    left align lines in [range]. Sets the indent in the
  2571.             lines to [indent] (default 0). {not in Vi}
  2572.  
  2573. :[range]>        Shift {count} [range] lines right.
  2574.  
  2575. :[range]> {count}    Shift {count} lines right, starting with [range]
  2576.             (default current line, see 4.4.3).
  2577.  
  2578. The ">" and "<" commands are handy for changing the indent within programs. 
  2579. The size of the white space which is inserted or deleted can be set with the 
  2580. 'shiftwidth' option. Normally the 'shiftwidth' option is set to 8, but you 
  2581. can set it to e.g. 3 to make smaller indents. The shift leftwards stops when 
  2582. there is no indent. The shift right does not do anything with empty lines. 
  2583.  
  2584. If the 'shiftround' option is set, the indent is rounded to a multiple of 
  2585. 'shiftwidth'.
  2586.  
  2587. When the 'expandtab' option if off (this is the default) <TAB>s are used as 
  2588. much as possible to make the indent. You can use ">><<" to replace an indent 
  2589. made out of spaces with the same indent made out of <TAB>s (and a few 
  2590. spaces if neccessary). If the 'expandtab' option is on, only spaces are 
  2591. used. Then you can use ">><<" to replace <TAB>s in the indent by spaces.
  2592.  
  2593. Q{motion}        Format the lines that were moved over. The length of 
  2594.             each line will be restricted to the width set with 
  2595.             the 'textwidth' option. If the 'textwidth' option is
  2596.             0, all lines will be joined together. If the
  2597.             'autoindent' option is set, the indent of the first
  2598.             line is used for the following lines. The
  2599.             'formatprg' option can be set to the name of an
  2600.             external program, which will be used instead of the
  2601.             internal function. The 'textwidth' option will then
  2602.             not be used. {not in Vi}
  2603.  
  2604. :[range]ce[nter] [width]
  2605.             Center lines in [range] between [width] columns
  2606.             (default 'textwidth' or 80 when 'textwidth' is 0).
  2607.             {not in Vi}
  2608.  
  2609. :[range]ri[ght] [width]
  2610.             right align lines in [range] at [width] columns
  2611.             (default 'textwidth' or 80 when 'textwidth' is 0).
  2612.             {not in Vi}
  2613.  
  2614.  
  2615. 11.3 Complex changes
  2616.  
  2617. !{motion}{filter}    Filter {motion} text through the external program
  2618.             {filter}.
  2619.  
  2620. !!{filter}        Filter [count] lines through the external program
  2621.             {filter}.
  2622.  
  2623. {visual}!{filter}    Filter the highlighted lines through the external
  2624.             program {filter} (see the chapter on Visual mode).
  2625.             {not in Vi}
  2626.  
  2627. :{range}![!]{filter} [!][arg]
  2628.             Filter {range} lines through the external program
  2629.             {filter}. The optional bangs are replaced with the
  2630.             latest given command. The optional [arg] is appended.
  2631.  
  2632. ={motion}        Filter {motion} lines through the external program 
  2633.             given with the 'equalprg' option (default: 
  2634.             "indent"). {Vi: when 'lisp' option is set, autoindent 
  2635.             {motion} lines}
  2636.  
  2637. ==            Filter [count] lines through the external program
  2638.             given with the 'equalprg' option (default: indent).
  2639.             {not in Vi}
  2640.  
  2641. {visual}=        Filter the highlighted lines through the external
  2642.             program given with the 'equalprg' option (default:
  2643.             indent) (see the chapter on Visual mode). {not in
  2644.             Vi}
  2645.  
  2646. A filter is a program that accepts text at standard input, changes it in some
  2647. way, and sends it to standard output. The commands above can be used to send
  2648. some text through a filter. An example of a filter is "sort", which sorts 
  2649. lines alphabetically. The "indent" program is used to pretty indent C 
  2650. programs (you need a version of indent that works like a filter, not all 
  2651. versions do that). The shell, given with the 'shell' option, is used to 
  2652. execute the command (See also the 'shelltype' option).
  2653. The filter commands can be redone with ".".
  2654.  
  2655. :[range]s[ubstitute]/{pattern}/{string}/[g][c] [count]
  2656.             For each line in [range] replace the first occurrence
  2657.             of {pattern} by {string}. With option [g] all 
  2658.             occurrences in the line are replaced. With option 
  2659.             [c] each replace has to be confirmed (<y> to 
  2660.             replace, <q> to quit replacing, <n> to skip). With
  2661.             [count] that many lines are are searched, starting
  2662.             with the last line number in [range] (default
  2663.             current line, see 4.4.3).
  2664.  
  2665. :[range]s[ubstitute] [g][c] [count]
  2666.             Repeat last :substitute with new options and possibly
  2667.             on other lines.
  2668.  
  2669. :[range]&[/{pattern}/{string}/][g][c] [count]
  2670.             Same as for :substitute.
  2671.  
  2672. &            Synonym for ":s".
  2673.  
  2674. If the {pattern} for the substitute command is empty, the previously given
  2675. pattern is used (from any search, including "/" and ":g").
  2676.  
  2677. For the definition of a pattern see 6.5, "Pattern searches".
  2678.  
  2679. Some characters in {string} have a special meaning:
  2680.  
  2681. magic    nomagic      action
  2682.   &      \&      replaced by the whole matched pattern
  2683.  \&       &      replaced by &
  2684.       \0      replaced by the whole matched pattern
  2685.       \1      replaced by the matched pattern in the first pair of ()
  2686.       \2      replaced by the matched pattern in the second pair of ()
  2687.       ..      ..
  2688.       \9      replaced by the matched pattern in the ninth pair of ()
  2689.   ~      \~      replaced by the {string} of the previous substitute
  2690.  \~       ~      replaced by ~
  2691.       \u      next character made uppercase
  2692.       \U      following characters made uppercase
  2693.       \l      next character made uppercase
  2694.       \L      following characters made uppercase
  2695.       \e      end of /u, /U, /l and /L
  2696.       \E      end of /u, /U, /l and /L
  2697.       <CR>      split line in two at this point
  2698.   CTRL-V <CR>      insert a carriage-return (CTRL-M)
  2699.  
  2700. Examples:
  2701. :s/a\|b/xxx\0xxx/g          modifies "a b"      in "xxxaxxx xxxbxxx"
  2702. :s/\([abc]\)\([efg]\)/\2\1/g  modifies "af fa bg" in "fa fa gb"
  2703. :s/abcde/abc^Mde/          modifies "abcde"    in "abc", "de" (two lines)
  2704. :s/$/^V^M/              modifies "abcde"      in "abcde^M"
  2705.  
  2706. Note: To insert a ^M you have to type CTRL-V <CR>. To insert a ^V you have
  2707. to type CTRL-V CTRL-V. So to insert the ^V^M in the last example you have to
  2708. type CTRL-V CTRL-V CTRL-V <CR>.
  2709.  
  2710. Because CTRL-V <CR> inserts a <CR>, it is impossible to insert a CTRL-V just
  2711. in front of a line break. You will have to split it up in two parts:
  2712.     :s/foo/^Vxxxx/
  2713.     :s/xxxx/^M/
  2714.  
  2715. When using parentheses in combination with <|>, like in \([ab]\)\|\([cd]\), 
  2716. either the first or second pattern in parentheses did not match, so either 
  2717. \1 or \2 is empty. Example:
  2718. :s/\([ab]\)\|\([cd]\)/\1x/g   modifies "a b c d"  in "ax bx x x"
  2719.  
  2720.  
  2721.     12. Copying and moving text
  2722.  
  2723. "<a-zA-Z0-9.%">        Use register <a-zA-Z0-9.%"> for next delete, yank or
  2724.             put (use uppercase character to append with delete
  2725.             and yank) (<.> only works with put).
  2726.  
  2727. :di[splay]        Display the contents of numbered and named registers.
  2728.             {Vi: no such command}
  2729.  
  2730. ["x]y{motion}        Yank {motion} text [into register x].
  2731.  
  2732. ["x]yy            Yank [count] lines [into register x] (linewise).
  2733.  
  2734. ["x]Y            With 'noyankendofline' option: yank [count] lines 
  2735.             [into register x] (synonym for yy, linewise); with 
  2736.             'yankendofline' option: yank until end of line 
  2737.             (synonym for y$, not linewise).
  2738.  
  2739. {visual}["x]y        Yank the highlighed text [into register x] (see the 
  2740.             chapter on Visual mode). {not in Vi}
  2741.  
  2742. {visual}["x]Y        Yank the highlighted lines [into register x] (see the 
  2743.             chapter on Visual mode). {not in Vi}
  2744.  
  2745. :[range]y[ank] [x]    Yank [range] lines [into register x].
  2746.  
  2747. :[range]y[ank] [x] {count}
  2748.             Yank {count} lines, starting with last line number 
  2749.             in [range] (default: current line, see 4.4.3), [into 
  2750.             register x].
  2751.  
  2752. ["x]p            Put the text [from register x] after the cursor
  2753. [count]
  2754.             times. {Vi: no count}
  2755.  
  2756. ["x]P            Put the text [from register x] before the cursor
  2757.             [count] times. {Vi: no count}
  2758.  
  2759. :[line]pu[t] [x]    Put the text [from register x] after [line] (default
  2760.             current line).
  2761.  
  2762. :[line]pu[t]! [x]    Put the text [from register x] before [line] (default
  2763.             current line).
  2764.  
  2765. These commands can be used to copy text from one place to another. This is 
  2766. done by first getting the text into a register with a yank, delete or change 
  2767. command. The register can then be inserted with a put command. All registers 
  2768. are kept when changing files. Thus you can also use this to move text from 
  2769. one file to another (the CTRL-^ command is a quick way to toggle between two 
  2770. files).
  2771.  
  2772. The put commands can be repeated with "." (except for :put) and undone. If the
  2773. command that was used to get the text into the register was linewise, the 
  2774. text will be inserted below ("p") or above ("P") the line where the cursor
  2775. is. Otherwise the text will be inserted after ("p") or before ("P") the
  2776. cursor. With the ":put" command the text will always be inserted in the next
  2777. line. You can exchange two characters with the command sequence "xp". You
  2778. can exchange two lines with the command sequence "ddp". You can exchange
  2779. two words with the command sequence "deep" (start with the cursor in the
  2780. blank space before the first word). The "']" or "`]" command can be used
  2781. after the put command to move the cursor to the end of the inserted text,
  2782. "'[" or "`[" to move the cursor to the start.
  2783.  
  2784. If the command that was used to get the text into the register used 
  2785. blockwise Visual mode, the block of text will be inserted before ("P") or
  2786. after ("p") the cursor column, in the current and next lines. Vim will make
  2787. the whole block of text start in the same column. Thus the inserted text
  2788. looks the same as when it was yanked or deleted. Some <TAB> characters may
  2789. be replaced by spaces to make this happen. However, if the width of the
  2790. block is not a multiple of a <TAB> width and the text after the inserted
  2791. block contains <TAB>s, that text may be misaligned.
  2792.  
  2793. There are four types of registers: The unnamed regster, 10 numbered
  2794. registers, 26 named registers and two read-only registers.
  2795.     The unnamed register is the register where all text deleted with     
  2796. the "d", "c", "s", "x" commands or copied with the yank "y" command is
  2797. placed, regardless of whether or not a specific register was used (e.g.
  2798. "xdd). The contents of this register are used by any put command (p or P)
  2799. which does not specify a register. Additionally it can be accessed by the
  2800. name <">. This means you have to type two double quotes. {Vi: register
  2801. contents lost when changing files, no <">}
  2802.     The numbered registers are filled with yank and delete commands. 
  2803. Numbered register <0> is filled with the last yank command, unless another 
  2804. register was specified with ["x]. Numbered register <1> is filled with the 
  2805. text that was deleted by each delete or change command, unless another 
  2806. register was specified or the text is less than one line (text deleted with
  2807. "x" or "dw" will not be put in a numbered register). The contents of
  2808. register <1> are put in <2>, <2> in <3>, and so forth. The contents of
  2809. register <9> are lost. {Vi: numbered register contents are lost when
  2810. changing files; register 0 does not exist}
  2811.     The named registers are only filled when you say so. They are named 
  2812. <a> to <z> normally. If you use an uppercase letter, the same registers as 
  2813. with the lower case letter is used, but the text is appended to the previous 
  2814. register contents. With a lower case letter the previous contents are lost.
  2815.     The read-only registers are <%> and <.>. They can only be used with the
  2816. commands "p", "P" and ":put". <.> contains the last inserted text (the same
  2817. as what is inserted with the insert mode commands CTRL-A and CTRL-@). <%>
  2818. contains the name of the current file.
  2819.  
  2820. If you use a put command without specifying a register, the register that 
  2821. was last written to is used (this is also the contents of the unnamed
  2822. register). If you are confused, use the ":dis" command to find out what will
  2823. be put (all named and numbered registers are displayed; the unnamed register
  2824. is labelled <">).
  2825.  
  2826. The next three commands always work on whole lines.
  2827.  
  2828. :[range]co[py] {address}
  2829.             Copy the lines given by [range] to below the line
  2830.             given by {address}.
  2831.  
  2832. :t            Synonym for copy.
  2833.  
  2834. :[range]m[ove] {address}
  2835.             Move the lines given by [range] to below the line
  2836.             given by {address}.
  2837.  
  2838.  
  2839.     13. Visual mode
  2840.  
  2841. Visual mode is a flexible and easy way to select a piece of text for an 
  2842. operator. It is the only way to select a block of text.
  2843.  
  2844. v            start/stop Visual mode per character. {not in Vi}
  2845.  
  2846. V            start/stop Visual mode linewise. {not in Vi}
  2847.  
  2848. CTRL-V            start/stop Visual mode blockwise. {not in Vi}
  2849.  
  2850. o            go to Other end of highlighted text: The current
  2851.             cursor position becomes the start of the highlighted
  2852.             text and the cursor is moved to the Other end of the
  2853.             highlighted text. {not in Vi} 
  2854.  
  2855. To apply an operator on a piece of text:
  2856.     1. mark the start of the text with "v", "V" or CTRL-V
  2857.         The character under the cursor will be used as the start.
  2858.     2. move to the end of the text
  2859.         The text from the start of the Visual mode up to and
  2860.         including the character under the cursor is highlighted.
  2861.     3. hit an operator
  2862.         The highlighted characters will be operated upon.
  2863.  
  2864. The highlighted text includes the character under the cursor. On terminals
  2865. where it is possible to make the cursor invisible the cursor position is
  2866. also highlighted. On terminals where this is not possible the cursor is
  2867. displayed normally.
  2868.  
  2869. With "v" the text before the start position and after the end position will 
  2870. not be highlighted. However, All uppercase and non-alpha operators, except 
  2871. "~", will work on whole lines anyway. See the list of operators below.
  2872.  
  2873. With CTRL-V (blockwise Visual mode) the highlighted text will be a rectangle
  2874. between start position and the cursor. However, some operators work on whole
  2875. lines anyway (see the list below). The change and substitute operators will
  2876. delete the highlighted text and then start insertion at the top left
  2877. position. 
  2878.  
  2879. When the "$" command is used with blockwise Visual mode, the right end of the 
  2880. highlighted text will be determined by the longest highlighted line. This
  2881. stops when a motion command is used that does not move straight up or down.
  2882.  
  2883. If "v", "V", CTRL-V or ESC is typed while in Visual mode, the highlighting
  2884. stops and no text is affected. If you hit CTRL-Z the highlighting stops and
  2885. the editor is suspended or a new shell is started.
  2886.  
  2887. For moving the end of the block many commands can be used, but you cannot 
  2888. use Ex commands, commands that make changes or abandon the file. Commands 
  2889. (starting with) ".pPiIaAO&", CTRL_^, "ZZ", CTRL-], CTRL-T, CTRL-R, CTRL-I 
  2890. and CTRL-O cause a beep and Visual mode continues. 
  2891.  
  2892. If the "v", "V" or CTRL-V is preceded with a count, the previously
  2893. highlighted area is used for a start. You can then move the end of the
  2894. highlighted area and give an operator. The type of the old area is used
  2895. (character, line or blockwise).
  2896. - Linewise Visual mode: The number of lines is multiplied with the count.
  2897. - Blockwise Visual mode: The number of lines and columns is multiplied with
  2898.   the count.
  2899. - Normal Visual mode within one line: The number of characters is multipled
  2900.   with the count.
  2901. - Normal Visual mode with several lines: The number of lines is multipled
  2902.   with the count, in the last line the same number of characters is used as
  2903.   in the last line in the previously highlighted area.
  2904. The start of the text is the Cursor position. If the "$" command was used as 
  2905. one of the last commands to extend the highlighted text, the area will be
  2906. extended to the rightmost column of the longest line.
  2907.  
  2908. The operators that can be used are:
  2909.     ~    switch case
  2910.     d    delete
  2911.     c    change
  2912.     y    yank
  2913.     >    shift right (1)(*)
  2914.     <    shift left (1)(*)
  2915.     !    filter through external command (1)
  2916.     =    filter through 'equalprg' option command (1)
  2917.     Q    format lines to 'textwidth' length (1)
  2918.  
  2919. Additionally the following commands can be used:
  2920.     :    start ex command for highlighted lines (1)
  2921.     r    change
  2922.     s    change
  2923.     C    change (2)
  2924.     R    change (2)
  2925.     S    change (2)
  2926.     x    delete
  2927.     D    delete (2)
  2928.     X    delete (2)
  2929.     Y    yank (2)
  2930.     J    join (1)
  2931.     U    make uppercase
  2932.     u    make lowercase
  2933.  
  2934. (1): always whole lines
  2935. (2): whole lines when not using CTRL-V
  2936. (*): in a future a blockwise shift will move the block only, not whole
  2937.      lines.
  2938.  
  2939. If you want to give a register name using the """ command, do this just before 
  2940. typing the operator character: "v{move around}"xd".
  2941.  
  2942. When repeating a Visual mode operator, the operator will be applied to the
  2943. same amount of text as the last time:
  2944. - Linewise Visual mode: The same number of lines.
  2945. - Blockwise Visual mode: The same number of lines and columns.
  2946. - Normal Visual mode within one line: The same number of characters.
  2947. - Normal Visual mode with several lines: The same number of lines, in the
  2948.   last line the same number of characters as in the last line the last time.
  2949. The start of the text is the Cursor position. If the "$" command was used as 
  2950. one of the last commands to extend the highlighted text, the repeating will
  2951. be applied up to the rightmost column of the longest line.
  2952.  
  2953.  
  2954.     14. Various commands
  2955.  
  2956. CTRL-L            Clear and redraw the screen.
  2957.  
  2958. CTRL-Z            On Unix systems: Suspend Vim. On other systems: 
  2959.             start a new shell (like ":sh").
  2960.  
  2961. <HELP>        or
  2962. :h[elp]            Show the help file page by page. The help file name 
  2963.             can be set with the 'helpfile' option. Type an index
  2964.             character to go directly to a page. Type <SPACE> or
  2965.             CTRL-F (with MSDOS: page-down) to go one page
  2966.             forward. Type <b> or CTRL-B (with MSDOS: page-up) to
  2967.             go one page back. Type <a> to go back to the index.
  2968.             Type <CR> to get out of the help screen. {Vi: no
  2969.             help}
  2970.  
  2971. <DEL>            When entering a number: remove the last digit.
  2972.  
  2973. :[range]p[rint]        Print [range] lines (default current line).
  2974.  
  2975. :[range]p[rint] {count}
  2976.             Print {count} lines, starting with [range] (default
  2977.             current line, see 4.4.3).
  2978.  
  2979. :[range]l[ist] [count]
  2980.             Same as :print, but display unprintable characters
  2981.             with <^>.
  2982.  
  2983. :[range]nu[mber] [count]
  2984.             Same as :print, but precede each line with its line
  2985.             number.
  2986.  
  2987. :=            Print the line number.
  2988.  
  2989. :sh[ell]        Escape to a shell (name from 'shell' option).
  2990.  
  2991. :![!]{cmd} [!][arg]    Execute {cmd} with the shell. The optional bangs are
  2992.             replaced with the previously given command. The 
  2993.             optional [arg] is appended. See also the 'shell' and 
  2994.             'shelltype' option.
  2995.  
  2996. :ve[rsion]        Print the version number of the editor.
  2997.  
  2998. K            Run a program to lookup the identifier under the 
  2999.             cursor. The name of the program is given with the 
  3000.             'keywordprg' (kp) option. The identifier is formed 
  3001.             of letters, numbers and the underscore. The 
  3002.             identifier under or right of the cursor is used. The 
  3003.             same can be done with the command
  3004.                 ":!{program} {identifier}". 
  3005.             {not in Vi}
  3006.  
  3007.  
  3008.     15. Repeating commands
  3009.  
  3010. 15.1 Single repeats
  3011.  
  3012. .            Repeat last change with count replaced by [count].
  3013.  
  3014. Simple changes can be repeated with the "." command. Without a count, the 
  3015. count of the last change is used. If you enter a count, it will replace the 
  3016. last one. If the last change included a specification of a numbered 
  3017. register, the register number will be incremented. See the section on undo 
  3018. and redo for an example how to use this.
  3019.  
  3020.  
  3021. 15.2 Multiple repeats
  3022.  
  3023. :[range]g[lobal]/{pattern}/[cmd]
  3024.             Execute the Ex command [cmd] (default ":p") on the
  3025.             lines within [range] where {pattern} matches.
  3026.  
  3027. :[range]g[lobal]!/{pattern}/[cmd]
  3028.             Execute the Ex command [cmd] (default ":p") on the
  3029.             lines within [range] where {pattern} does NOT match.
  3030.  
  3031. :[range]v[global]/{pattern}/[cmd]
  3032.             Same as :g!.
  3033.  
  3034. The global commands work by first scanning through the [range] lines and
  3035. marking each line where a match occurs. In a second scan the [cmd] is 
  3036. executed for each marked line with its line number prepended. If a line is 
  3037. changed or deleted its mark disappears. The default for [range] is the whole 
  3038. buffer (1,$). Use "CTRL-C" to interrupt the command.
  3039.  
  3040. To repeat a non-Ex command, you will have to put the command in a file and 
  3041. use "source!". For example:
  3042.     :g/pat/so! scriptfile
  3043. Make sure that the scriptfile ends with a whole command, otherwise Vim will 
  3044. wait for you to type the rest of the command for each match. The screen will 
  3045. not have been updated, so you don't know what you are doing.
  3046.     
  3047. The undo/redo command will undo/redo the whole global command at once.
  3048.  
  3049.  
  3050. 15.3 Complex repeats
  3051.  
  3052. q<0-9a-zA-Z">        Record typed characters into register <0-9a-zA-Z">
  3053.             (uppercase to append). The 'q' that stops recording
  3054.             is also stored in the register. The 'q' command is
  3055.             disabled while executing a register. (Implementation
  3056.             note: This was done because the 'q' command can be
  3057.             the result of mapping). {Vi: no recording}
  3058.  
  3059. q            Stops recording. {Vi: no recording}
  3060.  
  3061. @<0-9a-z">        Execute the contents of register <0-9a-z"> [count]
  3062.             times. {Vi: only named registers}
  3063.  
  3064. @@            Repeat the previous @<0-9a-z"> [count] times.
  3065.  
  3066. :@<0-9a-z">        Execute the contents of register <0-9a-z"> as
  3067.             an Ex command. {Vi: only in some versions}
  3068.  
  3069. :@@            Repeat the previous :@<0-9a-z">. {Vi: only in some 
  3070.             versions}
  3071.  
  3072. :so[urce] {file}    Read Ex commands from {file}.
  3073.  
  3074. :so[urce]! {file}    Read Vim commands from {file}. {not in Vi}
  3075.  
  3076. All commands and command sequences can be repeated by putting them in a named
  3077. register and then executing it. There are two ways to get the commands in the
  3078. register:
  3079. - Use the record command "q". You type the commands once, and while they are
  3080.   being executed they are stored in a register. Easy, because you can see 
  3081.   what you are doing. If you make a mistake, 'put' the register into the 
  3082.   file, edit the command sequence, and then delete it into the register 
  3083.   again. You can continue recording by appending to the register (use an 
  3084.   uppercase letter).
  3085. - Delete or yank the command sequence into the register.
  3086.  
  3087. Often used command sequences can be put under a function key with the ':map'
  3088. command.
  3089.  
  3090. An alternative is to put the commands in a file, and execute them with the
  3091. ':source!' command. Useful for long command sequences. Can be combined with 
  3092. the ':map' command to put complicated commands under a function key.
  3093.  
  3094. The ':source' command reads Ex commands from a file line by line. You will 
  3095. have to type any needed keyboard input. The ':source!' command reads from a 
  3096. script file character by character, interpreting each character as if you 
  3097. typed it.
  3098.  
  3099. Example: When you give the ":!ls" command you are asked to "hit return to
  3100. continue". If you ':source' a file with the line "!ls" in it, you will have 
  3101. to type the return yourself. But if you ':source!' a file with the line 
  3102. ":!ls" in it, the next characters from that file are read until a <CR> is 
  3103. found. You will not have to type <CR> yourself, unless ":!ls" was the last 
  3104. line in the file.
  3105.  
  3106. It is possible to put ':source[!]' commands in the script file, so you can 
  3107. make a top-down hierachy of script files. The ':source' command can be 
  3108. nested as deep as the number of files that can be opened at one time (about 
  3109. 15). The ':source!' command can be nested up to 15 levels deep.
  3110.  
  3111. In script files terminal-dependent key codes are represented by 
  3112. terminal-independent single character codes. In the MSDOS version the values
  3113. are 48 (0x30) higher. Any of these codes can be entered with CTRL-V followed
  3114. by the three digit decimal code.
  3115.  
  3116.     code    hex    meaning
  3117.  
  3118.     128    0x80    up-arrow
  3119.     129    0x81    down-arrow
  3120.     130    0x82    left-arrow
  3121.     131    0x83    right-arrow
  3122.     132    0x84    shift up-arrow
  3123.     133    0x85    shift down-arrow
  3124.     134    0x86    shift left-arrow
  3125.     135    0x87    shift right-arrow
  3126.  
  3127.     136    0x88    function key 1
  3128.     137    0x89    function key 2
  3129.     138    0x8a    function key 3
  3130.     139    0x8b    function key 4
  3131.     140    0x8c    function key 5
  3132.     141    0x8d    function key 6
  3133.     142    0x8e    function key 7
  3134.     143    0x8f    function key 8
  3135.     144    0x90    function key 9
  3136.     145    0x91    function key 10
  3137.  
  3138.     146    0x92    shifted function key 1
  3139.     147    0x93    shifted function key 2
  3140.     148    0x94    shifted function key 3
  3141.     149    0x95    shifted function key 4
  3142.     150    0x96    shifted function key 5
  3143.     151    0x97    shifted function key 6
  3144.     152    0x98    shifted function key 7
  3145.     153    0x99    shifted function key 8
  3146.     154    0x9a    shifted function key 9
  3147.     155    0x9b    shifted function key 10
  3148.  
  3149.     156    0x9c    help key
  3150.     157    0x9d    undo key
  3151.     158    0x9e    special-function key follows (MSDOS)
  3152.     159    0x9f    CTRL-@
  3153.  
  3154.  
  3155.     16. Undo and redo
  3156.  
  3157. <UNDO>        or
  3158. u            Undo [count] changes. {Vi: only one level}
  3159.  
  3160. :u[ndo]            Undo one change. {Vi: only one level}
  3161.  
  3162. CTRL-R            Redo [count] changes which were undone. {Vi: redraw 
  3163.             screen}
  3164.  
  3165. :red[o]            Redo one change which was unodone. {Vi: no redo}
  3166.  
  3167. U            Undo all latest changes on one line. {Vi: while not
  3168.             moved off of it}
  3169.  
  3170. The last changes are remembered. You can go back in time with the "u" 
  3171. command. You can then go forward again with the 'CTRL-R' command. If you 
  3172. make a new change after the "u" command, the 'CTRL-R' will not be possible 
  3173. anymore. The number of changes that are remembered is set with the 
  3174. 'undolevels' option. If it is zero, the old fashioned Vi undo is present: 
  3175. one level of undo and undo undoes itself. If it is negative no undo is
  3176. possible. Use this if you are running out of memory.
  3177.  
  3178. The "U" command is treated by undo/redo just like any other command. Thus a 
  3179. "u" command undos a "U" command and a 'CTRL-R' command redoes it again. When 
  3180. mixing "U", "u" and 'CTRL-R' you will notice that the "U" command will 
  3181. restore the situation of a line to before the previous "U" command. This may 
  3182. be confusing. Try it out to get used to it.
  3183.  
  3184. The numbered registers can also be used for undoing deletes. Each time you 
  3185. delete text, it is put into register "1. The contents of register "1 are 
  3186. shifted to "2, etc. The contents of register "9 are lost. You can now get
  3187. back the most recent deleted text with the put command: '"1P'. (also, if the
  3188. deleted text was the result of the last delete or copy operation, 'P' or 'p'
  3189. also works as this puts the contents of the unnamed register). You can get
  3190. back the text of three deletes ago with '"3P'.
  3191.  
  3192. If you want to get back more than one part of deleted text, you can use a
  3193. special feature of the repeat command ".". It will increase the number of the
  3194. register used. So if you first do ""1P", the following "." will result in a
  3195. '"2P'. Repeating this will result in all numbered registers being inserted.
  3196.  
  3197. Example:    If you deleted text with 'dd....' it can be restored with
  3198.         '"1P....'.
  3199.  
  3200. If you don't know in which register the deleted text is, you can use the
  3201. :display command. An alternative is to try the first register with '"1P', and
  3202. if it is not what you want do 'u.'. This will remove the contents of the
  3203. first put, and repeat the put command for the second register. Repeat the
  3204. 'u.' until you got what you want.
  3205.  
  3206.  
  3207.     17. Key mapping
  3208.  
  3209. :map {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in Command mode.
  3210.  
  3211. :map! {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in Insert and
  3212.             Command_line mode.
  3213.  
  3214. :noremap {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in Command mode. 
  3215.             Disallow remapping of {rhs}. {not in Vi}
  3216.  
  3217. :noremap! {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in insert and
  3218.             Command_line mode. Disallow remapping of {rhs}. {not 
  3219.             in Vi}
  3220.  
  3221. :unm[ap] {lhs}        Remove the mapping of {lhs} for Command mode.
  3222.  
  3223. :unm[ap]! {lhs}        Remove the mapping of {lhs} for Insert and
  3224.             Command_line mode.
  3225.  
  3226. :map            List all key mappings for Command mode.
  3227.  
  3228. :map!            List all key mappings for Insert and Command_line
  3229.             mode.
  3230.  
  3231. :map {lhs}        List the key mappings for the key sequences starting
  3232.             with {lhs} in Command mode. {not in Vi}
  3233.  
  3234. :map! {lhs}        List the key mappings for the key sequences starting
  3235.             with {lhs} in insert and Command_line mode. {not in Vi}
  3236.  
  3237. :cm[ap]            Same as :map, but for Command_line mode only. {not
  3238.             in Vi}
  3239.  
  3240. :cu[nmap]        Same as :unmap, but for Command_line mode only.
  3241.             {not in Vi}
  3242.  
  3243. :cno[remap]        Same as :noremap, but for Command_line mode only.
  3244.             {not in Vi}
  3245.  
  3246. :im[ap]            Same as :map, but for Insert mode only. {not in Vi}
  3247.  
  3248. :iu[nmap]        Same as :unmap, but for Insert mode only. {not in
  3249.             Vi}
  3250.  
  3251. :ino[remap]        Same as :noremap, but for Insert mode only. {not in
  3252.             Vi}
  3253.  
  3254. These commands are used to map a key or key sequence to a string of 
  3255. characters. You can use this to put command sequences under function keys, 
  3256. translate one key into another, etc. See the "Options" chapter below for how 
  3257. to save and restore the current mapping.
  3258.  
  3259. There are three sets of mappings
  3260. - For Insert mode. These are also used in Replace mode.
  3261. - For Command_line mode: When entering a ":" or "/" command.
  3262. - For Command mode: When typing commands.
  3263.  
  3264. The original vi did not have separate mappings for Insert mode and
  3265. Command_line mode. Therefore the ":map!" command enters and displays
  3266. mappings for both. In Vim you can use the ":cmap" and ":imap" commands to
  3267. enter mappings for each mode separately. When listing mappings with ":map!",
  3268. ":cmap" or ":imap" the character in column 1 is <!> for mappings in both
  3269. Insert and Command_line mode, <i> for Insert mode only and <c> for
  3270. Command_line mode only.
  3271.  
  3272. Everything from the first non-blank after {lhs} up to the end of the line
  3273. (or <|>) is considered to be part of {rhs}. This allows the {rhs} to end
  3274. with a space.
  3275.  
  3276. To include a space in {lhs} precede it with a CTRL-V (type two CTRL-Vs for 
  3277. each space). If you want a {rhs} that starts with a space, precede {rhs} 
  3278. with a single CTRL-V (You have to type CTRL-V two times). You can create an 
  3279. empty {rhs} by typing nothing after the two CTRL-Vs.
  3280.  
  3281. It is not possible to put a comment after this command, because the <"> 
  3282. character is considered to be part of the {rhs}. To put a <|> in {rhs} 
  3283. escape it with a backslash or a CTRL-V (to get one CTRL-V you have to type 
  3284. it twice).
  3285.  
  3286. To avoid mapping of the characters you type in insert or Command_line mode, 
  3287. type a CTRL-V first. The mapping in Insert mode is disabled if the 'paste'
  3288. option is set.
  3289.  
  3290. Note that the second character (argument) of the commands @zZtTfF[]rm'`"v is
  3291. not mapped. This was done to be able to use all the named registers and
  3292. marks, even when the command with the same name has been mapped.
  3293.  
  3294. Some examples (given as you type them; e.g. the "^V" is CTRL-V which you 
  3295. type, but will not show up on the screen):
  3296.  
  3297.     :map g /foo^V^Mcwbar^V^[    (replace next "foo" by "bar")
  3298.     :map! qq quadrillion questions
  3299.  
  3300. Vim will compare what you type with the start of a mapped sequence. If there
  3301. is an incomplete match, it will get more characters until there either is a
  3302. complete match or until there is no match at all. Example: If you map! "qq",
  3303. the first <q> will not appear on the screen until you type another
  3304. character. This is because Vim cannot know if the next character will be a
  3305. <q> or not. If you set the 'timeout' option (which is the default) Vim will
  3306. only wait for one second (or as long as specified with the 'timeoutlen'
  3307. option). After that it assumes that the <q> is to be interpreted as such. If
  3308. type slowly, or your system is slow, reset the 'timeout' option. Then you
  3309. might want to set the 'ttimeout' option. See the "Options" chapter.
  3310.  
  3311. If you want to exchange the meaning of two keys you should use the :noremap 
  3312. command. For example:
  3313.     :noremap k j
  3314.     :noremap j k
  3315. This will exchange the cursor up and down commands. With the normal :map 
  3316. command, when the 'remap' option is set, mapping takes place until the text 
  3317. is found not to be a part of a {lhs}. For example, if you use:
  3318.     :map x y
  3319.     :map y x
  3320. Vim will replace x by y, and then y by x, etc. When this has happened 1000 
  3321. times, Vim will give an error message.
  3322.  
  3323. See the file "index" for keys that are not used and thus can be mapped 
  3324. without losing any builtin function.
  3325.  
  3326. If you include an undo command inside a mapped sequence, this will bring the 
  3327. text back in the state before executing the macro. This is compatible with 
  3328. the original vi, as long as there is only one undo command in the mapped 
  3329. sequence (having two undo commands in a mapped sequence did not make sense 
  3330. in the original vi, you would get back the text before the first undo).
  3331.  
  3332. There are two ways to map a function key:
  3333. 1. The vi-compatible method: Map the key code. Often this is a sequence that
  3334.    starts with <ESC>. To enter a mapping like this you type ":map " and then
  3335.    you have to type CTRL-V before hitting the function key.
  3336. 2. The second method is to use the internal code for the function key. To
  3337.    enter such a mapping just hit the function key, without CTRL-V, or use
  3338.    the form "#1", "#2", .. "#9", "#0". Only the first ten function keys can
  3339.    be used this way ("#0" refers to function key 10, defined with option
  3340.    't_f10', which may be function key zero on some keyboards).
  3341. The advantage of the second method is that the mapping will mostly work on
  3342. different terminals without modification (the function key will be
  3343. translated into the same internal code, no matter what terminal you are
  3344. using. The termcap must be correct for this to work, and you must use the
  3345. same mappings).
  3346.  
  3347. DETAIL: Vim first checks if a sequence from the keyboard is mapped. If it
  3348. isn't the terminal key codes are tried (see section 20.2). If a terminal
  3349. code is found it is replaced by the internal code. Then the check for a
  3350. mapping is done again (so you can map an internal code to something else).
  3351. What is written into the script file (.vim file) depends on what is
  3352. recognized. If the terminal key code was recognized as a mapping the key
  3353. code itself is written to the script file. If it was recognized as a
  3354. terminal code the internal code is written to the script file.
  3355.  
  3356.  
  3357.     18. Recovery after a crash.
  3358.  
  3359. You have spent several hours typing in that text that has to be finished
  3360. next morning, and then disaster strikes: Your computer crashes.
  3361.  
  3362.             DON'T PANIC!
  3363.  
  3364.  
  3365. 18.1 The autoscript file
  3366.  
  3367. Vim keeps track of everything you type. Using the original file you started
  3368. from and the autoscript file you can recover (almost) all of your work.
  3369.  
  3370. The name of the autoscript file is the same as the file you are editing, 
  3371. with the extension ".vim". On MSDOS machines and when the 'shortname' option 
  3372. is set, any <.> is replaced by <_>. If this file already exists (e.g. when 
  3373. you are recovering from a crash) a warning is given and another extension is 
  3374. used, ".vil", ".vik", etc. An existing file will never be overwritten. The 
  3375. autoscript file is deleted as soon as the edited text is successfully
  3376. written to disk.
  3377.  
  3378. Technical: The replacement of <.> by <_> is done to avoid problems with 
  3379.        MSDOS compatible filesystems (e.g. crossdos, multidos). If Vim is 
  3380.        able to detect that the file is on an MSDOS-like filesystem, a 
  3381.        flag is set that has the same effect as the 'shortname' option. 
  3382.        This flag is reset when you start editing another file.
  3383.  
  3384.        If the ".vim" filename already exists, the last character is 
  3385.        decremented until there is no file with that name or ".via" is 
  3386.        reached. In the last case, no autoscript file is created.
  3387.  
  3388. By setting the 'directory' option you can place the autoscript file in
  3389. another place than where the edited file is. The advantage is that you will
  3390. not pollute the directories with ".vim" files and, when the 'directory' is
  3391. on another partition, reduce the risc of damaging the file system where the
  3392. file is (in a crash). The tradeoff is that you can get name collisions from
  3393. files with the same name but in different directories. You can also use a
  3394. recoverable ram disk, but there is no 100% guarantee that this works.
  3395. Putting autoscript files in RAM: makes no sense, you will loose them in a
  3396. crash. Put a command resembling the following one in s:.exrc:
  3397.     :set dir=dh2:tmp
  3398. This is also very handy when editing files on floppy.
  3399.  
  3400. The autoscript file is updated after typing 100 characters or when you have 
  3401. not typed anything for two seconds. This only happens if the buffer was 
  3402. changed, not when you only moved around. The reason why it is not kept up to 
  3403. date all the time is that this would slow down normal work too much. You can 
  3404. change the 100 character count with the 'updatecount' option. You can set 
  3405. the time with the 'updatetime' option. The time is given in milliseconds.
  3406.  
  3407. If the writing to the autoscript file is not wanted, it can be switched off 
  3408. by setting the 'updatecount' option to 0. The same is done when starting Vim 
  3409. with the "-n" or "-v" option. Writing can be switched back on by setting the 
  3410. 'updatecount' option to non-zero. If you have changed the buffer when 
  3411. switching on, the autoscript file will be incomplete and recovery will 
  3412. probably fail. To avoid this write out the buffer with ":w" before switching 
  3413. on the autoscript file.
  3414.  
  3415.  
  3416. 18.2 Recovery
  3417.  
  3418. In most cases recovery is quite easy: Start Vim on the same file you were
  3419. editing when the crash happened, with the "-r" option added. Vim will start
  3420. editing the file using the key strokes in the autoscript file. Be sure that 
  3421. the recovery was successful before overwriting the original file or deleting 
  3422. the autoscript file. Once you are sure the recovery is ok, write out the
  3423. file with ":wq" and delete the autoscript ".vim" file. Otherwise, you will
  3424. continue to get warning messages that the ".vim" file already exists.
  3425.  
  3426. Example:    vim -r reference.doc
  3427.  
  3428. Important: The .exrc file must be the same as with the original edit session,
  3429. because some options have effect on the editing. Also the window size must be
  3430. exactly the same, because the cursor movement resulting from some commands
  3431. depends on the window size (e.g. CTRL-F). To help you with that the window
  3432. resizing events are written into the script file with ":winsize" commands. 
  3433. The result of this command is that Vim will resize the used part of the 
  3434. window, but the window itself will remain the same size. The commands will 
  3435. be executed correctly, but the window contents may look disturbed. During 
  3436. normal editing you should not use the ":winsize" command. Use the window 
  3437. resizing gadget of the window. Do not resize the window during recovery!
  3438.  
  3439. In some cases the "-r" option does not result in successful recovery. This
  3440. happens when you executed a command that cannot be reproduced anymore. For
  3441. example: Reading a file which does not exist anymore. In such a case the
  3442. succeeding commands probably only make things worse. To solve this you will 
  3443. have to edit the autoscript file and remove the commands that cause errors. 
  3444. If this becomes difficult try splitting up the autoscript file in small 
  3445. pieces. {Vi: recovers in another way that has a larger change to succeed but 
  3446. causes more overhead}
  3447.  
  3448. If the autoscript file does not end in ".vim" but in something else, you can
  3449. use the script reading option "-s {filename}". This will have (almost) the 
  3450. same effect as the "-r" option. This is also handy when the script file is 
  3451. in another directory than expected.
  3452.  
  3453. You can give the "-r" option in combination with the "-s scriptin" option. 
  3454. The scriptin file will be read first, then the autoscript file for recovery.
  3455.  
  3456. The difference between using the "-r" option and the "-s" option is that with
  3457. the "-r" option the name of the script file is made from the file name, and 
  3458. the last modification date is checked to see if the autoscript file is 
  3459. newer. This prevents the wrong autoscript file from being used for a
  3460. recovery.
  3461.  
  3462.  
  3463.     19. Options
  3464.  
  3465. Vi has a number of internal variables and switches which can be set to 
  3466. achieve special effects. These options come in three forms, those that are 
  3467. switches, which toggle from off to on and back, those that require a numeric 
  3468. value, and those that require an alphanumeric string value.
  3469.  
  3470.  
  3471. 19.1 Setting options
  3472.  
  3473. :se[t]            Show all modified options. {Vi: non-default options}
  3474.  
  3475. :se[t] all        Show all but terminal options.
  3476.  
  3477. :se[t] termcap        Show all terminal options.
  3478.  
  3479. :se[t] {option}        Set toggle option on, show value of string or number
  3480.             option.
  3481.  
  3482. :se[t] no{option}    Set toggle option off.
  3483.  
  3484. :se[t] inv{option}    Invert toggle option. {not in Vi}
  3485.  
  3486. :se[t] {option}={value} Set string or number option to {value}.
  3487.  
  3488. :se[t] {option}?    Show value of {option}.
  3489.  
  3490. The arguments to ":set" may be repeated. For example:
  3491. ":set ai nosi sw=3 ts=3". If you make an error in one of the arguments an 
  3492. error message will be given and the text up to the next space will be 
  3493. skipped. Thus following arguments will be processed.
  3494.  
  3495. An environment variable in most string options will be expanded. This
  3496. happens only when the string starts with a <$>. If the environment variable
  3497. exists the <$> and the following environment variable name is replaced by
  3498. its value. If it does not exist the <$> and the name are not modified. Any
  3499. non-id character (not a letter, digit or <_>) may follow the environment
  3500. variable name. That character and what follows is appended to the value of
  3501. the environemnt variable. Example:
  3502.     :set term=$TERM.new
  3503.  
  3504. Besides changing options with the ":set" command, there are four 
  3505. alternatives to set options automatically for one or more files. The first 
  3506. and second ones are used for all files. The third is used to set options for 
  3507. the files in one directory. The last is used to set options for a single 
  3508. file. The first three are done when you start Vim, in the given order. The 
  3509. last is done whenever you start editing a new file.
  3510.  
  3511. 1. The environment variable VIMINIT is read for an Ex command. You can set
  3512.    VIMINIT to something like "set noai sw=3" to set options.
  3513. 2. Only if there is no VIMINIT environment variable, the file 
  3514.    "s:.vimrc" is read for Ex commands. You can include set commands in this 
  3515.    file. (see below for how to automatically create a file with set commands).
  3516. 3. If VIMINIT is not found and "s:.vimrc" does not exist, EXINIT is used, 
  3517.    in the same way as VIMINIT.
  3518. 4. If VIMINIT is not found, "s:.vimrc" does not exist and EXINIT is not found, 
  3519.    the file "s:.exrc" is read for Ex commands.
  3520. 5. If the 'exrc' option is set, the file ".vimrc" in the current directory is 
  3521.    read for Ex commands. You can include set commands in this file. If this 
  3522.    file is not found the file ".exrc" is tried.
  3523. 6. If you start editing a new file, and the 'modeline' option is set, a
  3524.    number of lines at the beginning and end of the file are checked for the
  3525.    string "vi:", "vim:" or "ex:". The text after it is considered to be the
  3526.    arguments for a ":set" command, separated with colons or spaces. For
  3527.    example:
  3528.            "vi:noai:sw=3 ts=6"
  3529.    The number of lines that are checked can be set with the 'modelines'
  3530.    option. If 'modeline' is not set or 'modelines' is 0 no lines are
  3531.    checked.
  3532.    The string "vi:", "vim:" or "ex:" must be preceded with a blank or begin 
  3533.    at the start of a line. This minimizes the chance that a normal word like 
  3534.    "lex:" is caught.
  3535.    Note that all of the rest of the line is used, thus a line like:
  3536.            "/* vi:ts=4: */"
  3537.    will give an error message for the trailing "*/".
  3538.    If an error is detected the rest of the line is skipped.
  3539.    One other form of modelines is recognized that has the "set" command
  3540.    after "vi:", "vim:" or "ex:" (this is compatible with some versions of
  3541.    vi). In this case the characters up to the first <:> are executed as an
  3542.    ex command. Anything following it is ignored. Thus a line like:
  3543.            "/* vi:set ts=4: */"
  3544.    is OK. If you want to include a <:> in a set command precede it with a
  3545.    <\>.
  3546.  
  3547.  
  3548. 19.2 Saving settings
  3549.  
  3550. :mkexrc [file]        Write current key mappings and changed options to 
  3551.             [file] (default ".exrc"), unless it already exists. 
  3552.             {not in Vi}
  3553.  
  3554. :mkexrc! [file]        Always write current key mappings and changed 
  3555.             options to [file] (default ".exrc"). {not in Vi}
  3556.  
  3557. :mkvimrc[!] [file]    Same as :mkexrc, but default is ".vimrc". {not in 
  3558.             Vi}
  3559.  
  3560. These commands will write ":map" and ":set" commands to a file, in such a 
  3561. way that when these commands are executed, the current key mappings and 
  3562. options will be set again. A common method is to use a default ".exrc" file 
  3563. by first reading one in with ":source s:.exrc.Cprogs", change the settings 
  3564. and then save them in the current directory with ":mkexrc!".
  3565.  
  3566.  
  3567. 19.3 Options summary
  3568.  
  3569. In the list below all the options are mentioned with their full name and some
  3570. with an abbreviation between parens. Both forms may be used. In this
  3571. document when an option that can be toggled is "set" that means that ":set
  3572. option" is entered.  When an option is "reset", ":set nooption" is used.
  3573.  
  3574. autoindent (ai)        toggle    (default off)
  3575.     Copy indent from current line when starting a new line (typing <CR> 
  3576.     in Insert mode or when using the "o" or "O" command). If you do not 
  3577.     type anything on the new line except <BS> and then type <ESC> or 
  3578.     <CR>, the indent is deleted again. When autoindent is set, 
  3579.     formatting (with the "Q" command or when you reach 'textwidth' in 
  3580.     Insert mode) uses the indentation of the first line. The 'autoindent'
  3581.     option is reset when the 'paste' option is set.
  3582.  
  3583. autowrite (aw)        toggle    (default off)
  3584.     Write the contents of the file, if it has been modified, on each
  3585.     :next, :rewind, :previous, :stop, :suspend, :tag, :!, :make, CTRL-]
  3586.     and CTRL-^ command; and when a CTRL-O, CTRL-I, '<A-Z>, or `<A-Z>
  3587.     command takes one to another file.
  3588.  
  3589. backspace (bs)        number    (default 0)
  3590.     Influences the working of <BS>, <DEL>, CTRL-W and CTRL-U in Insert 
  3591.     mode. If set to 0 Vi compatible backspacing is used. When 1 allow 
  3592.     backspacing over newlines. When larger than 1 allow backspacing over 
  3593.     the start of insert. In the last case CTRL-W and CTRL-U stop once at 
  3594.     the start of insert. {not in Vi}
  3595.  
  3596. backup (bk)        toggle    (default on)
  3597.     Make a backup before overwriting a file. Leave it around after the 
  3598.     file has been succesfully written. If you do not want to keep the 
  3599.     backup file, but you do want a backup while the file is being
  3600.     written, reset this option and set the 'writebackup' option. If you
  3601.     do not want a backup file at all reset both options (See the table
  3602.     in section 5.4 for another explanation.). {not in Vi}
  3603.  
  3604. backupdir (bdir)    string    (default "$HOME")
  3605.     For Unix systems only. Name of the directory where the backup file 
  3606.     is put when it cannot be created in the same directory as the 
  3607.     original file. Environment variables are expanded. {not in Vi}
  3608.  
  3609. binary (bin)        toggle    (default off)
  3610.     This option should be set before editing a binary file. You can also
  3611.     use the "-b" command line option. When this option is set the
  3612.     'textwidth' option will set to 0, the 'textmode' and 'textauto'
  3613.     options will be reset and 'modelines' will be set to 0. When writing
  3614.     a file the end-of-line for the last line is only written if there
  3615.     was one in the original file (normally Vim appends an end-of-line to
  3616.     the last line if there is none; this would make the file longer).
  3617.  
  3618. bioskey (bk)        toggle    (default on)
  3619.     For MSDOS only: When set the bios is called to obtain a keyboard
  3620.     character. This works better to detect CTRL-C, but only works for
  3621.     the console. When using a terminal over a serial port reset this
  3622.     option. {not in Vi}
  3623.  
  3624. columns            number    (default 80 or terminal width)
  3625.     Number of columns in the display. Normally this is set by the 
  3626.     terminal initialization and does not have to be set by hand. {not in 
  3627.     Vi}
  3628.  
  3629. compatible (cp)        toggle    (default off)
  3630.     At the moment this option is set, several other options will be set 
  3631.     or reset to make Vim vi-compatible. Switching this option off has no 
  3632.     effect. {not in Vi}
  3633.  
  3634.     option        new value    effect
  3635.  
  3636.     backspace    0        normal backspace
  3637.     backup        off        no backup file
  3638.     digraph        off        no digraphs
  3639.     esckeys        off        no <ESC>-keys in Insert mode
  3640.     expandtab    off        tabs not expanded to spaces
  3641.     history        0        no commandline history
  3642.     insertmode    off        do not start in Insert mode
  3643.     joinspaces    on        insert 2 spaces after period
  3644.     modelines    0        no modelines
  3645.     revins        off        no reverse insert
  3646.     ruler        off        no ruler
  3647.     scrolljump    0        no jump scroll
  3648.     shiftround    off        indent not rounded to shiftwidth
  3649.     showcmd        off        command characters not shown
  3650.     showmode    off        current mode not shown
  3651.     smartindent    off        no smart indentation
  3652.     textauto    off        no automatic textmode detection
  3653.     textwidth    0        no automatic line wrap
  3654.     tildeop        off        tilde is not an operator
  3655.     ttimeout    off        no terminal timeout
  3656.     undolevels    0        no multilevel undo
  3657.     updatecount    0        no autoscript file
  3658.     writebackup    off        no backup file written
  3659.     yankendofline    off        do not Yank to end of line
  3660.  
  3661. digraph (dg)        toggle    (default off)
  3662.     Enable the entering of digraphs in Insert mode with {char1} <BS> 
  3663.     {char2}. Only works if Vim was compiled with digraphs enabled. {not 
  3664.     in Vi}
  3665.  
  3666. directory (dir)        string    (default "")
  3667.     Directory for the autoscript file. Empty means in same directory as 
  3668.     the edited file. The name may end in an <:> or </>. Environment
  3669.     variables are expanded. Carefeful with <\> characters, type two to
  3670.     get one in the option, ":set dir=c:\\tmp". {Vi: directory to put
  3671.     temp file in, defaults to "/tmp"}
  3672.  
  3673. equalprg (ep)        string    (default "indent")
  3674.     External program to use for "=" command. Environment variables are
  3675.     expanded. {not in Vi}
  3676.  
  3677. errorbells (eb)        toggle    (default off)
  3678.     Ring the bell for error messages. Does not work on the Amiga, you 
  3679.     always get a screen flash.
  3680.  
  3681. errorfile (ef)        string    (default "AztecC.Err" or "errors")
  3682.     Name of the error file for the QuickFix mode (see 5.5). Environment
  3683.     variables are expanded. {not in Vi}
  3684.  
  3685. errorformat (efm)    string    (default "%f>%l:%c:%t:%n:%m" or
  3686.                         ""%f",%*[^0-9]%l %m")
  3687.     Scanf-like description of the format for the lines in the error file
  3688.     (see 5.5). {not in Vi}
  3689.  
  3690. esckeys (ek)        toggle    (default on)
  3691.     Function keys that start with an <ESC> are recognized in Insert
  3692.     mode. When this option is off, the cursor and function keys cannot be
  3693.     used in Insert mode if they start with an <ESC>. The advantage of this
  3694.     is that the single <ESC> is recognized immediately, instead of after
  3695.     one second.
  3696.  
  3697. expandtab (et)        toggle    (default off)
  3698.     In Insert mode: Use the appropriate number of spaces to insert a 
  3699.     <TAB>. Spaces are used in indents with the '>' and '<' commands and
  3700.     when 'autoindent' is set. To insert a real tab when expandtab is
  3701.     set, use CTRL-V<TAB>. {not in Vi}
  3702.  
  3703. exrc            toggle (default off)
  3704.     Enables the reading of .vimrc and .exrc in the current directory. If
  3705.     you switch this option on you should also consider setting the
  3706.     'secure' option (see 3.4). {not in Vi}
  3707.  
  3708. formatprg (fp)        string (default "")
  3709.     The name of an external program that will be used to format the
  3710.     lines selected with the "Q" command. The program must take the input
  3711.     on stdin and produce the output on stdout. The unix program 'fmt' is
  3712.     such a program. If this option is an empty string, the internal
  3713.     format function will be used. Environment variables are expanded.
  3714.     {not in Vi}
  3715.  
  3716. graphic (gr)        toggle    (default off, MSDOS: on)
  3717.     When off characters between <~> and 0xa0 are displayed as "~?", 
  3718.     "~@", "~A", etc.. When on the characters are sent to the display 
  3719.     directly. This will allow for graphic characters to be shown on some 
  3720.     terminals (e.g. MSDOS console) and mess up the display on others 
  3721.     (e.g. Amiga).
  3722.  
  3723. helpfile (hf)        string    (default (Amiga) "vim:vim.hlp"
  3724.                      (unix) "/usr/local/lib/vim.hlp")
  3725.     Name of the help file. It may start with an environment variable. 
  3726.     For example: "$VIM/doc/vim.hlp". Environment variables are expanded.
  3727.     {not in Vi}
  3728.  
  3729. history (hi)        number    (default 20)
  3730.     Number of command lines that are remembered. {not in Vi}
  3731.  
  3732. ignorecase (ic)        toggle    (default off)
  3733.     Ignore case in search patterns.
  3734.  
  3735. insertmode (im)        toggle    (default off)
  3736.     Start the edit of a file in Insert mode. {not in Vi}
  3737.  
  3738. joinspaces (js)        toggle    (default on)
  3739.     Insert two spaces after a period with a join command. {not in Vi}
  3740.  
  3741. keywordprg (kp)        string    (default "ref")
  3742.     Program to use for the "K" command. Environment variables are
  3743.     expanded. {not in Vi}
  3744.  
  3745. lines            number    (default 24 or terminal height)
  3746.     Number of lines in the display. Normally you don't need to set this. 
  3747.     That is done automatically by the terminal initialization code.
  3748.  
  3749. list            toggle    (default off)
  3750.     List mode: Show tabs as CTRL-I, show end of line with $. Useful to 
  3751.     see the difference between tabs and spaces and for trailing blanks.
  3752.  
  3753. magic            toggle    (default on)
  3754.     Changes the special characters that can be used in search patterns. 
  3755.     See section "Pattern searches".
  3756.  
  3757. makeprg (mp)        string    (default "make")
  3758.     Program to use for the ":make" command. This option may contain
  3759.     <%> and <#> characters, which are expanded like when used in a
  3760.     command line. Environment variables are expanded. {not in Vi}
  3761.  
  3762. modeline (ml)        toggle    (default on)
  3763. modelines (mls)        number    (default 5)
  3764.     If 'modeline' is set 'modelines' gives the number of lines that is
  3765.     checked for set commands. If 'modeline' is not set or 'modelines' is
  3766.     0 no lines are checked. See 19.1. {not in Vi}
  3767.  
  3768. number (nu)        toggle    (default off)
  3769.     Print the line number in front of each line.
  3770.  
  3771. paragraphs (para)    string    (default "IPLPPPQPP LIpplpipbp")
  3772.     Specifies the nroff macros that separate paragraphs. These are pairs 
  3773.     of two letters (see section 6.4).
  3774.  
  3775. paste            toggle    (default off)
  3776.     Put Vim in Paste mode. This is useful if you want to cut or copy
  3777.     some text from one window and paste it in Vim. This will avoid
  3778.     unexpected effects. When the 'paste' option is set mapping in Insert
  3779.     mode is disabled, abbreviations are disabled and some options are
  3780.     reset ('textwidth', 'autoindent', 'smartindent', 'revins', 'ruler'
  3781.     and 'showmatch'). When the 'paste' option is reset the mentioned
  3782.     options are restored to the value before the last time 'paste' was
  3783.     set. If you use this often, you could map a function key to the
  3784.     command ":set invpaste^V^M". {not in Vi}
  3785.  
  3786. readonly (ro)        toggle    (default off)
  3787.     If set, writes fail unless you use an !. Protects you from
  3788.     accidentally overwriting a file. Also, sets 'updatecount' to zero so
  3789.     that no ".vim" autoscript file is created. Default on when vim is
  3790.     started in view mode ("vim -v") or when the executable is called
  3791.     "view". It is reset if you overwrite the current file (e.g. with
  3792.     ":w!"). WARNING: An edit session that starts with 'noreadonly' won't
  3793.     be protected with a .vim autoscript file unless 'updatecount' is set
  3794.     back to some non-zero number (e.g. 100).
  3795.  
  3796. remap            toggle    (default on)
  3797.     Allows for :map command to work recursively. If you do not want this 
  3798.     for a single entry, use the :noremap[!] command.
  3799.  
  3800. report            number    (default 2)
  3801.     Threshold for reporting number of lines changed.
  3802.  
  3803. revins            toggle    (default off)
  3804.     Inserting characters in Insert mode will work backwards. See "typing
  3805.     backwards". Can be toggled with the CTRL-P command in Insert mode.
  3806.     This option is reset when 'compatible' or 'paste' is set. {not in Vi}
  3807.  
  3808. ruler (ru)        toggle    (default off)
  3809.     Show the line and column number of the cursor position in the status
  3810.     line, separated by a comma. If there are characters in the line that
  3811.     take two positions on the screen, both the "real" column and the
  3812.     screen column are shown, separated with a dash. This option is reset
  3813.     when the 'paste' option is set. {not in Vi}
  3814.  
  3815. secure            toggle    (default off)
  3816.     When on, shell and write commands are not allowed in ".vimrc" and 
  3817.     ".exrc" in the current directory and map commands are displayed.
  3818.     Switch it off only if you know that you will not run into problems,
  3819.     or when the 'exrc' option is off.
  3820.  
  3821. scroll            number    (default 'lines' / 2)
  3822.     Number of lines to scroll with CTRL-U and CTRL-D commands. Will be
  3823.     set to half the number of lines in the window when the window size
  3824.     changes. If you give a count to the CTRL-U or CTRL-D command it will
  3825.     be used as the new value for 'scroll'. Reset to 'lines' / 2 with
  3826.     ":set scroll=0".
  3827.  
  3828. scrolljump        number    (default 1)
  3829.     Minimal number of lines to scroll when the cursor gets off the 
  3830.     screen (e.g. with "j"). Not used for scroll commands (e.g. CTRL-E, 
  3831.     CTRL-D). Useful if your terminal scrolls very slowly. {not in Vi}
  3832.  
  3833. sections (sect)        string    (default "SHNHH HUnhsh")
  3834.     Specifies the nroff macros that separate sections. These are pairs of
  3835.     two letters (See section 6.4).
  3836.  
  3837. shell (sh)        string    (default $SHELL or "sh", MSDOS: "command")
  3838.     Name of the shell to use for ! and :! commands. See also the
  3839.     'shelltype' option. It is allowed to give an argument to the 
  3840.     command, e.g. "csh -f". If you type this in the command line you 
  3841.     will have to put a backslash in front of the space. Environment
  3842.     variables are expanded.
  3843.  
  3844. shelltype (st)        number    (default 0)
  3845.     On the Amiga this option influences the way how the commands work 
  3846.     which use a shell.
  3847.     0 and 1: always use the shell
  3848.     2 and 3: use the shell only to filter lines
  3849.     4 and 5: use shell only for ':sh' command
  3850.     When not using the shell, the command is executed directly.
  3851.  
  3852.     0 and 2: use 'shell -c cmd' to start external commands
  3853.     1 and 3: use 'shell cmd' to start external commands
  3854.  
  3855. shiftround (sr)        toggle    (default off)
  3856.     Round indent to multiple of shiftwidth. Applies to > and < commands 
  3857.     and to CTRL-T and CTRL-D in Insert mode. {not in Vi}
  3858.  
  3859. shiftwidth (sw)        number    (default 8)
  3860.     Number of spaces to use for (auto)indent.
  3861.  
  3862. shortname (sn)        toggle    (default off)
  3863.     Filenames can be 8 characters plus one extension of 3 characters. 
  3864.     Multiple dots in file names are not allowed. When this option is on, 
  3865.     dots in filenames are replaced by underscores when adding an 
  3866.     extension (".bak" or ".vim"). This option is not available for 
  3867.     MSDOS, because then it would always be on. This option is useful 
  3868.     when editing files on an MSDOS compatible filesystem, e.g. messydos 
  3869.     or crossdos. {not in Vi}
  3870.  
  3871. showcmd (sc)        toggle    (default on, off for unix)
  3872.     show command in status line. Set this option off if your terminal 
  3873.     is slow. {not in Vi}
  3874.  
  3875. showmatch (sm)        toggle    (default off)
  3876.     When a bracket is inserted, briefly jump to the matching one. This
  3877.     option is reset when the 'paste' option is set.
  3878.  
  3879. showmode (smd)        toggle    (default on)
  3880.     If in Insert or Replace mode, put a message on the last line.
  3881.  
  3882. sidescroll (ss)        number    (default 0)
  3883.     The minimal number of columns to scroll horizontally. Used only when
  3884.     the 'wrap' option is on and the cursor is moved off of the screen.
  3885.     When set to zero the cursor will be put in the middle of the screen.
  3886.     When using a slow terminal set it to a large number or 0. When using
  3887.     a fast terminal use a small number or 1. {not in Vi}
  3888.  
  3889. smartindent (si)    toggle    (default off)
  3890.     Do smart autoindenting for C programs in Insert mode and with the
  3891.     "o" and "O" commands. An indent is automatically inserted:
  3892.     - After a line ending in <{>.
  3893.     - After a line starting with "if", "for", "while", "else" or "do".
  3894.       If you type a <{> as the first character in the new line, the
  3895.       indent is deleted. 
  3896.     - Before a line starting with <}> (only with the "O" command).
  3897.     One indent is deleted when typing <}> as the first character in a
  3898.     new line.
  3899.     'smartindent' is reset when the 'paste' option is set. {not in Vi}
  3900.  
  3901. suffixes (su)        string    (default ".bak.o.h.info.vim")
  3902.     Files with these suffixes are ignored when multiple files match a
  3903.     wildcard. {not in Vi}
  3904.  
  3905. tabstop (ts)        number    (default 8)
  3906.     Number of spaces that a <TAB> in the file counts for.
  3907.  
  3908. taglength (tl)        number    (default 0)
  3909.     If non-zero, tags are significant up to this number of characters.
  3910.  
  3911. tags            string    (default "tags")
  3912.     Filenames for the tag command, separated by spaces. Environment
  3913.     variables are expanded for the first name. {Vi: default is "tags
  3914.     /usr/lib/tags"}
  3915.  
  3916. term            string    (default $TERM or "amiga" on Amiga, "pcterm"
  3917.                     on MSDOS)
  3918.     Name of the terminal. Used for choosing the terminal control 
  3919.     characters. Environment variables are expanded.
  3920.  
  3921. terse            toggle    (default on)
  3922.     Ignored. {Vi: shorten the error messages}
  3923.  
  3924. textauto (ta)        toggle    (default on)
  3925.     When a new file is edited the first line is checked for the line
  3926.     separator. If it is a single <LF> 'textmode' is reset. If it is a
  3927.     <CR><LF> pair 'textmode' is set.
  3928.  
  3929. textmode (tx)        toggle    (MSDOS: default on, others: default off)
  3930.     When off, <LF> separates lines. When on, <CR><LF> separates lines.
  3931.     Only used when reading and writing files. Set automatically when
  3932.     reading a file and 'textauto' is on.
  3933.  
  3934. textwidth        number    (default 0)
  3935.     Maximum width of text that is being inserted. A longer line will be
  3936.     broken after white space to get this width. A zero value disables
  3937.     this. 'textwidth' is set to 0 when the 'paste' option is set. If
  3938.     'wrapmargin' is set to non-zero, textwidth is set to
  3939.     ('columns' - 'wrapmargin'). {not in Vi} 
  3940.  
  3941. tildeop (to)        toggle    (default off)
  3942.     The tilde command <~> behaves like an operator. {not in Vi}
  3943.  
  3944. timeout            toggle (default on)
  3945. ttimeout        toggle (default off)
  3946.     These two options together determine the behaviour when part of a 
  3947.     mapped key sequence or keyboard code has been received:
  3948.  
  3949.     timeout        ttimeout    action
  3950.     off        off        no time out
  3951.     on        on or off    time out on :mappings and key codes
  3952.     off        on        time out on key codes
  3953.  
  3954.     If there is no time out, Vim will wait until either the complete 
  3955.     mapping or key sequence has been received, or it is clear that there 
  3956.     is no mapping or key sequence for the received characters. For 
  3957.     example: if you have mapped "vl" and Vim has received <v>, the next 
  3958.     character is needed to see if the <v> is followed by an <l>. With a 
  3959.     time out Vim will wait for about 1 second for the next character to 
  3960.     arrive. After that the already received characters are interpreted
  3961.     as single characters. The time can be set with the 'timeoutlen'
  3962.     option.
  3963.     On slow terminals or very busy systems time out may cause 
  3964.     malfunctioning cursor keys. If both options are off, Vim waits 
  3965.     forever after an entered <ESC> if there are key codes that start 
  3966.     with <ESC>. You will have to type <ESC> twice. If you do not have 
  3967.     problems with key codes, but would like to have :mapped key 
  3968.     sequences not time out in 1 second, set the ttimeout option and 
  3969.     reset the timeout option. {the ttimeout option is not in Vi}
  3970.  
  3971. timeoutlen (tm)        number    (default 1000)
  3972.     The time in milliseconds that is waited for a key code or mapped key
  3973.     sequence to complete. {only in some versions of Vi}
  3974.  
  3975. undolevels (ul)        number    (default 100)
  3976.     Maximum number of changes that can be undone. Set to 0 for Vi 
  3977.     compatibility: one level of undo and 'u' undoes itself. Set to a
  3978.     negative number for no undo at all (saves memory). {not in Vi}
  3979.  
  3980. updatecount (uc)    number    (default 100)
  3981.     After this many characters typed the auto script file will be written
  3982.     to disk. When zero the auto script will not be written to at all (see
  3983.     chapter on recovery). {not in Vi}
  3984.  
  3985. updatetime (ut)        number    (default 2000)
  3986.     If this many milliseconds nothing is typed the auto script file will 
  3987.     be written to disk (see chapter on recovery). {not in Vi}
  3988.  
  3989. visualbell (vb)        toggle    (default off)
  3990.     Use (sort of) visual bell for AUX device. {not in Vi}
  3991.  
  3992. warn            toggle    (default on)
  3993.     Give a warning message when a shell command is used while the buffer
  3994.     has been changed.
  3995.  
  3996. wildchar (wc)        number    (default <TAB> or CTRL-E)
  3997.     Character you have to type to start wildcard expansion in the 
  3998.     command line. CTRL-E is used when Vim was compiled with COMPATIBLE 
  3999.     or when the 'compatible' option is set. The character is not
  4000.     recognized when used inside a macro. {not in Vi}
  4001.  
  4002. wrap            toggle    (default on)
  4003.     When on, long lines will wrap and continue on the next line. When
  4004.     off long lines will not wrap and only part of them will be shown.
  4005.     When the cursor is moved to a part that is not shown, the screen
  4006.     will scroll horizontally (also see 'sidescroll' option. {not in Vi}
  4007.  
  4008. wrapmargin (wm)        number    (default 0)
  4009.     Number of characters from the right window border where wrapping
  4010.     starts. In Vim this is implemented by setting textwidth to the window
  4011.     width minus the wrapmargin. {Vi: works differently and less useful}
  4012.  
  4013. wrapscan (ws)        toggle    (default on)
  4014.     Searches wrap around the end of the file.
  4015.  
  4016. writeany (wa)        toggle    (default off)
  4017.     Allows writing to any file with no need for "!" override.
  4018.  
  4019. writebackup (wb)    toggle    (default on)
  4020.     Make a backup before overwriting a file. The backup is removed after 
  4021.     the file was succesfully written, unless the 'backup' option is also 
  4022.     on. {not in Vi}
  4023.  
  4024. yankendofline (ye)    toggle    (default off)
  4025.     The Y command yanks from the cursor until the end of the line instead
  4026.     of whole lines. {not in Vi}
  4027.  
  4028.  
  4029.     20. Terminal information
  4030.  
  4031. Vim uses information about the terminal you are using to fill the screen and 
  4032. recognize what keys you hit. If this information is not correct the screen 
  4033. may be messed up or keys may not be recognized. The actions which have to be 
  4034. performed on the screen are accomplished by outputting a string of
  4035. characters. Special keys produce a string of characters. These strings are 
  4036. stored in the terminal options, see section 20.2.
  4037.  
  4038.  
  4039. 20.1 startup
  4040.  
  4041. When Vim is started a default terminal type is assumed. For the Amiga this 
  4042. is a standard CLI window, for MSDOS the pc terminal, for Unix an ansi 
  4043. terminal. A few other terminal types are always available. Use the command 
  4044. "set term=xxx" to find out which ones are builtin.
  4045.  
  4046. You can give the terminal name with the '-T' command line option. If it is 
  4047. not given Vim will try to get the name from the TERM environment variable.
  4048.  
  4049. On Unix the termcap file is used. On Amiga and MSDOS this is only available 
  4050. if Vim was compiled with TERMCAP defined. If the termcap code is included 
  4051. Vim will try to get the strings for the terminal you are using from the 
  4052. termcap file.
  4053.  
  4054. For normal editing the terminal will be put into "raw" mode. The strings 
  4055. defined with 't_ts' and 't_ks' will be sent to the terminal. Normally this 
  4056. puts the terminal in a state where the termcap codes are valid and activates 
  4057. the cursor and function keys. When Vim exits the terminal will be put back 
  4058. into the mode it was before Vim started. The strings defined with 't_te' and 
  4059. 't_ke' will be sent to the terminal. On the Amiga with commands that print 
  4060. multiple lines at the bottom of the screen or execute an external command 
  4061. (e.g. "!!", ":files") the terminal will be put into normal mode for a 
  4062. moment. This means that you can stop the output to the screen by hitting a 
  4063. printing key. Output resumes when you hit <BS>.
  4064.  
  4065. Some termcap entries are wrong in the sense that after sending 't_ks' the 
  4066. cursor keys send codes different from the codes defined in the termcap. To 
  4067. avoid this you can set 't_ks' (and 't_ke') to empty strings. This must be
  4068. done during initialization (see 3.4), otherwise its too late.
  4069.  
  4070. Some termcap entries assume that the highest bit is always reset. For 
  4071. example: The cursor-up entry for the amiga could be ":ku=\EA:". But the 
  4072. Amiga really sends "\233A". This works fine if the highest bit is reset, 
  4073. e.g. when using an Amiga over a serial line. If the cursor keys don't work, 
  4074. try the entry ":ku=\233A:".
  4075.  
  4076. Some termcap entries have the entry ":ku=\E[A:". But the Amiga really sends 
  4077. "\233A". On output "\E[" and "\233" are often equivalent, on input they 
  4078. aren't. You will have to change the termcap entry, or change the key code 
  4079. with the :set command to fix this.
  4080.  
  4081. Many cursor key codes start with an <ESC>. Vim must find out if this a 
  4082. single hit of the <ESC> key or the start of a cursor key sequence. It waits 
  4083. for a next character to arrive. If it does not arrive within one second a 
  4084. single <ESC> is assumed. On very slow systems this may fail, causing cursor 
  4085. keys not to work sometimes. If you discover this problem reset the 'timeout' 
  4086. option. Vim will wait for the next character to arrive after an <ESC>. If 
  4087. you want to enter a single <ESC> you must type it twice. Resetting the
  4088. 'esckeys' option avoids this problems in Insert mode, but you lose the
  4089. possibility to use cursor and function keys in Insert mode.
  4090.  
  4091. On the Amiga the recognition of window resizing is activated only when the 
  4092. terminal name is "amiga" or "builtin_amiga".
  4093.  
  4094. Some terminals have confusing codes for the cursor keys. The televideo 925
  4095. is such a terminal. It sends a CTRL-H for cursor-left. This would make it
  4096. impossible to distinguish a backspace and cursor-left. To avoid this problem
  4097. CTRL-H is never recognized as cursor-left.
  4098.  
  4099.  
  4100. 20.2 terminal options
  4101.  
  4102. The terminal options can be set just like normal options. But they are not
  4103. shown with the ":set all" command. Instead use ":set termcap".
  4104.  
  4105. It is always possible to change individual strings by setting the 
  4106. appropriate option. For example:
  4107.  
  4108.     :set t_el=^V^[[K    (CTRL-V, ESC, [, K)
  4109.  
  4110. {Vi: no terminal options. You have to exit vi, edit the termcap entry and
  4111. try again}
  4112.  
  4113. The options are listed below along with the associated termcap code. Two of
  4114. them are required: Cursor positioning and clear screen. The others are used
  4115. to minimize the screen updating overhead and to recognize special keys.
  4116.  
  4117.  
  4118.     option    termcap        meaning
  4119.  
  4120. OUTPUT CODES
  4121.     t_name    (name)    name of current terminal entry
  4122.     t_el    ce    clear to end of line
  4123.     t_il    al    add new blank line
  4124.     t_cil    AL    add number of blank lines
  4125.     t_dl    dl    delete line
  4126.     t_cdl    DL    delete number of lines
  4127.     t_ed    cl    clear screen (required!)
  4128.     t_ci    vi    cursur invisible
  4129.     t_cv    ve    cursur visible
  4130.     t_tp    me    normal mode
  4131.     t_tp    se    shift-out end (if 'mr' or 'me' not defined)
  4132.     t_ti    mr    reverse mode
  4133.     t_ti    so    shift-out mode (if 'mr' or 'me' not defined)
  4134.     t_cm    cm    cursor motion (required!)
  4135.     t_sr    sr    scroll reverse (backward)
  4136.     t_cri    RI    cursor number of chars right
  4137.     t_vb    vb    visual bell
  4138.     t_ks    ks    put terminal in "keypad transmit" mode
  4139.     t_ke    ke    out of "keypad transmit" mode
  4140.     t_ts    ti    put terminal in "termcap" mode
  4141.     t_te    te    out of "termcap" mode
  4142.  
  4143. KEY CODES
  4144.     t_ku    ku    arrow up
  4145.     t_kd    kd    arrow down
  4146.     t_kr    kr    arrow right
  4147.     t_kl    kl    arrow left
  4148.     t_sku    (none)    shift arrow up
  4149.     t_skd    (none)    shift arrow down
  4150.     t_skr    %i    shift arrow right
  4151.     t_skl    #4    shift arrow left
  4152.     t_f1    k1    function key 1
  4153.     t_f2    k2    function key 2
  4154.     t_f3    k3    function key 3
  4155.     t_f4    k4    function key 4
  4156.     t_f5    k5    function key 5
  4157.     t_f6    k6    function key 6
  4158.     t_f7    k7    function key 7
  4159.     t_f8    k8    function key 8
  4160.     t_f9    k9    function key 9
  4161.     t_f10    k;    function key 10
  4162.     t_sf1    F1    function key 11 or shifted function key 1
  4163.     t_sf2    F2    function key 12 or shifted function key 2
  4164.     t_sf3    F3    function key 13 or shifted function key 3
  4165.     t_sf4    F4    function key 14 or shifted function key 4
  4166.     t_sf5    F5    function key 15 or shifted function key 5
  4167.     t_sf6    F6    function key 16 or shifted function key 6
  4168.     t_sf7    F7    function key 17 or shifted function key 7
  4169.     t_sf8    F8    function key 18 or shifted function key 8
  4170.     t_sf9    F9    function key 19 or shifted function key 9
  4171.     t_sf10    FA    function key 20 or shifted function key 10
  4172.     t_help    %1    help key
  4173.     t_undo    &8    undo key
  4174.  
  4175. Note for xterm users: The shifted cursor keys normally don't work. You can
  4176.     make them work with the xmodmap command and some mappings in Vim.
  4177.  
  4178.     Give these commands in the xterm:
  4179.         xmodmap -e "keysym Up = Up F16"
  4180.         xmodmap -e "keysym Down = Down F17"
  4181.         xmodmap -e "keysym Left = Left F18"
  4182.         xmodmap -e "keycode Right = Right F19"
  4183.  
  4184.     And use these mappings in Vim:
  4185.         :map CTRL-V 151 CTRL-V 132
  4186.         :map! CTRL-V 151 CTRL-V 132
  4187.         :map CTRL-V 152 CTRL-V 133
  4188.         :map! CTRL-V 152 CTRL-V 133
  4189.         :map CTRL-V 153 CTRL-V 134
  4190.         :map! CTRL-V 153 CTRL-V 134
  4191.         :map CTRL-V 154 CTRL-V 135
  4192.         :map! CTRL-V 154 CTRL-V 135
  4193.  
  4194. Where 151-154 are the internal vim decimal codes for function keys F16 to
  4195. F19 and 132-135 are the codes for the shifted arrow keys.
  4196.  
  4197.  
  4198. 20.3 Window size
  4199.  
  4200. If you are running Vim on an Amiga and the terminal name is "amiga" or 
  4201. "builtin_amiga", the amiga-specific window resizing will be enabled. On Unix 
  4202. systems three methods are tried to get the window size:
  4203.  
  4204. - an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
  4205. - the environment variables "LINES" and "COLUMNS"
  4206. - from the termcap entries "li" and "co"
  4207.  
  4208. If everything fails a default size of 24 lines and 80 columns is assumed. If 
  4209. a window-resize signal is received the size will be set again. If the window 
  4210. size is wrong you can use the 'lines' and 'columns' options to set the 
  4211. correct values.
  4212.  
  4213.  
  4214. 20.4 slow and fast terminals
  4215.  
  4216. If you have a fast terminal you may like to set the 'ruler' option. The 
  4217. cursor position is shown in the status line. If you are using horizontal
  4218. scrolling ('wrap' option off) consider setting 'sidescroll' to a small
  4219. number. 
  4220.  
  4221. If you have a slow terminal you may want to reset the 'showcmd' option. 
  4222. The command characters will not be shown in the status line. If the terminal 
  4223. scrolls very slowly, set the 'scrolljump' to 5 or so. If the cursor is moved
  4224. off the screen (e.g. with "j") Vim will scroll 5 lines at a time. Another
  4225. possibility is to reduce the number of lines that Vim uses with the command
  4226. "z<height><CR>".
  4227.  
  4228. If the characters from the terminal are arriving with more than 1 second 
  4229. between them you might want to set the 'timeout' and/or 'ttimeout' option. 
  4230. See the "Options" chapter.
  4231.  
  4232.  
  4233.     21. Differences from Vi and Ex
  4234.  
  4235. This chapter only lists what has not been mentioned in previous chapters.
  4236. Also see "difference.doc".
  4237.  
  4238. 21.1 Missing commands
  4239.  
  4240. A large number of the "Ex" commands (the commands that start with a colon) 
  4241. are included. However, there is no Ex mode. 
  4242.  
  4243. These commands are in Vi, but not in Vim.
  4244.  
  4245. Q            {Vi: go to Ex mode}
  4246.  
  4247. :a[ppend]        {Vi: append text}
  4248. :c[hange]        {Vi: replace lines}
  4249. :i[nsert]        {Vi: insert text}
  4250. :o[pen]            {Vi: start editing in open mode}
  4251. :pres[erve]        {Vi: emergency exit}
  4252. :rec[over]        {Vi: recover a file after a crash or :preserve}
  4253. :z            {Vi: print some lines}
  4254. :~            {Vi: do a substitute on the previous regular
  4255.             expression}
  4256.  
  4257.  
  4258. 21.2 Missing options
  4259.  
  4260. These options are in the unix Vi, but not in Vim. If you try to set them you 
  4261. won't get an error message, but their value cannot be printed.
  4262.  
  4263. autoprint (ap)        toggle    (default on)
  4264. beautify (bf)        toggle    (default off)
  4265. edcompatible        toggle    (default off)
  4266. hardtabs (ht)        number    (default 8)
  4267.     number of spaces that a <TAB> moves on the display
  4268. lisp            toggle    (default off)
  4269. mesg            toggle    (default on)
  4270. open            toggle    (default on)
  4271. optimize (op)        toggle    (default on)
  4272. prompt            toggle    (default on)
  4273. redraw            toggle    (default off)
  4274. slowopen (slow)        toggle    (default off)
  4275. sourceany        toggle    (default not documented)
  4276. ttytype            string
  4277. window            number    (default 24)
  4278. w300            number    (default 24)
  4279. w1200            number    (default 24)
  4280. w9600            number    (default 24)
  4281.  
  4282.  
  4283.     22. Credits
  4284.  
  4285. Parts of this manual comes from several Vi manuals, written by:
  4286.     W.N. Joy
  4287.     Alan P.W. Hewett
  4288.     Mark Horton
  4289.  
  4290. The editor Vim is based on Stevie and includes (ideas from) other software,
  4291. worked on by:
  4292.     Tim Thompson        Stevie
  4293.     Tony Andrews        Stevie
  4294.     G. R. (Fred) Walter    Stevie
  4295.     Henry Spencer        regular expressions
  4296.     Steve Kirkendall    Elvis
  4297.     Juergen Weigert        Lattice version, AUX improvements, UNIX and 
  4298.                 MSDOS ports
  4299.     Olaf Seibert        DICE version and regexp improvements
  4300.     Peter da Silva        termlib
  4301.  
  4302. I must thank all the people that sent me bug reports and suggestions. 
  4303. They keep Vim alive!
  4304. vi:tw=76:ts=8:sw=8
  4305.