home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / textedit / vim.zip / REFERENC.DOC < prev    next >
Text File  |  1993-04-08  |  139KB  |  3,435 lines

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