home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume37 / vim / part22 < prev    next >
Encoding:
Text File  |  1993-04-23  |  51.1 KB  |  1,260 lines

  1. Newsgroups: comp.sources.misc
  2. From: mool@oce.nl (Bram Moolenaar)
  3. Subject: v37i022:  vim - Vi IMitation editor v1.27, Part22/24
  4. Message-ID: <1993Apr25.013900.23433@sparky.imd.sterling.com>
  5. X-Md4-Signature: c67e6af7711a2f25d375d4af82fe3cf4
  6. Date: Sun, 25 Apr 1993 01:39:00 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: mool@oce.nl (Bram Moolenaar)
  10. Posting-number: Volume 37, Issue 22
  11. Archive-name: vim/part22
  12. Environment: UNIX, AMIGA, MS-DOS
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 22 (of 23)."
  21. # Contents:  vim/doc/reference.doc1
  22. # Wrapped by mool@oce-rd2 on Mon Apr 19 15:50:14 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'vim/doc/reference.doc1' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'vim/doc/reference.doc1'\"
  26. else
  27. echo shar: Extracting \"'vim/doc/reference.doc1'\" \(48721 characters\)
  28. sed "s/^X//" >'vim/doc/reference.doc1' <<'END_OF_FILE'
  29. X
  30. X
  31. X
  32. X            VIM reference manual
  33. X
  34. X             By Bram Moolenaar
  35. X
  36. X               version 1.27
  37. X
  38. X
  39. X 1. Introduction
  40. X 2. Notation
  41. X 3. Starting VIM
  42. X 4. Modes
  43. X 5. Editing files
  44. X 6. Cursor motions
  45. X 7. Scrolling
  46. X 8. Tags
  47. X 9. Inserting text
  48. X10. Deleting text
  49. X11. Changing text
  50. X12. Copying and moving text
  51. X13. Quoting
  52. X14. Various commands
  53. X15. Repeating commands
  54. X16. Undo and redo
  55. X17. Key mapping
  56. X18. Recovery after a crash
  57. X19. Options
  58. X20. Terminal information
  59. X21. Differences from Vi and Ex
  60. X22. Credits
  61. X
  62. X
  63. X    1. Introduction
  64. X
  65. XVIM stands for Vi Imitation. VIM is a text editor which includes almost all 
  66. Xthe commands from the Unix program "Vi". It is very useful for editing 
  67. Xprograms and other ASCII text. All commands are given with the keyboard. 
  68. XThere is no mouse support and there are no menus. This gives the advantage 
  69. Xthat you can keep your fingers on the keyboard and your eyes on the screen.
  70. X
  71. XThroughout this manual the differences between Vi and Vim are mentioned in 
  72. Xcurly braces. Read the file "difference.doc" for a summary of the 
  73. Xdifferences.
  74. X
  75. XThis manual refers to VIM on the Commodore Amiga computer. On other 
  76. Xcomputers and on terminals there may be small differences. For MSDOS this 
  77. Xis documented in msdos.doc. For UNIX this is in unix.doc.
  78. X
  79. XThis manual is a reference for all the VIM commands and options. A basic
  80. Xknowledge of "Vi" is assumed. A summary of this manual can be found in the 
  81. Xfile vim.hlp. It can be accessed from within VIM with the <HELP> key (in 
  82. XMSDOS <F1>) and with the command ":help". The 'helpfile' option can be 
  83. Xset to the name of the help file, so you can put it in any place you like.
  84. X
  85. X
  86. X    2. Notation
  87. X
  88. X[]        Characters in square brackets are optional.
  89. X
  90. X[cnt]        An optional number that may precede the command to multiply
  91. X        or iterate the command. If no number is given a count of one 
  92. X        is used, unless otherwise noted. Note that in this manual 
  93. X        the [cnt] is not mentioned in the description of the 
  94. X        command, but only in the explanation. This was done to make 
  95. X        the commands more easy to lookup. If the "sc" option is on, 
  96. X        the (partially) entered count is shown at the bottom of the 
  97. X        window. You can use <DEL> to erase the last digit.
  98. X
  99. X["x]        An optional named register designation where text can be 
  100. X        stored. The x is a single character between <a> and <z> or 
  101. X        <A> and <Z> and in some cases (with the put command) between 
  102. X        <0> and <9> or <.>. The uppercase and lower case letter
  103. X        designate the same register, but the lower case letter is 
  104. X        used to overwrite the previous register contents, while the 
  105. X        uppercase letter is used to append to the previous register 
  106. X        contents. Without the ""x" the deleted text is put into the 
  107. X        unnamed register.
  108. X
  109. X{}        Curly braces denote parts of the command which must appear, 
  110. X        but can take a number of different values. The differences 
  111. X        between VIM and Vi are also given in curly braces (this will 
  112. X        be clear from the context).
  113. X
  114. X{motion}    A command that moves the cursor. They are listed in chapter 
  115. X        6. This is used after an "operator" command to move over the 
  116. X        text that is to be operated upon. If the motion includes a 
  117. X        count and the operator also had a count, the two counts are 
  118. X        multiplied. For example: "2d3w" deletes six words.
  119. X
  120. X{quote}        A piece of text that is started with the 'q' or 'Q' command
  121. X        and ended by the cursor position. This is used before an 
  122. X        "operator" to highlight the text that is to be operated 
  123. X        upon. See the chapter on quoting.
  124. X
  125. X<character>    A special character from the table below or a single ASCII
  126. X        character.
  127. X
  128. X<char1-char2>    A single character from the range <char1> to <char2>. For
  129. X        example: <a-z> is a lower case letter. Multiple ranges may be
  130. X        concatenated. For example: <a-zA-Z0-9> is any alphanumeric
  131. X        character.
  132. X
  133. XCTRL-<char>    <char> typed as a control character, that is, typing <char>
  134. X        while holding the CTRL key down. The case of <char> does not
  135. X        matter, thus CTRL-A and CTRL-a are equivalent.
  136. X
  137. X
  138. Xnotation    meaning             equivalent hex value
  139. X-----------------------------------------------------------------------
  140. X<NUL>        zero            CTRL_@  0x00 (or 0x9e)
  141. X<BELL>      bell            CTRL-G    0x07
  142. X<BS>        backspace        CTRL-H    0x08
  143. X<TAB>       tab            CTRL-I    0x09
  144. X<LF>        linefeed        CTRL-J    0x0a
  145. X<NL>        newline            CTRL-J    0x0a (same as linefeed)
  146. X<FF>        formfeed        CTRL-L    0x0c
  147. X<CR>        carriage return        CTRL-M    0x0d
  148. X<ESC>       escape            CTRL-[    0x1b
  149. X<SPACE>        space                0x20
  150. X<DEL>       delete                0x7f
  151. X<C_UP>        cursor-up            0x80
  152. X<C_DOWN>    cursor-down            0x81
  153. X<C_LEFT>    cursor-left            0x82
  154. X<C_RIGHT>    cursor-right            0x83
  155. X<SC_UP>        shift-cursor-up            0x84
  156. X<SC_DOWN>    shift-cursor-down        0x85
  157. X<SC_LEFT>    shift-cursor-left        0x86
  158. X<SC_RIGHT>    shift-cursor-right        0x87
  159. X<F1> - <F10>    function keys 1 to 10        0x88 - 0x91
  160. X<SF1> - <SF10>    shift-function keys 1 to 10    0x92 - 0x9b
  161. X<HELP>        help key            0x9c
  162. X<UNDO>        undo key            0x9d
  163. X-----------------------------------------------------------------------
  164. X
  165. X
  166. X    3. Starting VIM
  167. X
  168. X3.1 Command line
  169. X
  170. XMost often VIM is started to edit a single file with the command
  171. X
  172. X    vim file
  173. X
  174. XMore generally VIM is started with:
  175. X
  176. X    vim [options] [filelist]
  177. X
  178. XIf the filelist is missing, the editor will start with an empty buffer.
  179. XOtherwise exactly one out of the following six may be used to choose one or
  180. Xmore files to be edited.
  181. X
  182. Xfile ..        A list of file names. The first one will be the current file 
  183. X        and read into the buffer. The cursor will be positioned on 
  184. X        the first line of the buffer.
  185. X
  186. X+[num] file ..    Same as the above, but the cursor will be positioned on line
  187. X        "num". If "num" is missing, the cursor will be positioned on
  188. X        the last line.
  189. X
  190. X+/{pat} file ..    Same as the above, but the cursor will be positioned on the
  191. X        first line containing "pat" in the current file (see the 
  192. X        section "pattern searches" for the available search 
  193. X        patterns).
  194. X
  195. X+{command} file ..
  196. X-c {command} file ..
  197. X        Same as the above, but "command" will be executed after the 
  198. X        file has been read. "command" is interpreted as an Ex 
  199. X        command. If the "command" contains spaces it must be 
  200. X        enclosed in double quotes (this depends on the shell that is 
  201. X        used). Example: Vim "+set si" main.c
  202. X
  203. X-t {tag}    A tag. "tag" is looked up in the tags file, the associated 
  204. X        file becomes the current file and the associated command is 
  205. X        executed. Mostly this is used for C programs. In that case 
  206. X        "tag" should be a function name. The effect is that the file 
  207. X        containing that function becomes the current file and the 
  208. X        cursor is positioned on the start of the function (see the 
  209. X        section "tag searches").
  210. X
  211. X-e        QuickFix mode. The error file "AztecC.Err" is read and the 
  212. X        first error is displayed. See the section "using the 
  213. X        QuickFix option".
  214. X
  215. XThe options, if present, must precede the filelist. The options may be given 
  216. Xin any order.
  217. X
  218. X-r        Recovery mode. The autoscript file is read to recover a 
  219. X        crashed editing session. It has almost the same effect as 
  220. X        "-s file.vim". See the chapter "Recovery after a crash".
  221. X
  222. X-v        View mode. The 'readonly' option will be set and no 
  223. X        autoscript file will be written (see -n below). You can 
  224. X        still edit the buffer, but will be prevented from 
  225. X        accidentally overwriting a file. If you forgot that you are 
  226. X        in view mode and did make some changes, you can overwrite 
  227. X        a file by adding an exclamation mark to the Ex command, as in 
  228. X        ":w!". The 'readonly' option can be reset with ":set noro" 
  229. X        (see the options chapter). It is suggested to make an alias: 
  230. X        "alias view vim -v".
  231. X
  232. X-n        No autoscript file will be written. Recovery after a crash 
  233. X        will be impossible. Handy if you want to edit a file on a 
  234. X        very slow medium (e.g. floppy). Can also be done with ":set 
  235. X        uc=0". You can switch it on again by setting the 'uc' option 
  236. X        to some value, e.g. ":set uc=100" (only do this if the 
  237. X        buffer was not changed yet).
  238. X
  239. X-T {terminal}    Set the terminal type to "terminal". This influences the 
  240. X        codes that Vim will send to your terminal. This is normally 
  241. X        not needed, because Vim will be able to find out what type 
  242. X        of terminal you are using (See chapter 20).
  243. X
  244. X-d {device}    The "device" is opened to be used for editing. Normally you 
  245. X        would use this to set the window position and size:
  246. X        "-d con:x/y/width/height", e.g. "-d con:30/10/600/150". But 
  247. X        you can also use it to start editing on another device, e.g. 
  248. X        AUX:. This only works on the Amiga.
  249. X
  250. X-s {scriptin}    The script file "scriptin" is read. The characters in the 
  251. X        file are interpreted as if you had typed them. The same can 
  252. X        be done with the command ":source! {scriptin}". If the end 
  253. X        of the file is reached before the editor exits, further 
  254. X        characters are read from the keyboard. See also the section 
  255. X        "complex repeats".
  256. X
  257. X-w {scriptout}    All the characters that you type are recorded in the file
  258. X        "scriptout", until you exit VIM. This is useful if you want 
  259. X        to create a script file to be used with "vim -s" or 
  260. X        ":source!". See also the section "complex repeats".
  261. X
  262. XExample for using a script file to change a name in several files:
  263. X    Create a file "subs.vi" containing substitute commands and a :wq
  264. X    command:
  265. X
  266. X        :%s/Jones/Smith/g
  267. X        :%s/Allen/Peter/g
  268. X        :wq
  269. X
  270. X    Execute VIM on all files you want to change:
  271. X
  272. X        foreach i ( *.let ) vim -s subs.vi $i
  273. X
  274. X
  275. X3.2 Workbench (Amiga only)
  276. X
  277. XVim can be started from the workbench by clicking on its icon twice. It will
  278. Xthen start with an empty buffer.
  279. X
  280. XVim can be started to edit one or more files by using a "Project" icon. The
  281. X"Default Tool" of the icon must be the full pathname of the Vim executable. 
  282. XThe name of the ".info" file must be the same as the name of the text file. 
  283. XBy clicking on this icon twice, Vim will be started with the filename as 
  284. Xcurrent filename, which will be read into the buffer (if it exists). You can 
  285. Xedit multiple files by pressing the shift key while clicking on icons, and 
  286. Xclicking twice on the last one. The "Default Tool" for all these icons must 
  287. Xbe the same.
  288. X
  289. XIt is not possible to give arguments to Vim, other than filenames, from the
  290. Xworkbench.
  291. X
  292. X
  293. X3.3 Vim window
  294. X
  295. XVIM will run in the CLI window where it was started. If VIM was started with 
  296. Xthe "run" or "runback" command, or if VIM was started from the workbench, it 
  297. Xwill open a window of its own.
  298. X
  299. XTechnical detail:
  300. X    To open the new window a little trick is used. As soon as VIM 
  301. X    recognizes that it does not run in a normal CLI window, it will 
  302. X    create a script file in t:. This script file contains the same 
  303. X    command as how VIM was started, and an "endcli" command. This script 
  304. X    file is then executed with a "newcli" command (the "c:run" and 
  305. X    "c:newcli" commands are required for this to work). The script file 
  306. X    will hang around until reboot, or until you delete it. This method 
  307. X    is required to get the ":sh" and ":!" commands to work correctly. 
  308. X    But when Vim was started with the -e option (quickfix mode), this 
  309. X    method is not used. The reason for this is that when a compiler 
  310. X    starts Vim with the -e option it will wait for a return code. With 
  311. X    the script trick the compiler cannot get the return code. As a 
  312. X    consequence the ":sh" and ":!" commands are not available when the 
  313. X    -e option is used.
  314. X
  315. XVIM will automatically recognize the window size and react to window 
  316. Xresizing. Under Amiga DOS 1.3 it is advised to use the fastfonts program 
  317. X"FF" to speed up display redrawing.
  318. X
  319. X
  320. X3.4 Initialization
  321. X
  322. XWhen VIM starts running it does initializations in this order:
  323. X
  324. X1.  Four places are searched for initializations. The first that exists is 
  325. X    used, the others are ignored.
  326. X     1. The environment variable VIMINIT
  327. X     2. The file "s:.vimrc" (for Unix: "$HOME/.vimrc")
  328. X     3. The environment variable EXINIT
  329. X     4. The file "s:.exrc" (for Unix: "$HOME/.exrc")
  330. X
  331. X2.  The current directory is searched for two files. The first that exists 
  332. X    is used, the other is ignored.
  333. X     1. The file ".vimrc"
  334. X     2. The file ".exrc"
  335. X
  336. X    If an environment variable is used, it is executed as a single Ex 
  337. X    command line. Multiple commands must be separated with '|'. If a file is 
  338. X    used, each line is executed as an Ex command line.
  339. X
  340. X3.  The environment variable SHELL, if it exists, is used to set the 
  341. X    'shell' option.
  342. X
  343. X4.  The environment variable TERM, if it exists, is used to set the 'term'
  344. X    option.
  345. X
  346. XThe first can be used to set your default settings and mappings for all edit 
  347. Xsessions. The second one for sessions in a certain directory. See the 
  348. Xsection "Saving settings" for how to create a file with commands to recreate 
  349. Xthe current settings.
  350. X
  351. XIf the VIMINIT environment variable or ".vimrc" exist the EXINIT and ".exrc" 
  352. Xare skipped. This can be used to initialize Vim without interfering with 
  353. Xanother version of Vi.
  354. X
  355. XOn the Amiga two types of environment variables exist. The ones set with the
  356. XDOS 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3 
  357. Xmanual. The environment variables set with the old Manx Set command (before 
  358. Xversion 5.0) are not recognized.
  359. X
  360. XWhile reading the ".vimrc" and the ".exrc" file some commands are disabled 
  361. Xfor security reasons. Otherwise it would be possible to create a .exrc that 
  362. Xcontains nasty commands, which another user may automatically execute when 
  363. Xhe starts Vim it that directory. The disabled commands are the ones that 
  364. Xstart a shell and the ones that write to a file. The ":map" commands are 
  365. Xechoed, so you can see which keys are being mapped. (On unix systems this 
  366. Xonly happens if you are not the owner of the ".vimrc" or ".exrc" file.)
  367. X
  368. X
  369. X3.5 Suspending
  370. X
  371. XCTRL-Z                Suspend the editor. Same as ":stop!".
  372. X
  373. X:st[op][!]            Suspend the editor. If the "!" is not given,
  374. X                the buffer was changed, autowrite is set and 
  375. X                a filename is known, the buffer will be 
  376. X                written.
  377. X
  378. XOn BSD-UNIX systems it is possible to suspend Vim with CTRL-Z. This is only 
  379. Xpossible in command mode (see next chapter). Vim will restart if you make it 
  380. Xthe foreground job again. On other systems CTRL-Z will start a new shell. 
  381. XThis is the same as the ":sh" command. Vim will restart if you exit from the 
  382. Xshell.
  383. X
  384. X
  385. X    4. Modes
  386. X
  387. X4.1 Introduction
  388. X
  389. XVIM has four basic modes:
  390. X
  391. Xcommand mode        In command mode you can enter all the editor
  392. X            commands. If you start the editor you are in this 
  393. X            mode (unless you have set the 'insertmode' option, 
  394. X            see below).
  395. X
  396. Xinsert mode        In insert mode the text you type is inserted into the
  397. X            buffer. If the 'showmode' option is set (which is
  398. X            default), the string "-- INSERT --" is shown at the
  399. X            bottom of the window.
  400. X
  401. Xreplace mode        Replace mode is a special case of insert mode. You
  402. X            can do the same things as in insert mode, but for 
  403. X            each character you enter (except some special 
  404. X            characters) one character of the existing text is 
  405. X            deleted. If the 'showmode' option is set (which is 
  406. X            default), the string "-- REPLACE --" is shown at the 
  407. X            bottom of the window.
  408. X
  409. Xcommand line mode    In command line mode you can enter one line of text
  410. X            at the bottom of the window. This is for the Ex 
  411. X            commands, the pattern search commands and the filter 
  412. X            command.
  413. X
  414. XMore explanation on the insert, replace and command line mode is further on 
  415. Xin this chapter.
  416. X
  417. X
  418. X4.2 Switching from mode to mode
  419. X
  420. XIf for any reason you do not know in which mode you are, you can always get
  421. Xback to command mode by typing <ESC> twice. You will know you are back in
  422. Xcommand mode when you see the screen flash or hear the bell after you type
  423. X<ESC>.
  424. X
  425. X- go from command mode to insert mode by giving one of the commands
  426. X  "iIaAoOcCsS".
  427. X- go from command mode to replace mode with the "R" command (not the "r"
  428. X  command!).
  429. X- go from command mode to command line mode with the one of the commands
  430. X  ":/?!".
  431. X
  432. X- go from insert or replace mode to command mode with <ESC> (twice in some
  433. X  rare cases).
  434. X- go from command line mode to command mode with <CR> (which causes the
  435. X  entered command to be executed), by deleting the complete line (e.g. with 
  436. X  CTRL-U) and giving a final <BS>, or by hitting <ESC> twice. In the last 
  437. X  case the first <ESC> will also be used to start filename completion, but 
  438. X  you can ignore that.
  439. X
  440. XIf the 'insertmode' option is set, editing a file will start in insert mode.
  441. X
  442. X
  443. X4.3 Insert and replace mode
  444. X
  445. XIn insert and replace mode the following characters have a special meaning,
  446. Xother characters are inserted directly. To insert one of these special
  447. Xcharacters into the buffer, precede it with CTRL-V. To insert a <NUL> 
  448. Xcharacter use CTRL-V CTRL-J (the <NUL> is actually stored as a <LF> in 
  449. Xmemory, but replaced with a <NUL> when written to a file). To insert a 
  450. XCTRL-C use "CTRL-V003".
  451. X
  452. Xchar        action
  453. X-----------------------------------------------------------------------
  454. XCTRL-@        Insert previously inserted text and stop insert. {Vi: only
  455. X        when typed as first char, only upto 128 chars}
  456. XCTRL-A        Insert previously inserted text. {not in Vi}
  457. XCTRL-B <0-9a-z>
  458. X        Insert the contents of a numbered or named register (see 
  459. X        chapter on copying and moving text). 'B' stands for buffer, 
  460. X        which is called register in this document. {not in Vi}
  461. XCTRL-D        Delete one shiftwidth of indent at the start of the current 
  462. X        line. See also 'shiftround' option. {Vi: only after 
  463. X        auto-indent; also accepts preceding <^> and <0>}
  464. XCTRL-E        Insert the character which is below the cursor. {not in Vi}
  465. XCTRL-H <BS>    Delete the character before the cursor (see below). {Vi: 
  466. X        does not delete autoindents}
  467. XCTRL-J <LF>    Begin new line.
  468. XCTRL-K {char1} {char2}
  469. X        Enter digraph (see below). {not in Vi}
  470. XCTRL-M <CR>    Begin new line.
  471. XCTRL-O        See below. {not in Vi}
  472. XCTRL-R        Insert the character which is above the cursor. {not in Vi}
  473. XCTRL-T        Insert one shiftwidth of indent at the start of the current 
  474. X        line. See also 'shiftround' option. {Vi: only when in 
  475. X        autoindent}
  476. XCTRL-U        Delete all entered characters in the current line (see 
  477. X        below).
  478. XCTRL-V        Insert next non-digit literally. Up to three digits form the 
  479. X        decimal value of a single byte. All this without mapping. 
  480. X        {Vi: no decimal byte entry}
  481. XCTRL-W        Delete the word before the cursor (see below). See the 
  482. X        section "word motions" for the definition of a word.
  483. XCTRL-[ <ESC>    End insert or replace mode, back to command mode.
  484. X<DEL>        Same as CTRL-H <BS>
  485. X-----------------------------------------------------------------------
  486. X
  487. XThe effect of the <BS>, <DEL>, CTRL-W and CTRL-U depends on the 'backspace' 
  488. Xoption:
  489. X
  490. Xbackspace    action
  491. X option
  492. X   0       delete stops in column 1 and start position of insert
  493. X   1       delete stops at start position of insert
  494. X   2       delete always, CTRL-W and CTRL-U stop once at start position of 
  495. X          insert
  496. X
  497. XIf the 'backspace' option is non-zero and the cursor is in column 1 when one 
  498. Xof the three keys is used, the current line is joined with the previous 
  499. Xline. This effectively deletes the newline in front of the cursor. {Vi: does 
  500. Xnot cross lines, does not delete past start position of insert}
  501. X
  502. XWith CTRL-V followed by one, two or three digits you can enter the decimal 
  503. Xvalue of a byte, except 10. Normally CTRL-V is followed by three digits. The 
  504. Xformed byte is inserted as soon as you type the third digit. If you type 
  505. Xonly one or two digits and then a non-digit, the decimal value of those one 
  506. Xor two digits form the byte. After that the non-digit is dealt with in the 
  507. Xnormal way.
  508. X
  509. XIf you enter a value of 10, it will be interpreted as a 0. The 10 is a <LF>, 
  510. Xwhich is used internally to represent the NUL character. When writing the 
  511. Xbuffer to a file the <LF> character is translated into <NUL>. The <LF> 
  512. Xcharacter is written at the end of each line. Thus if you want to insert a 
  513. X<LF> character in a file you will have to make a line break.
  514. X
  515. X
  516. Xspecial keys
  517. X
  518. XThe following keys are special. They stop the current insert, do something 
  519. Xand then restart insertion. This means you can do something without getting 
  520. Xout of insert mode. This is very handy if you prefer to use the insert mode 
  521. Xall the time, just like editors that don't have a separate command mode. You 
  522. Xmay also want to set the 'backspace' option to 2 and set the 'insertmode' 
  523. Xoption. You can map often used commands to function keys by preceding them 
  524. Xwith a CTRL-O.
  525. X
  526. XThe changes (inserted or deleted characters) before and after these keys can 
  527. Xbe undone separately. Only the last change can be redone and always behaves 
  528. Xlike an 'i' command.
  529. X
  530. Xchar        action
  531. X-----------------------------------------------------------------------
  532. X<C_UP>        cursor one line up
  533. X<C_DOWN>    cursor one line down
  534. X<C_LEFT>    cursor one character left
  535. X<C_RIGHT>    cursor one character right
  536. X<SC_UP>        move window one page up
  537. X<SC_DOWN>    move window one page down
  538. X<SC_LEFT>    cursor one word back (like 'b' command)
  539. X<SC_RIGHT>    cursor one word forward (like 'w' command)
  540. XCTRL-O        execute one command and return to insert mode
  541. X-----------------------------------------------------------------------
  542. X
  543. XThe CTRL-O command has one side effect: If the cursor was beyond the end of 
  544. Xthe line it will be put on the last character in the line.
  545. X
  546. X
  547. X'textwidth' option
  548. X
  549. XThe 'textwidth' option can be used to automatically break a line before it 
  550. Xis getting too long. Set the 'textwidth' option to the maximum line length. 
  551. XIf you then type more characters (not being spaces or tabs), the last word 
  552. Xwill be put on a new line (unless it is the only word on the line). {Vi has 
  553. Xthe 'wrapmargin' option, but it does not do what you want}.
  554. X
  555. XIf you want to format a block of text you can use the 'V' operator. Type 'V' 
  556. Xand a movement command to move the cursor to the end of the block. In many 
  557. Xcases the command "V}" will do what you want (format until the next empty 
  558. Xline). Or you can use quoting: hit 'q', move to the end of the block and hit 
  559. X'V'.
  560. X
  561. X
  562. X'expandtab' option
  563. X
  564. XIf the 'expandtab' option is set, spaces will be used to fill the amount of
  565. Xwhitespace of the tab. If you want to enter a real <TAB> use CTRL-V. The
  566. X'expandtab' option is normally off.
  567. X
  568. X
  569. Xdigraphs
  570. X
  571. X:dig[raph]        show currently defined digraphs. {not in Vi}
  572. X
  573. X:dig[raph] {char1}{char2} {number} ...
  574. X            Add digraph {char1}{char2} to the list. {number} is 
  575. X            the decimal representation of the entered character.
  576. X
  577. XDigraphs are used to enter characters that normally cannot be entered by 
  578. Xan ordinary keyboard. These are mostly accented characters which have the 
  579. Xeighth bit set. The digraphs are more easy to remember than the decimal 
  580. Xnumber that can be entered with CTRL-V (see above).
  581. X
  582. XVim must have been compiled with the 'digraphs' option enabled. If not, the 
  583. X":digraph" command will display an error message.
  584. X
  585. XThere are two methods to enter digraphs:
  586. X    CTRL-K {char1} {char2}        or
  587. X    {char1} <BS> {char2}
  588. XThe first is always available. The second only when the 'digraph' option is 
  589. Xset.
  590. X
  591. XOnce you have entered the digraph the character is treated like a normal 
  592. Xcharacter, taking up only one character in the file and on the screen. 
  593. XExample:
  594. X    <|> <BS> <|>    will enter the double <|> character (166)
  595. X    <a> <BS> <^>    will enter an 'a' with a hat (226)
  596. X    CTRL-K <-> <->    will enter a minus sign (173)
  597. X
  598. XThe default digraphs are listed in the file digraph.doc. They are meant for 
  599. Xthe Amiga character set, which is some international standard. With another 
  600. Xcharacter set they may be illogical.
  601. X
  602. XIf you accidently typed an <a> that should be an <e>, you will type <a> <BS> 
  603. X<e>. But that is a digraph, so you will not get wat you want. To avoid this, 
  604. Xuse <DEL> instead of <BS>.
  605. X
  606. X
  607. Xreplace mode
  608. X
  609. XIn replace mode one character in the line is deleted for every character you 
  610. Xtype. If there are no characters to delete (at the end of the line), the 
  611. Xtyped character is appended (as in insert mode). Thus the number of 
  612. Xcharacters in a line stays the same until you get to the end of the line.
  613. X
  614. XBe careful with <TAB> characters. If you type a normal printing character in 
  615. Xits place, the number of characters is still the same, but the number of 
  616. Xcolumns will become smaller.
  617. X
  618. XThe 'repdel' option influences what happens if you delete characters in 
  619. Xreplace mode (with <BS>, <DEL>, CTRL-W or CTRL-U). If 'repdel' is on (the 
  620. Xdefault) the characters are really deleted. For example: If you made a 
  621. Xtyping error and hit <BS> to correct it, the number of characters in the 
  622. Xline will be one less. This is sometimes illogical, because replace mode was 
  623. Xmade to keep the number of characters the same. If you reset 'repdel', the 
  624. Xcharacters are not deleted but only the cursor is moved, so you can then 
  625. Xcorrect your typing error.
  626. X
  627. X
  628. X4.4 Command line mode
  629. X
  630. XCommand line mode is used to enter Ex commands, search patterns and <!>
  631. Xcommands.
  632. X
  633. X
  634. X4.4.1 Command line editing
  635. X
  636. XNormal characters are inserted in front of the cursor position. You can move
  637. Xaround in the command line with the left and right cursor keys. {Vi: can 
  638. Xonly alter the last character in the line}
  639. X
  640. XThe command lines that you enter are remembered in a history table. You can
  641. Xrecall them with the up and down cursor keys. Use the 'history' option to 
  642. Xset the number of lines that are remembered (default 20).
  643. X
  644. XCTRL-V        Insert next non-digit literally. Up to three digits form the 
  645. X        decimal value of a single byte. All this without mapping. 
  646. X        This works the same way as in insert mode (see above). {Vi: 
  647. X        type the CTRL-V twice to get one}
  648. X<C_LEFT>    cursor left
  649. X<C_RIGHT>    cursor right
  650. X<SC_LEFT>    cursor one word left
  651. X<SC_RIGHT>    cursor one word right
  652. X
  653. X<BS>        delete the character in front of the cursor
  654. X<DEL>        delete the character under the cursor (at end of line:
  655. X        character in front of the cursor)
  656. XCTRL-U        remove all characters
  657. X
  658. X<C_UP>        recall older command line from history
  659. X<C_DOWN>    recall more recent command line from history
  660. X
  661. XCTRL-D        list filenames that match the pattern in front of the cursor
  662. X<ESC>        do filename completion on the pattern in front of the cursor
  663. XCTRL-N        after <ESC> with multiple matches: go to next match;
  664. X        otherwise: recall more recent command line from history
  665. XCTRL-P        after <ESC> with multiple matches: go to previous match;
  666. X        otherwise: recall older command line from history
  667. X
  668. XIn the pattern for CTRL-D and <ESC> standard Amiga wildcards are accepted, 
  669. Xplus the <*> and <?> characters.
  670. X
  671. XFor filename completion you can use the 'suffixes' option to set a priority 
  672. Xbetween files with almost the same name. If there are multiple matches, 
  673. Xthose files with a file extension that is in the 'suffixes' option are 
  674. Xignored. The default is ".bak.o.h.info.vim", which means that files with the 
  675. Xextensions ".bak", ".o", ".h", ".info" and ".vim" are sometimes ignored. It 
  676. Xis impossible to ignore suffixes with two dots. Examples:
  677. X
  678. Xpattern:    files:                match:
  679. Xtest*        test.c test.h test.o        test.c
  680. Xtest*        test.h test.o            test.h and test.o
  681. Xtest*        test.i test.h test.c        test.i and test.c
  682. X
  683. X
  684. X4.4.2 Ex command lines
  685. X
  686. XThe Ex commands have a few specialities:
  687. X
  688. X<"> or <#> at the start of a line causes the whole line to be ignored. <"> 
  689. Xafter a command causes the rest of the line to be ignored. This can be used 
  690. Xto add comments.
  691. X
  692. X<|> can be used to separate commands, so you can give multiple commands in 
  693. Xone line. The commands ":global", ":vglobal" and ":!" see the <|> as their 
  694. Xargument, and can therefore not be followed by another command.
  695. X
  696. XWhen the character <%> or <#> is used where a filename is expected, they are 
  697. Xexpanded to the current and alternate filename (see the chapter "editing 
  698. Xfiles").
  699. X
  700. XEmbedded and trailing spaces in filenames are allowed if one filename is
  701. Xexpected as argument (":next {file..}" uses the space to separate filenames).
  702. X
  703. XWhen you want to use the special characters <"> or  <|> in a command, or want
  704. Xto use <%> or <#> in a filename, precede them with a backslash. The backslash
  705. Xis not required in a range and in the ":substitute" command.
  706. X
  707. X
  708. X4.4.3 Ex command line ranges
  709. X
  710. XSome Ex commands accept a line range in front of them. This is noted as
  711. X[range]. It consists of one or more line specifiers, separated with ',' or 
  712. X';'. When separated with ';' the cursor position will be set to that line 
  713. Xbefore interpreting the next line specifier. The default line specifier for 
  714. Xmost commands is the cursor position, but the commands ":write" and 
  715. X":global" have the whole file (1,$) as default. If more line specifiers are 
  716. Xgiven than required for the command, the first one(s) will be ignored.
  717. X
  718. XLine numbers may be specified with:
  719. X    {number}    an absolute line number
  720. X    .        the current line
  721. X    $        the last line in the file
  722. X    %        equal to 1,$ (the entire file)
  723. X    't        position of mark t (lower case)
  724. X    /{pattern}[/]    the next line where {pattern} matches
  725. X    ?{pattern}[?]    the previous line where {pattern} matches
  726. X
  727. XEach may be followed (several times) by '+' or '-' and an optional number. 
  728. XThis number is added or subtracted from the preceding line number. If the 
  729. Xnumber is omitted, 1 is used.
  730. X
  731. XThe '/' and '?' may be preceded with another address. The search starts from
  732. Xthere. The '/' and '?' after {pattern} are required to separate the pattern
  733. Xfrom anything that follows.
  734. X
  735. XThe {number} must be between 0 and the number of lines in the file. A 0 is 
  736. Xinterpreted as a 1, except with the commands tag, pop and read.
  737. X
  738. XExamples:
  739. X    .+3        three lines below the cursor
  740. X    /that/+1    the line below the next line containing "that"
  741. X    .,$        from current line until end of file
  742. X    0/that        the first line that containing "that"
  743. X
  744. XSome commands allow for a count after the command. This count is used as the
  745. Xnumber of lines to be used, starting with the line given in the last line
  746. Xspecifier (the default is the cursor line).
  747. X
  748. XExamples:
  749. X    :s/x/X/g 5    substitute <x> by <X> in the current line and four
  750. X            following lines
  751. X    :23d 4        delete lines 23, 24, 25 and 26
  752. X
  753. X
  754. X4.5 The window contents
  755. X
  756. XIn command and insert/replace mode the screen window will show the current
  757. Xcontents of the buffer: What You See Is What You Get. {Vi: when changing 
  758. Xtext a <$> is placed on the last changed character; The window is not always 
  759. Xupdated on slow terminals} Lines longer than the window width will wrap. The 
  760. Xbottom lines in the window may start with one of these two characters:
  761. X
  762. X<@>     The next line is too long to fit in the window.
  763. X<~>    Below the last line in the buffer.
  764. X
  765. XIf the bottom line is completely filled with <@>, the line that is at the 
  766. Xtop of the window is too long to fit in the window. If the cursor is on this 
  767. Xline you can't see what you are doing, because this part of the line is not 
  768. Xshown. However, the part of the line before the <@>s can be edited normally. 
  769. X{Vi: gives an "internal error" on lines that do not fit in the window}
  770. X
  771. XAll normal ASCII characters are displayed directly on the screen. The <TAB> 
  772. Xis replaced by the number of spaces that it represents. Other non-printing 
  773. Xcharacters are replaced by "^<char>", where <char> is the non-printing 
  774. Xcharacter with 64 added. Thus character 7 (bell) will be shown as "^G". 
  775. XCharacters between 127 and 160 are replaced by "~<char>", where <char> is 
  776. Xthe character with 64 subtracted. These characters occupy more than one 
  777. Xposition on the screen. The cursor can only be positioned on the first one.
  778. X
  779. XIf you set the 'number' option, all lines will be preceded with their 
  780. Xnumber.
  781. X
  782. XIf you set the 'list' option, <TAB> characters will not be shown as several
  783. Xspaces, but as "^I". A <$> will be placed at the end of the line, so you can
  784. Xfind trailing blanks.
  785. X
  786. XIn command line mode only the command line itself is shown correctly. The
  787. Xdisplay of the buffer contents is updated as soon as you go back to command
  788. Xmode.
  789. X
  790. XSome commands hand over the window to external commands (e.g. ":shell" and
  791. X"="). After these commands are finished the window may be clobbered with 
  792. Xoutput from the external command, so it needs to be redrawn. This is also 
  793. Xthe case if something is displayed on the status line that is longer than 
  794. Xthe width of the window. If you are expected to have a look at the screen 
  795. Xbefore it is redrawn, you get this message:
  796. X
  797. X        Press RETURN or enter command to continue
  798. X
  799. XAfter you type a key the screen will be redrawn and Vim continues. If you 
  800. Xtype <CR>, <SP> or <NL> nothing else happens. If you type any other key, it 
  801. Xwill be interpreted as (the start of) a new command. {Vi: only <:> commands 
  802. Xare interpreted}
  803. X
  804. XThe last line of the window is used for status and other messages. The 
  805. Xstatus messages will only be used if an option is on:
  806. X
  807. Xstatus message            option        default
  808. Xcurrent mode             'showmode'    on
  809. Xcommand characters        'showcmd'    on
  810. Xcursor position            'ruler'        off
  811. X
  812. XThe current mode is "-- INSERT --" or "-- REPLACE --". The command 
  813. Xcharacters are those that you typed but were not used yet. {Vi: does not show the characters you 
  814. Xtyped or the cursor position}
  815. X
  816. XIf you have a slow terminal you can switch off the status messages to speed 
  817. Xup editing:
  818. X    :set nosc noru nosm
  819. X
  820. XIf there is an error, an error message will be shown for at least one second 
  821. X(in reverse video). {Vi: error messages may be overwritten with other 
  822. Xmessages before you have a chance to read them}
  823. X
  824. XSome commands show how many lines were affected. Above which threshold this
  825. Xhappens can be controlled with the 'report' option (default 2).
  826. X
  827. XOn the Amiga VIM will run in a CLI window. The name VIM and the full name of
  828. Xthe current filename will be shown in the title bar. When the window is
  829. Xresized, VIM will automatically redraw the window. You may make the window as
  830. Xsmall as you like, but if it gets too small not a single line will fit in it.
  831. XMake it at least 40 characters wide to be able to read most messages on the
  832. Xlast line.
  833. X
  834. X
  835. X    5. Editing files
  836. X
  837. X5.1 Introduction
  838. X
  839. XEditing a file with VIM means:
  840. X
  841. X1. reading the file into the internal buffer
  842. X2. changing the buffer with editor commands
  843. X3. writing the buffer into a file
  844. X
  845. XAs long as you don't write the buffer, the original file remains unchanged. 
  846. XIf you start editing a file (read a file into the buffer), the file name is 
  847. Xremembered as the "current filename".
  848. X
  849. XIf there already was a current filename, then that one becomes the alternate 
  850. Xfile name. Up to 20 older alternate filenames are remembered in a list. When 
  851. Xyou enter a filename, for editing (e.g. with ":e filename") or writing (e.g. 
  852. Xwith (:w filename"), the filenames shift one down in this list. You can use 
  853. Xthis list to remember which files you edited and to quickly switch from one 
  854. Xfile to another with the CTRL-^ command (e.g. to copy text). {Vi: only one 
  855. Xalternate filename}
  856. X
  857. XIn Ex commands (the ones that start with a colon) you can refer to the 
  858. Xcurrent filename with <%> and refer to the alternate filename with <#> or 
  859. X"#0". The older alternate filenames are "#1", "#2", ..., "#20".
  860. X
  861. XCTRL-G        or
  862. X:f[ile]            Prints the current filename and the cursor position.
  863. X
  864. X:f[ile] {name}        Sets the current filename to {name}.
  865. X
  866. X:files            Lists the alternate filenames.
  867. X
  868. XWhen writing the buffer, the default is to use the current filename. Thus 
  869. Xwhen you give the "ZZ" or ":wq" command, the original file will be 
  870. Xoverwritten. If you do not want this, the buffer can be written into another 
  871. Xfile by giving a filename argument to the ":write" command. For example:
  872. X    
  873. X    vim testfile
  874. X    [change the buffer with editor commands]
  875. X    :w newfile
  876. X    :q
  877. X
  878. XThis will create a file "newfile", that is a modified copy of "testfile". 
  879. XThe file "testfile" will remain unchanged. Anyway, if the 'backup' option is 
  880. Xset, VIM renames the original file before it will be overwritten. You can 
  881. Xuse this file if you discover that you need the original file. The name of 
  882. Xthe backup file is the same as the original file with ".bak" appended. Any 
  883. X'.' is replaced by '_' on MSDOS machines, when Vim has detected that an 
  884. XMSDOS-like filesystem is being used (e.g. messydos or crossdos) and when the 
  885. X'shortname' option is set.
  886. X
  887. XTechnical: On the Amiga you can use 30 characters for a file name. But on an 
  888. X       MSDOS-compatible filesystem only 8 plus 3 characters are 
  889. X       available. Vim tries to detect the type of filesystem when it is 
  890. X       creating the .vim file. If an MSDOS-like filesystem is suspected, 
  891. X       a flag is set that has the same effect as setting the 'shortname' 
  892. X       option. This flag will be reset as soon as you start editing a 
  893. X       new file. The flag will be used when making the filename for the 
  894. X       ".vim" and ".bak" files for the current file. But when you are 
  895. X       editing a file in a normal filesystem and write to an MSDOS-like 
  896. X       filesystem the flag will not have been set. In that case the 
  897. X       creation of the ".bak" file may fail and you will get an error 
  898. X       message. Use the 'shortname' option.
  899. X
  900. XVIM remembers whether you have changed the buffer. You are protected from
  901. Xloosing the changes you made. If you try to quit without writing, or want to
  902. Xstart editing another file, this will be refused. In order to overrule this
  903. Xprotection add a <!> to the command. The changes will then be lost. For
  904. Xexample: ":q" will not work if the buffer was changed, but ":q!" will. To see
  905. Xwhether the buffer was changed use the "CTRL-G" command. The message includes
  906. Xthe string "[Modified]" if the buffer has been changed.
  907. X
  908. X
  909. X5.2 Editing a file
  910. X
  911. X:e [+pat]        Edit the current file, unless changes have been made.
  912. X
  913. X:e! [+pat]        Edit the current file always. Discard any changes to
  914. X            the buffer.
  915. X
  916. X:e[dit] [+pat] {file}    Edit {file}, unless changes have been made.
  917. X
  918. X:e[dit]! [+pat] {file}    Edit {file} always. Discard any changes to the
  919. X            buffer.
  920. X
  921. X:ex [+pat] [file]    Same as :edit.
  922. X
  923. X:vi[sual] [+pat] [file]    Same as :edit. {Vi: go from Ex to visual mode}
  924. X
  925. XCTRL-^            Edit [cnt]th (default 0) alternate file (equivalent
  926. X            to ":e #[cnt]"). If the 'autowrite' option is set 
  927. X            and the buffer was changed, write it. This is a 
  928. X            quick way to toggle between two (or more) files.
  929. X
  930. X:cd            Print the current directory name. {Vi: go to home 
  931. X            directory}
  932. X
  933. X:cd {path}        Change the current directory to {path}.
  934. X
  935. X:chd[ir] [path]        Same as :cd.
  936. X
  937. XThese commands are used to start editing a single file. This means that the
  938. Xfile is read into the buffer and the current filename is set. You may use the
  939. X":cd" command to get to another directory, so you will not have to type that 
  940. Xdirectory name in front of the filenames.
  941. X
  942. XYou can use the ":e!" command if you messed up the buffer and want to start 
  943. Xall over again. The ":e" command is only useful if you have changed the 
  944. Xcurrent filename.
  945. X
  946. XThe [+pat] can be used to position the cursor in the newly opened file:
  947. X    +        Start at the last line.
  948. X    +{num}        Start at line {num}.
  949. X    +/{pat}        Start at first line containing {pat}. {pat} must not
  950. X            contain any spaces.
  951. X    +{command}    Execute {command} after opening the new file.
  952. X            {command} is an Ex command. It must not contain 
  953. X            spaces.
  954. X
  955. X
  956. X5.3 The file list
  957. X
  958. XIf you give more than one filename when starting VIM, this list is remembered
  959. Xas the file list. You can use this list with the following commands:
  960. X
  961. X:ar[gs]            Print the file list, with the current file in "[]".
  962. X
  963. X:[count]n[ext]        Edit [count] next file, unless changes have been 
  964. X            made and the 'autowrite' option is off {Vi: no 
  965. X            count}.
  966. X
  967. X:[count]n[ext]!        Edit [count] next file, discard any changes to the 
  968. X            buffer {Vi: no count}.
  969. X
  970. X:n[ext] [+pat] {filelist}
  971. X            Define {filelist} as the new list of files and edit
  972. X            the first one, unless changes have been made and the
  973. X            'autowrite' option is off.
  974. X
  975. X:n[ext]! [+pat] {filelist}
  976. X            Define {filelist} as the new list of files and edit
  977. X            the first one. Discard any changes to the buffer.
  978. X
  979. X:[count]N[ext]        Edit [count] previous file in file list, unless 
  980. X            changes have been made and the 'autowrite' option is 
  981. X            off {Vi: no count}.
  982. X
  983. X:[count]N[ext]!        Edit [count] previous file in file list. Discard any 
  984. X            changes to the buffer {Vi: no count}.
  985. X
  986. X:[count]pre[vious]    Same as :Next {Vi: no count}.
  987. X
  988. X:rew[ind]        Start editing the first file in the file list, unless
  989. X            changes have been made and the 'autowrite' option is
  990. X            off.
  991. X
  992. X:rew[ind]!        Start editing the first file in the file list.
  993. X            Discard any changes to the buffer.
  994. X
  995. X:[count]wn[ext]        Write current file and start editing the [count] 
  996. X            next file. {not in Vi}
  997. X
  998. X:[count]wn[ext] {file}    Write current file to {file} and start editing the 
  999. X            [count] next file, unless {file} already exists and 
  1000. X            the 'writeany' option is off. 
  1001. X            {not in Vi}
  1002. X
  1003. X:[count]wn[ext]! {file}    Write current file to {file} and start editing the 
  1004. X            [count] next file. {not in Vi}
  1005. X
  1006. XThe [count] in the commands above defaults to one.
  1007. X
  1008. XThe wildcards in the file list are expanded and the filenames are sorted.
  1009. XThus you can use the command "vim *.c" to edit all the C files. From within 
  1010. XVIM the command ":n *.c" does the same.
  1011. X
  1012. XYou are protected from leaving VIM if you are not editing the last file in 
  1013. Xthe file list. This prevents you from forgetting that you were editing one 
  1014. Xout of several files. You can exit anyway, and save any changes, with the 
  1015. X":wq!" command. To loose any changes use the ":q!" command.
  1016. X
  1017. X
  1018. X5.4 Writing and quitting
  1019. X
  1020. X:[range]w[rite][!]    Write the specified lines to the current file.
  1021. X
  1022. X:[range]w[rite]    {file}    Write the specified lines to {file}, unless it
  1023. X            already exists and the 'writeany' option is off.
  1024. X
  1025. X:[range]w[rite]! {file}    Write the specified lines to {file}. Overwrite an
  1026. X            existing file.
  1027. X
  1028. X:[range]w[rite][!] >>    Append the specified lines to the current file.
  1029. X
  1030. X:[range]w[rite][!] >> {file}
  1031. X            Append the specified lines to {file}.
  1032. X
  1033. X:[range]w[rite] !{cmd}    Execute {cmd} with [range] lines as standard input
  1034. X            (note the space in front of the <!>).
  1035. X
  1036. XThe default [range] for the ":w" command is the whole buffer (1,$).
  1037. X
  1038. X
  1039. X:q[uit]         Quit, unless changes have been made or not editing 
  1040. X            the last file in the file list.
  1041. X
  1042. X:q[uit]!        Quit always, without writing.
  1043. X
  1044. X:cq            Quit always, without writing, and return an error 
  1045. X            code. Used for Manx's QuickFix option (see 5.5).
  1046. X
  1047. X:wq            Write the current file. Exit if not editing the
  1048. X            last file in the file list.
  1049. X
  1050. X:wq!            Write the current file and exit.
  1051. X
  1052. X:wq {file}        Write to {file}. Exit if not editing the last
  1053. X            file in the file list.
  1054. X
  1055. X:wq! {file}        Write to {file} and exit.
  1056. X
  1057. X:x[it][!] [file]    Like ":wq", but write only when changes have been
  1058. X            made.
  1059. X
  1060. XZZ            Store current file, if modified, and exit (same as
  1061. X            ":x").
  1062. X
  1063. XIf you write to an existing file (but do not append) while the 'backup' or 
  1064. X'writebackup' option is on, a backup of the original file is made. On Unix 
  1065. Xsystems the file is copied, on other systems the file is renamed. After the 
  1066. Xfile has been successfully written and when the 'writebackup' option is on 
  1067. Xand the 'backup' option is off, the backup file is deleted.
  1068. X
  1069. X'backup'    'writebackup'        action
  1070. X   off             off        no backup made
  1071. X   off             on            backup made, deleted afterwards
  1072. X   on             off        backup made, not deleted
  1073. X   on             on            backup made, not deleted
  1074. X
  1075. XOn Unix systems:
  1076. XWhen you write to an existing file, that file is truncated and then filled 
  1077. Xwith the new text. This means that protection bits, owner and symbolic links 
  1078. Xare unmodified. The backup file however, is a new file, owned by the user 
  1079. Xwho edited the file. If it is not possible to create the backup file in the 
  1080. Xsame directory as the original file, the directory given with the 
  1081. X'backupdir' option is used (default: home directory).
  1082. X
  1083. XIf the creation of a backup file fails, the write is not done. If you want 
  1084. Xto write anyway add a <!> to the command.
  1085. X
  1086. X
  1087. X5.5 Using the QuickFix option
  1088. X
  1089. XManx's Aztec C compiler on the Amiga has a speciality to speedup the
  1090. Xedit-compile-edit cycle. This is called the QuickFix option. VIM includes
  1091. Xsupport for this handy feature which is almost identical to Manx's editor 
  1092. X"Z". What you should do is:
  1093. X
  1094. X- Set the CCEDIT environment variable with the command
  1095. X    mset "CCEDIT=vim -e"
  1096. X
  1097. X- Compile with the -qf option. If the compiler finds any errors, Vim is 
  1098. Xstarted and the cursor is positioned on the first error. The error message 
  1099. Xwill be displayed on the last line. You can go to other errors with the 
  1100. Xcommands mentioned below. You can fix the errors and write the file(s).
  1101. X
  1102. X- If you exit Vim normally the compiler will re-compile the same file. If you
  1103. Xexit with the :cq command, the compiler will terminate. Do this if you cannot
  1104. Xfix the error, or if another file needs to be compiled first.
  1105. X
  1106. XThe following commands can be used if you are in QuickFix mode:
  1107. X
  1108. X:cc [nr]        Display error [nr]. If [nr] is omitted, the same
  1109. X            error is displayed again.
  1110. X
  1111. X:cn            Display the next error in the list.
  1112. X
  1113. X:cp            Display the previous error in the list.
  1114. X
  1115. X:cq            Quit Vim with an error code, so that the compiler
  1116. X            will not compile the same file again.
  1117. X
  1118. X:cf            Read the error file. This is done automatically when
  1119. X            Vim is started with the -e option.
  1120. X
  1121. X:cl            List all errors.
  1122. X
  1123. XThe name of the file can be set with the 'errorfile' option. The default is 
  1124. X"AztecC.Err". The format of the file is:
  1125. X
  1126. X    filename>linenumber:columnnumber:errortype:errornumber:errormessage
  1127. X
  1128. X    filename    name of the file in which the error was detected
  1129. X    linenumber    line number where the error was detected
  1130. X    columnnumber    column number where the error was detected
  1131. X    errortype    type of the error, normally a single 'E'
  1132. X    errornumber    number of the error
  1133. X    errormessage    description of the error
  1134. X
  1135. XIf you have a different compiler you could write a program that translates 
  1136. Xthe error messages into this format. Even better, it could start the 
  1137. Xcompiler (with make), interpret the output and, when there are any errors, 
  1138. Xstart Vim and recompile.
  1139. X
  1140. XThere are some restrictions to the Quickfix option. The compiler only writes 
  1141. Xthe first 25 errors to the errorfile (Manx's documentation does not say how 
  1142. Xto get more). If you want to find the others, you will have to fix a few 
  1143. Xerrors and exit the editor. After recompiling, upto 25 remaining errors 
  1144. Xwill be found.
  1145. X
  1146. XIf Vim was started from the compiler the :sh and :! commands will not work, 
  1147. Xbecause Vim is then running in the same process as the compiler and these 
  1148. Xtwo commands may guru the machine then.
  1149. X
  1150. XIf you insert or delete lines, mostly the correct error location is still 
  1151. Xfound because hidden marks are used (Manx's Z editor does not do this). 
  1152. XSometimes, when the mark has been deleted for some reason, the message "line 
  1153. Xchanged" is shown to warn you that the error location may not be correct. If 
  1154. Xyou edit another file the marks are lost and the error locations may not be 
  1155. Xcorrect anymore.
  1156. X
  1157. X
  1158. X    6. Cursor motions
  1159. X
  1160. XThese commands move the cursor position. If the new position is off of the
  1161. Xscreen, the screen is scrolled to show the cursor (see also 'scrolljump' 
  1162. Xoption).
  1163. X
  1164. XThe motion commands can be used after other commands, called operators, to
  1165. Xhave the command operate on the text that was moved over. That is the text
  1166. Xbetween the cursor position before and after the motion. If the motion
  1167. Xincludes a count and the operator also had a count, the two counts are
  1168. Xmultiplied. For example: "2d3w" deletes six words.
  1169. X    The operator either affects whole lines, or the characters between 
  1170. Xthe cursor positions. Generally, motions that move between lines affect 
  1171. Xlines, and motions that move within a line affect characters. However, there 
  1172. Xare some exceptions.
  1173. X    The motion is either inclusive or exclusive. When inclusive, the 
  1174. Xstart and end positions of the motion are included in the operation. When 
  1175. Xexclusive, the last character towards the end of the buffer is not included. 
  1176. XLinewise motions are always inclusive.
  1177. X    Which motions are linewise, inclusive or exclusive is mentioned 
  1178. Xbelow.
  1179. X
  1180. XInstead of first giving the operator and then a motion you can use quoting: 
  1181. Xmark the start of the text with <q>, move the cursor to the end of the text 
  1182. Xthat is to be affected and then hit the operator. The text between the start 
  1183. Xand the cursor position is highlighted, so you can see what text will be 
  1184. Xoperated upon. This allows much more freedom, but requires more key strokes 
  1185. Xand has limited redo functionality. See the chapter on quoting.
  1186. X
  1187. XIf you want to know where you are in the file use the "CTRL-G" command. If 
  1188. Xyou set the 'ruler' option, the cursor position is continuously shown in the 
  1189. Xstatus line (which slows down Vim a little).
  1190. X
  1191. XNOTE: Experienced users prefer the hjkl keys because they are always right
  1192. Xunder their fingers. Beginners often prefer the arrow keys, since they do not
  1193. Xrequire memorization of which hjkl key is which. The mnemonic value of hjkl 
  1194. Xis clear from looking at the keyboard. Think of j as an arrow pointing 
  1195. Xdownwards.
  1196. X
  1197. X6.1 Left-right motions
  1198. X
  1199. Xh        or
  1200. X<C_LEFT>    or
  1201. XCTRL-H        or
  1202. X<BS>            [cnt] characters to the left (exclusive).
  1203. X
  1204. Xl        or
  1205. X<C_RIGHT>    or
  1206. X<SPACE>            [cnt] characters to the right (exclusive).
  1207. X
  1208. X0            To the first character of the line (exclusive).
  1209. X
  1210. X^            To the first non-blank character of the line
  1211. X            (exclusive).
  1212. X
  1213. X$            To the end of line [cnt] from the cursor (inclusive).
  1214. X
  1215. X|            To column [cnt] (inclusive).
  1216. X
  1217. Xf<char>            To [cnt]'th occurrence of <char> to the right. The
  1218. X            cursor is placed on <char> (inclusive).
  1219. X
  1220. XF<char>            To the [cnt]'th occurrence of <char> to the left. The
  1221. X            cursor is placed on <char> (inclusive).
  1222. X
  1223. Xt<char>            Till before [cnt]'th occurrence of <char> to the
  1224. X            right. The cursor is placed on the character left of 
  1225. X            <char> (inclusive).
  1226. X
  1227. XT<char>            Till after [cnt]'th occurrence of <char> to the left.
  1228. X            The cursor is placed on the character right of <char>
  1229. END_OF_FILE
  1230. if test 48721 -ne `wc -c <'vim/doc/reference.doc1'`; then
  1231.     echo shar: \"'vim/doc/reference.doc1'\" unpacked with wrong size!
  1232. fi
  1233. # end of 'vim/doc/reference.doc1'
  1234. fi
  1235. echo shar: End of archive 22 \(of 23\).
  1236. cp /dev/null ark22isdone
  1237. MISSING=""
  1238. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ; do
  1239.     if test ! -f ark${I}isdone ; then
  1240.     MISSING="${MISSING} ${I}"
  1241.     fi
  1242. done
  1243. if test "${MISSING}" = "" ; then
  1244.     echo You have unpacked all 23 archives.
  1245.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1246. else
  1247.     echo You still need to unpack the following archives:
  1248.     echo "        " ${MISSING}
  1249. fi
  1250. ##  End of shell archive.
  1251. exit 0
  1252. -------------8<----------------8<----------------8<---------------8<--------
  1253. Bram Moolenaar                             | DISCLAIMER:  This  note  does  not
  1254. Oce Nederland B.V., Research & Development | necessarily represent the position
  1255. p.o. box 101, 5900 MA  Venlo               | of  Oce-Nederland  B.V.  Therefore
  1256. The Netherlands        phone +31 77 594077 | no liability or responsibility for
  1257. UUCP: mool@oce.nl        fax +31 77 595450 | whatever will be accepted.
  1258.  
  1259. exit 0 # Just in case...
  1260.