home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume44 / vim / part04 < prev    next >
Internet Message Format  |  1994-08-16  |  71KB

  1. From: mool@oce.nl (Bram Moolenaar)
  2. Newsgroups: comp.sources.misc
  3. Subject: v44i023:  vim - Vi IMproved editor, v3.0, Part04/26
  4. Date: 16 Aug 1994 21:17:29 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <32rrvp$kb4@sparky.sterling.com>
  9. X-Md4-Signature: 0445d194de70481e701871c436694bd3
  10.  
  11. Submitted-by: mool@oce.nl (Bram Moolenaar)
  12. Posting-number: Volume 44, Issue 23
  13. Archive-name: vim/part04
  14. Environment: UNIX, AMIGA, MS-DOS, Windows NT
  15. Supersedes: vim: Volume 41, Issue 50-75
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  vim/doc/reference.doc.B vim/src/termlib.c
  22. # Wrapped by kent@sparky on Mon Aug 15 21:43:59 1994
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 4 (of 26)."'
  26. if test -f 'vim/doc/reference.doc.B' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'vim/doc/reference.doc.B'\"
  28. else
  29.   echo shar: Extracting \"'vim/doc/reference.doc.B'\" \(50511 characters\)
  30.   sed "s/^X//" >'vim/doc/reference.doc.B' <<'END_OF_FILE'
  31. Xfilename"), the filename is added to the list. You can use this list to
  32. Xremember which files you edited and to quickly switch from one file to
  33. Xanother with the CTRL-^ command (e.g. to copy text). First type the number
  34. Xof the file and then hit CTRL-^. {Vi: only one alternate filename}
  35. X
  36. XIn Ex commands (the ones that start with a colon) <%> is replaced by the
  37. Xcurrent filename and <#> is replaced by the alternate filename. The older
  38. Xalternate filenames are "#1", "#2", etc. "#0" is the same as "#". If a
  39. X"<" is appended to <%>, <#> or "#n" the extension of the file name is
  40. Xremoved (everything after and including the last '.' in the file name).
  41. X
  42. X    %        current file name
  43. X    %<        current file name without extension
  44. X    #        alternate file name for current window
  45. X    #<        idem, without extension
  46. X    #31        alternate file number 31
  47. X    #31<        idem, without extension
  48. X
  49. XCTRL-G        or
  50. X:f[ile]            Prints the current filename (as typed) and the
  51. X            cursor position. {vi does not include column number}
  52. X
  53. X{count}CTRL-G        Prints the current filename with full path and the
  54. X            cursor position.
  55. X
  56. X:f[ile] {name}        Sets the current filename to {name}.
  57. X
  58. X:buffers
  59. X:files            List all the currently known file names. See
  60. X            'windows.doc'. {not in vi}
  61. X
  62. XVim will remember the full path name of a file name that you enter. In most
  63. Xcases when the file name is displayed only the name you typed is shown, but
  64. Xthe full path name is being used if you used the ":cd" command.
  65. X
  66. XIf the environment variable 'HOME' is set, and the file name starts with
  67. Xthat string, it is often displayed with HOME replaced by "~". This was done
  68. Xto keep file names short. When reading or writing files the full name is
  69. Xstill used, the "~" is only used when displaying file names.
  70. X
  71. XWhen writing the buffer, the default is to use the current filename. Thus 
  72. Xwhen you give the "ZZ" or ":wq" command, the original file will be 
  73. Xoverwritten. If you do not want this, the buffer can be written into another 
  74. Xfile by giving a filename argument to the ":write" command. For example:
  75. X    
  76. X    vim testfile
  77. X    [change the buffer with editor commands]
  78. X    :w newfile
  79. X    :q
  80. X
  81. XThis will create a file "newfile", that is a modified copy of "testfile". 
  82. XThe file "testfile" will remain unchanged. Anyway, if the 'backup' option is 
  83. Xset, Vim renames the original file before it will be overwritten. You can 
  84. Xuse this file if you discover that you need the original file. See also the
  85. X'patchmode' option. The name of the backup file is the same as the original
  86. Xfile with ".bak" appended. Any <.> is replaced by <_> on MSDOS machines, when
  87. XVim has detected that an MSDOS-like filesystem is being used (e.g. messydos or
  88. Xcrossdos) and when the 'shortname' option is set.
  89. X
  90. XTechnical: On the Amiga you can use 30 characters for a file name. But on an 
  91. X       MSDOS-compatible filesystem only 8 plus 3 characters are 
  92. X       available. Vim tries to detect the type of filesystem when it is 
  93. X       creating the .swp file. If an MSDOS-like filesystem is suspected, 
  94. X       a flag is set that has the same effect as setting the 'shortname' 
  95. X       option. This flag will be reset as soon as you start editing a 
  96. X       new file. The flag will be used when making the filename for the 
  97. X       ".swp" and ".bak" files for the current file. But when you are 
  98. X       editing a file in a normal filesystem and write to an MSDOS-like 
  99. X       filesystem the flag will not have been set. In that case the 
  100. X       creation of the ".bak" file may fail and you will get an error 
  101. X       message. Use the 'shortname' option in this case.
  102. X
  103. XWhen you started editing without giving a file name, "No File" is displayed in
  104. Xmessages. If a ":write file" or ":read file" command is used, the file name
  105. Xfor the current file is set to the file name in that command. This is useful
  106. Xwhen starting Vim without an argument and then doing ":read file" to start
  107. Xediting a file. Or when entering text in an empty buffer and then writing it
  108. Xto a file. Because the file name was set without really starting to edit that
  109. Xfile, you are protected from overwriting that file. This is done by setting
  110. Xthe "notedited" flag. You can see if this flag is set with the CTRL-G or
  111. X":file" command. It will include "[Not edited]" when the "notedited" flag is
  112. Xset. When writing the buffer to the current file name (with ":w!"), the
  113. X"notedited" flag is reset.
  114. X
  115. XVim remembers whether you have changed the buffer. You are protected from
  116. Xlosing the changes you made. If you try to quit without writing, or want to
  117. Xstart editing another file, this will be refused. In order to overrule this
  118. Xprotection add a <!> to the command. The changes will then be lost. For
  119. Xexample: ":q" will not work if the buffer was changed, but ":q!" will. To see
  120. Xwhether the buffer was changed use the "CTRL-G" command. The message includes
  121. Xthe string "[Modified]" if the buffer has been changed.
  122. X
  123. X
  124. X5.2 Editing a file
  125. X
  126. X:e[dit] [+cmd]        Edit the current file, unless changes have been made.
  127. X
  128. X:e[dit]! [+cmd]        Edit the current file always. Discard any changes to
  129. X            the buffer.
  130. X
  131. X:e[dit] [+cmd] {file}    Edit {file}, unless changes have been made.
  132. X
  133. X:e[dit]! [+cmd] {file}    Edit {file} always. Discard any changes to the
  134. X            buffer.
  135. X
  136. X:e[dit] #[count]        Edit the [count]th alternate filename (as shown by
  137. X                        :files). This command does the same as [count] CTRL-^.
  138. X
  139. X:ex [+cmd] [file]    Same as :edit. {Vi: go from visual to Ex mode}
  140. X
  141. X:vi[sual] [+cmd] [file]    Same as :edit. {Vi: go from Ex to Visual mode}
  142. X
  143. X[count]CTRL-^        Edit [count]th alternate file (equivalent to ":e
  144. X            #[count]"). Without count this gets you to the
  145. X            previously edited file. This is a quick way to
  146. X            toggle between two (or more) files. If the
  147. X            'autowrite' option is set and the buffer was
  148. X            changed, write it.
  149. X
  150. X]f
  151. X[f
  152. Xgf            Edit the file whose name is under or after the
  153. X            cursor. Mnemonic: "goto file". This fails if the
  154. X            current file cannot be abandoned. {not in Vi}
  155. X
  156. X:cd            On non-Unix systems: Print the current directory
  157. X            name. On Unix systems: Change the current directory
  158. X            to the home directory.
  159. X
  160. X:cd {path}        Change the current directory to {path}. Does not
  161. X            change the meaning of an already entered file name,
  162. X            because its full path name is remembered.
  163. X
  164. X:chd[ir] [path]        Same as :cd.
  165. X
  166. X:pwd            Print the current directory name. {Vi: no pwd}
  167. X
  168. XThese commands are used to start editing a single file. This means that the
  169. Xfile is read into the buffer and the current filename is set. You may use the
  170. X":cd" command to get to another directory, so you will not have to type that 
  171. Xdirectory name in front of the filenames. One warning: After using ":cd" the
  172. Xfull path name will be used for reading and writing files. On some networked
  173. Xfile systems this may cause problems. The result of using the full path name
  174. Xis that the file names currently in use will remain referring to the same
  175. Xfile. Example: If you have a file a:test and a directory a:vim the commands
  176. X":e test" ":cd vim" ":w" will overwrite the file a:test and not write
  177. Xa:vim/test. But if you do ":w test" the file a:vim/test will be written,
  178. Xbecause you gave a new file name and did not refer to a file name before the
  179. X":cd".
  180. X
  181. XYou can use the ":e!" command if you messed up the buffer and want to start 
  182. Xall over again. The ":e" command is only useful if you have changed the 
  183. Xcurrent filename.
  184. X
  185. XThe [+cmd] can be used to position the cursor in the newly opened file:
  186. X    +        Start at the last line.
  187. X    +{num}        Start at line {num}.
  188. X    +/{pat}        Start at first line containing {pat}. {pat} must not
  189. X            contain any spaces.
  190. X    +{command}    Execute {command} after opening the new file.
  191. X            {command} is an Ex command. It must not contain 
  192. X            spaces.
  193. X
  194. XWhen reading a file when the 'textmode' option is off (default for
  195. Xnon-MSDOS) the <LF> character is interpreted as end-of-line. If 'textmode'
  196. Xis on (default for MSDOS), <CR><LF> is also interpreted as end-of-line.
  197. X
  198. XWhen writing a file when the 'textmode' option is off a <LF> character is
  199. Xused to separate lines. When the 'textmode' option is on <CR><LF> is used.
  200. X
  201. XYou can read a file with 'textmode' set and write it with 'textmode' reset.
  202. XThis will replace all <CR><LF> pairs by <LF>. If you read a file with
  203. X'textmode' reset and write with 'textmode' set, all <LF> characters will be
  204. Xreplaced by <CR><LF>.
  205. X
  206. XIf you start editing a new file and the 'textauto' option is set, Vim will
  207. Xtry to detect whether the lines in the file are separated by a single <LF>
  208. X(as used on Unix and Amiga) or by a <CR><LF> pair (MSDOS). It reads up to
  209. Xthe first <LF> and checks if there is a <CR> in front of it. If there is the
  210. X'textmode' option is set, otherwise it is reset. If the 'textmode' option is
  211. Xset on non-MSDOS systems the message "[textmode]" is shown to remind you
  212. Xthat something unusual is happening. On MSDOS systems you get the message
  213. X"[notextmode]" if the 'textmode' option is not set.
  214. X
  215. XBefore editing binary, executable or Vim script files you should set the
  216. X'textmode' and 'textauto' options off. With 'textmode' on you risk that
  217. Xsingle <LF> characters are unexpectedly replaced with <CR><LF>. A simple way
  218. Xto do this is by starting Vim with the "-b" option.
  219. X
  220. X
  221. X5.3 The argument list
  222. X
  223. XIf you give more than one filename when starting Vim, this list is
  224. Xremembered as the argument list. Do not confuse this with the file list,
  225. Xwhich you can see with the ":files" command. The argument list was already
  226. Xpresent in vi, the file list is new in Vim. The file names in the argument
  227. Xlist will also be present in the file list (unless they were deleted with
  228. X":bdel").
  229. X
  230. XYou can use the argument list with the following commands:
  231. X
  232. X:ar[gs]            Print the argument list, with the current file in
  233. X            square brackets.
  234. X
  235. X:[count]argu[ment] [count] [+cmd]
  236. X            Edit file [count] in the argument list, unless
  237. X            changes have been made and the 'autowrite' option is
  238. X            off. {Vi: no such command}
  239. X
  240. X:[count]argu[ment]! [count] [+cmd]
  241. X            Edit file [count] in the argument list, discard any
  242. X            changes to the current buffer. {Vi: no such command}
  243. X
  244. X:[count]n[ext] [+cmd]    Edit [count] next file, unless changes have been 
  245. X            made and the 'autowrite' option is off {Vi: no 
  246. X            count}.
  247. X
  248. X:[count]n[ext]! [+cmd]    Edit [count] next file, discard any changes to the 
  249. X            buffer {Vi: no count}.
  250. X
  251. X:ar[gs] [+cmd] {filelist}
  252. X:n[ext] [+cmd] {filelist}
  253. X            Define {filelist} as the new argument list and edit
  254. X            the first one, unless changes have been made and the
  255. X            'autowrite' option is off.
  256. X
  257. X:ar[gs]! [+cmd] {filelist}
  258. X:n[ext]! [+cmd] {filelist}
  259. X            Define {filelist} as the new argument list and edit
  260. X            the first one. Discard any changes to the buffer.
  261. X
  262. X:[count]N[ext] [count] [+cmd]
  263. X            Edit [count] previous file in argument list, unless 
  264. X            changes have been made and the 'autowrite' option is 
  265. X            off {Vi: no count}.
  266. X
  267. X:[count]N[ext]! [count] [+cmd]
  268. X            Edit [count] previous file in argument list. Discard
  269. X            any changes to the buffer {Vi: no count}.
  270. X
  271. X:[count]pre[vious] [count] [+cmd]
  272. X            Same as :Next {Vi: only in some versions}
  273. X
  274. X:rew[ind] [+cmd]    Start editing the first file in the argument list,
  275. X            unless changes have been made and the 'autowrite'
  276. X            option is off.
  277. X
  278. X:rew[ind]! [+cmd]    Start editing the first file in the argument list.
  279. X            Discard any changes to the buffer.
  280. X
  281. X:la[st] [+cmd]        Start editing the last file in the argument list, unless
  282. X            changes have been made and the 'autowrite' option is
  283. X            off. {not in Vi}
  284. X
  285. X:la[st]! [+cmd]        Start editing the last file in the argument list.
  286. X            Discard any changes to the buffer. {not in Vi}
  287. X
  288. X:[count]wn[ext] [+cmd]    Write current file and start editing the [count] 
  289. X            next file. {not in Vi}
  290. X
  291. X:[count]wn[ext] [+cmd] {file}
  292. X            Write current file to {file} and start editing the
  293. X            [count] next file, unless {file} already exists and
  294. X            the 'writeany' option is off. {not in Vi}
  295. X
  296. X:[count]wn[ext]! [+cmd] {file}
  297. X            Write current file to {file} and start editing the
  298. X            [count] next file. {not in Vi}
  299. X
  300. X:[count]wN[ext][!] [+cmd] [file]
  301. X:[count]wp[revous][!] [+cmd] [file]
  302. X            Same as :wnext, but go to previous file instead of
  303. X            next. {not in Vi}
  304. X
  305. XThe [count] in the commands above defaults to one. For some commands it is
  306. Xpossible to use two counts. The last one (rightmost one) is used.
  307. X
  308. XFor [+cmd] see 5.2.
  309. X
  310. XThe wildcards in the argument list are expanded and the filenames are sorted.
  311. XThus you can use the command "vim *.c" to edit all the C files. From within 
  312. XVim the command ":n *.c" does the same.
  313. X
  314. XYou are protected from leaving Vim if you are not editing the last file in 
  315. Xthe argument list. This prevents you from forgetting that you were editing one 
  316. Xout of several files. To exit anyway try to exit twice. If there are changes
  317. Xin the current buffer this will fail. You can exit anyway, and save any
  318. Xchanges, with the ":wq!" command. To lose any changes use the ":q!" command.
  319. X
  320. X
  321. X5.4 Writing and quitting
  322. X
  323. X:[range]w[rite][!]    Write the specified lines to the current file.
  324. X
  325. X:[range]w[rite]    {file}    Write the specified lines to {file}, unless it
  326. X            already exists and the 'writeany' option is off.
  327. X
  328. X:[range]w[rite]! {file}    Write the specified lines to {file}. Overwrite an
  329. X            existing file.
  330. X
  331. X:[range]w[rite][!] >>    Append the specified lines to the current file.
  332. X
  333. X:[range]w[rite][!] >> {file}
  334. X            Append the specified lines to {file}. <!> forces the
  335. X            write even if file does not exist.
  336. X
  337. X:[range]w[rite] !{cmd}    Execute {cmd} with [range] lines as standard input
  338. X            (note the space in front of the <!>).
  339. X
  340. XThe default [range] for the ":w" command is the whole buffer (1,$).
  341. XIf a file name is give with ":w" it becomes the alternate file. This can be
  342. Xused when the write fails and you want to try again later with ":w #".
  343. X
  344. X
  345. X:q[uit]         Quit, unless changes have been made or not editing 
  346. X            the last file in the argument list.
  347. X
  348. X:q[uit]!        Quit always, without writing.
  349. X
  350. X:cq            Quit always, without writing, and return an error 
  351. X            code. Used for Manx's QuickFix mode (see 5.5).
  352. X
  353. X:wq            Write the current file. Exit if not editing the
  354. X            last file in the argument list.
  355. X
  356. X:wq!            Write the current file and exit.
  357. X
  358. X:wq {file}        Write to {file}. Exit if not editing the last
  359. X            file in the argument list.
  360. X
  361. X:wq! {file}        Write to {file} and exit.
  362. X
  363. X:x[it][!] [file]    Like ":wq", but write only when changes have been
  364. X            made.
  365. X
  366. X:exi[t][!] [file]    Same as :xit.
  367. X
  368. XZZ            Write current file, if modified, and exit (same as
  369. X            ":x").
  370. X
  371. XIf you write to an existing file (but do not append) while the 'backup' or 
  372. X'writebackup' option is on, a backup of the original file is made. On Unix 
  373. Xsystems the file is copied, on other systems the file is renamed. After the 
  374. Xfile has been successfully written and when the 'writebackup' option is on 
  375. Xand the 'backup' option is off, the backup file is deleted.
  376. X
  377. X'backup'    'writebackup'        action
  378. X   off             off        no backup made
  379. X   off             on            backup made, deleted afterwards
  380. X   on             off        backup made, not deleted
  381. X   on             on            backup made, not deleted (default)
  382. X
  383. XOn Unix systems:
  384. XWhen you write to an existing file, that file is truncated and then filled 
  385. Xwith the new text. This means that protection bits, owner and symbolic links 
  386. Xare unmodified. The backup file however, is a new file, owned by the user 
  387. Xwho edited the file. If it is not possible to create the backup file in the 
  388. Xsame directory as the original file, the directory given with the 
  389. X'backupdir' option is used (default: home directory).
  390. X
  391. XIf the creation of a backup file fails, the write is not done. If you want 
  392. Xto write anyway add a <!> to the command.
  393. X
  394. XIf the 'textmode' option is set <CR><LF> is used for end-of-line. This is
  395. Xdefault for MSDOS. On other systems the message "[textmode]" is shown to
  396. Xremind you that an usual end-of-line marker was used. If the 'textmode' is
  397. Xnot set LF is used for end-of-line. On MSDOS the message "[notextmode]" is
  398. Xshown. See also the 'textmode' and 'textauto' options.
  399. X
  400. X
  401. X5.5 Using the QuickFix mode
  402. X
  403. XVim has a special mode to speedup the edit-compile-edit cycle. This is
  404. Xinspired by the quickfix option of the Manx's Aztec C compiler on the Amiga.
  405. XThe idea is to save the error messages from the compiler in a file and use
  406. XVim to jump to the errors one by one. You can then examine each problem and
  407. Xfix it, without having to remember all the error messages.
  408. X
  409. XIf you are using Manx's Aztec C compiler on the Amiga you should do the
  410. Xfollowing:
  411. X- Set the CCEDIT environment variable with the command
  412. X    mset "CCEDIT=vim -e"
  413. X- Compile with the -qf option. If the compiler finds any errors, Vim is 
  414. X  started and the cursor is positioned on the first error. The error message
  415. X  will be displayed on the last line. You can go to other errors with the
  416. X  commands mentioned below. You can fix the errors and write the file(s).
  417. X- If you exit Vim normally the compiler will re-compile the same file. If you
  418. X  exit with the :cq command, the compiler will terminate. Do this if you
  419. X  cannot fix the error, or if another file needs to be compiled first.
  420. X
  421. XIf you are using another compiler you should save the error messages in a
  422. Xfile and start Vim with "vim -e filename". An easy way to do this is with
  423. Xthe ":make" command (see below). The 'errorformat' option should be set to
  424. Xmatch the error messages from your compiler (see below).
  425. X
  426. XThe following commands can be used if you are in QuickFix mode:
  427. X
  428. X:cc [nr]        Display error [nr]. If [nr] is omitted, the same
  429. X            error is displayed again. {not in Vi}
  430. X
  431. X:[count]cn        Display the [count] next error in the list that
  432. X            includes a file name. If there are no file names at
  433. X            all, go the the [count] next error. {not in Vi}
  434. X
  435. X:[count]cp        Display the [count] previous error in the list that
  436. X            includes a file name. If there are no file names at
  437. X            all, go the the [count] previous error. {not in Vi}
  438. X
  439. X:cq            Quit Vim with an error code, so that the compiler
  440. X            will not compile the same file again. {not in Vi}
  441. X
  442. X:cf [errorfile]        Read the error file and jump to the first error.
  443. X            This is done automatically when Vim is started with
  444. X            the -e option. You can use this command when you
  445. X            keep Vim running while compiling. If you give the
  446. X            name of the errorfile, the 'errorfile' option will
  447. X            be set to [errorfile] {not in Vi}
  448. X
  449. X:cl            List all errors. {not in Vi}
  450. X
  451. X:make [arguments]    1. If the 'autowrite' option is set and the buffer
  452. X               was changed, write it.
  453. X            2. Any existing 'errorfile' is deleted.
  454. X            3. The program given with the 'makeprg' option is
  455. X               started (default "make") with the optional
  456. X               [arguments] and the output is saved in
  457. X               'errorfile' (for Unix it is also echoed on the
  458. X               screen).
  459. X            4. The 'errorfile' is then read and the first error
  460. X               is jumped to.
  461. X            5. The 'errorfile' is deleted.
  462. X            {not in Vi}
  463. X
  464. XThe name of the file can be set with the 'errorfile' option. The default is 
  465. X"AztecC.Err" for the Amiga and "errors" for other systems. The format of the
  466. Xfile from the Aztec compiler is:
  467. X
  468. X    filename>linenumber:columnnumber:errortype:errornumber:errormessage
  469. X
  470. X    filename    name of the file in which the error was detected
  471. X    linenumber    line number where the error was detected
  472. X    columnnumber    column number where the error was detected
  473. X    errortype    type of the error, normally a single <E> or <W>
  474. X    errornumber    number of the error (for lookup in the manual)
  475. X    errormessage    description of the error
  476. X
  477. XAnother compiler is likely to use a different format. You should set the
  478. X'errorformat' option to a scanf-like string that describes the format. First
  479. Xyou need to know how scanf works. Look in the documentation of your C
  480. Xcompiler. Vim will understand eight conversion characters. Others are invalid.
  481. X    %f        file name (finds a string)
  482. X    %l        line number (finds a number)
  483. X    %c        column number (finds a number)
  484. X    %t        error type (finds a single character)
  485. X    %n        error number (finds a number)
  486. X    %m        error message (finds a string)
  487. X    %*<conv>    any scanf non-assignable conversion
  488. X    %%        the single <%> character
  489. X
  490. XExamples:
  491. X"%f>%l:%c:%t:%n:%m"            for the AztecC.Err file
  492. X"%f:%l:\ %t%*[^0123456789]%n:\ %m"    for Aztec C error messages
  493. X"%f\ %l\ %t%*[^0123456789]%n:\ %m"    for SAS C
  494. X"\"%f\",%*[^0123456789]%l:\ %m"        default for generic C compilers
  495. X"%f:%l:%m"                for GCC
  496. X
  497. XNote the backslash in front of a space and double quote. It is required for
  498. Xthe :set command.
  499. X
  500. XThe "%f" and "%m" conversions have to detect the end of the string. They
  501. Xshould be followed by a character that cannot be in the string. Everything
  502. Xup to that character is included in the string. Be careful: "%f%l" will
  503. Xinclude everything up to the first <%> in the file name. If the "%f" or "%m"
  504. Xis at the end, everything up to the end of the line is included.
  505. X
  506. XIf a line is detected that does not completely match the 'errorformat', the
  507. Xwhole line is put in the error message and the entry is marked "not valid"
  508. XThese lines are skipped with the ":cn" and ":cp" commands (unless there is
  509. Xno valid line at all). You can use ":cl" to display all the error messages.
  510. X
  511. XIf the error format does not contain a file name Vim cannot switch to the
  512. Xcorrect file. You will have to do this by hand.
  513. X
  514. XIf you have a compiler that produces error messages that do not fit in the
  515. Xformat string, you could write a program that translates the error messages
  516. Xinto this format. You can use this program with the ":make" command by
  517. Xchanging the 'makeprg' option. For example:
  518. X    ":set mp=make\ \\\|&\ error_filter".
  519. XThe backslashes before the pipe character are required to avoid it to be
  520. Xrecognized as a command separator. The backslash before each space is
  521. Xrequired for the set command.
  522. X
  523. XThe ":make" command executes the command given with the 'makeprg' option.
  524. XThis is done by passing the command to the shell given with the 'shell'
  525. Xoption. This works almost like typing
  526. X
  527. X    ":!{makeprg} [arguments] {shellpipe} {errorfile}".
  528. X
  529. X{makeprg} is the string given with the 'makeprg' option. Any command can be
  530. Xused, not just "make". Characters <%> and <#> are expanded as usual on a
  531. Xcommand line. You can use "#<" to insert the current filename without
  532. Xextension, for example ":set makeprg=make\ #<.o".
  533. X
  534. X[arguments] is anything that is typed after ":make".
  535. X{shellpipe} is the 'shellpipe' option.
  536. X{errorfile} is the 'errorfile' option.
  537. X
  538. XThe 'shellpipe' option defaults to ">" for the Amiga and MSDOS. This means
  539. Xthat the output of the compiler is saved in a file and not shown on the
  540. Xscreen directly. For Unix "| tee" is used. The compiler output is shown on
  541. Xthe screen and saved in a file the same time. Depending on the shell used
  542. X"|& tee" or "2>&1| tee" is the default, so stderr output will be included.
  543. X
  544. XThere are some restrictions to the Quickfix mode on the Amiga. The
  545. Xcompiler only writes the first 25 errors to the errorfile (Manx's
  546. Xdocumentation does not say how to get more). If you want to find the others,
  547. Xyou will have to fix a few errors and exit the editor. After recompiling,
  548. Xup to 25 remaining errors will be found.
  549. X
  550. XOn the Amiga, if Vim was started from the compiler, the :sh and :! commands
  551. Xwill not work, because Vim is then running in the same process as the
  552. Xcompiler and these two commands may guru the machine then.
  553. X
  554. XIf you insert or delete lines, mostly the correct error location is still 
  555. Xfound because hidden marks are used (Manx's Z editor does not do this). 
  556. XSometimes, when the mark has been deleted for some reason, the message "line 
  557. Xchanged" is shown to warn you that the error location may not be correct. If 
  558. Xyou quit Vim and start again the marks are lost and the error locations may
  559. Xnot be correct anymore.
  560. X
  561. X
  562. X5.6 Editing binary files
  563. X
  564. XAlthough Vim was made to edit text files, it is possible to edit binary
  565. Xfiles. The "-b" command line option (b for binary) sets some options for
  566. Xediting binary files ('binary' on, 'textwidth' to 0, 'textmode' and
  567. X'textauto' off, 'modelines' to 0, 'expandtab' off). Setting the 'binary'
  568. Xoption has the same effect. Don't forget to do this before reading the file.
  569. X
  570. XThere are a few things to remember when editing binary files:
  571. X- When editing executable files the number of characters must not change.
  572. X  Use only the "R" or "r" command to change text. Do not delete characters
  573. X  with "x" or by backspacing.
  574. X- Set the 'textwidth' option to 0. Otherwise lines will unexpectedly be
  575. X  split in two.
  576. X- When there are not many end-of-line characters, the lines will become very
  577. X  long. If you want to edit a line that does not fit on the screen reset the
  578. X  'wrap' option. Horizontal scrolling is used then. If a line becomes too
  579. X  long (more than about 32767 characters on the Amiga, much more on 32-bit
  580. X  systems) you cannot edit that line. The line will be split when reading
  581. X  the file. It is also possible that you get an "out of memory" error when
  582. X  reading the file.
  583. X- Make sure the 'textmode' and 'textauto' options are off before loading the
  584. X  file. In 'textmode' both <CR><LF> and <LF> are considered to end a line
  585. X  and when the file is written the <LF> will be replaced by <CR><LF>. The
  586. X  'modelines' option should also be off, because there may be a string like
  587. X  ":vi:" in the file that would give unpredictable results.
  588. X- <NUL> characters are shown on the screen as ^@. You can enter them with
  589. X  "CTRL-V CTRL-@" or "CTRL-V 000" {vi cannot handle <NUL> characters in the
  590. X  file}
  591. X- To insert a <LF> character in the file split up a line. When writing the
  592. X  buffer to a file a <LF> will be written for the end of line.
  593. X- Vim normally appends an end-of-line character at the end of the file if
  594. X  there is none. Setting the 'binary' option prevents this. If you want to
  595. X  add the final end-of-line, set the 'endofline' option. You can also read the
  596. X  value of this option to see if there was an end-of-line character for the
  597. X  last line (you cannot see this in the text).
  598. X
  599. X
  600. X    6. Cursor motions
  601. X
  602. XThese commands move the cursor position. If the new position is off of the
  603. Xscreen, the screen is scrolled to show the cursor (see also 'scrolljump' 
  604. Xoption).
  605. X
  606. XThe motion commands can be used after other commands, called operators, to
  607. Xhave the command operate on the text that was moved over. That is the text
  608. Xbetween the cursor position before and after the motion. If the motion
  609. Xincludes a count and the operator also had a count, the two counts are
  610. Xmultiplied. For example: "2d3w" deletes six words.
  611. X    The operator either affects whole lines, or the characters between 
  612. Xthe start and end position. Generally, motions that move between lines
  613. Xaffect lines (are linewise), and motions that move within a line affect
  614. Xcharacters. However, there are some exceptions.
  615. X    A character motion is either inclusive or exclusive. When inclusive,
  616. Xthe start and end position of the motion are included in the operation.
  617. XWhen exclusive, the last character towards the end of the buffer is not
  618. Xincluded. Linewise motions always include the start and end position.
  619. X    Which motions are linewise, inclusive or exclusive is mentioned 
  620. Xbelow. There are however, two general exceptions:
  621. X1. If the motion is exclusive and the end of the motion is in column 1, the 
  622. X   end of the motion is moved to the end of the previous line and the motion 
  623. X   becomes inclusive. Example: "}" ends at the first line after a paragraph, 
  624. X   but "V}" will not include that line.
  625. X2. If the motion is exclusive, the end of the motion is in column 1 and the 
  626. X   start of the motion was at or before the first non-blank in the line, the 
  627. X   motion becomes linewise. Example: If a paragraph begins with some blanks 
  628. X   and you do "d}" while standing on the first non-blank, all the lines of 
  629. X   the paragraph are deleted, including the blanks. If you do a put now, the 
  630. X   deleted lines will be inserted below the cursor position.
  631. X
  632. XInstead of first giving the operator and then a motion you can use Visual
  633. Xmode: mark the start of the text with <v>, move the cursor to the end of the
  634. Xtext that is to be affected and then hit the operator. The text between the
  635. Xstart and the cursor position is highlighted, so you can see what text will
  636. Xbe operated upon. This allows much more freedom, but requires more key
  637. Xstrokes and has limited redo functionality. See the chapter on Visual mode.
  638. X
  639. XIf you want to know where you are in the file use the "CTRL-G" command. If 
  640. Xyou set the 'ruler' option, the cursor position is continuously shown in the 
  641. Xstatus line (which slows down Vim a little).
  642. X
  643. XNOTE: Experienced users prefer the hjkl keys because they are always right
  644. Xunder their fingers. Beginners often prefer the arrow keys, because they
  645. Xdo not know what the hjkl keys do. The mnemonic value of hjkl is clear from
  646. Xlooking at the keyboard. Think of j as an arrow pointing downwards.
  647. X
  648. X6.1 Left-right motions
  649. X
  650. Xh        or
  651. X<C_LEFT>    or
  652. XCTRL-H        or
  653. X<BS>            [count] characters to the left (exclusive).
  654. X
  655. Xl        or
  656. X<C_RIGHT>    or
  657. X<SPACE>            [count] characters to the right (exclusive).
  658. X
  659. X0            To the first character of the line (exclusive).
  660. X
  661. X^            To the first non-blank character of the line
  662. X            (exclusive).
  663. X
  664. X$            To the end of line [count] from the cursor
  665. X            (inclusive).
  666. X
  667. X|            To column [count] (inclusive).
  668. X
  669. Xf<char>            To [count]'th occurrence of <char> to the right. The
  670. X            cursor is placed on <char> (inclusive).
  671. X
  672. XF<char>            To the [count]'th occurrence of <char> to the left.
  673. X            The cursor is placed on <char> (inclusive).
  674. X
  675. Xt<char>            Till before [count]'th occurrence of <char> to the
  676. X            right. The cursor is placed on the character left of 
  677. X            <char> (inclusive).
  678. X
  679. XT<char>            Till after [count]'th occurrence of <char> to the
  680. X            left. The cursor is placed on the character right of
  681. X            <char> (inclusive).
  682. X
  683. X;            Repeat latest f, t, F or T [count] times.
  684. X
  685. X,            Repeat latest f, t, F or T in opposite direction
  686. X            [count] times.
  687. X
  688. XThese commands move the cursor to the specified column in the current line.
  689. XThey stop at the first column and at the end of the line, except "$", which 
  690. Xmay move to one of the next lines.
  691. X
  692. X
  693. X6.2 Up-down motions
  694. X
  695. Xk        or
  696. X<C_UP>        or
  697. XCTRL-P            [count] lines upward (linewise).
  698. X
  699. Xj        or
  700. X<C_DOWN>    or
  701. XCTRL-J        or
  702. X<LF>        or
  703. XCTRL-N            [count] lines downward (linewise).
  704. X
  705. X-  <minus>        [count] lines upward, on the first non-blank
  706. X            character (linewise).
  707. X
  708. X+        or
  709. XCTRL-M        or
  710. X<CR>            [count] lines downward, on the first non-blank
  711. X            character (linewise).
  712. X
  713. X_  <underscore>        [count] - 1 lines downward, on the first non-blank
  714. X            character (linewise).
  715. X
  716. XG            Goto line [count], default last line, on the first
  717. X            non-blank character (linewise).
  718. X
  719. X:[range]        Set the cursor on the (last) specified line number
  720. X            (cannot be used with an operator).
  721. X
  722. X{count}%        Go to {count} percentage in the file, on the first
  723. X            non-blank in the line (linewise). To compute the new
  724. X            line number this formula is used: {count} *
  725. X            number-of-lines / 100. {not in Vi}
  726. X
  727. XThese commands move to the specified line. They stop when reaching the first 
  728. Xor the last line. The first two commands put the cursor in the same column 
  729. X(if possible) as it was after the last command that changed the column, 
  730. Xexcept after the "$" command, then the cursor will be put on the last 
  731. Xcharacter of the line.
  732. X
  733. X
  734. X6.3 Word motions
  735. X
  736. X<SC_RIGHT>    or
  737. Xw            [count] words forward (exclusive).
  738. X
  739. XW            [count] WORDS forward (exclusive).
  740. X
  741. Xe            Forward to the end of word [count] (inclusive).
  742. X
  743. XE            Forward to the end of WORD [count] (inclusive).
  744. X
  745. X<SC_LEFT>    or
  746. Xb            [count] words backward (exclusive).
  747. X
  748. XB            [count] WORDS backward (exclusive).
  749. X
  750. XThese commands move over words or WORDS. A word consists of a sequence of 
  751. Xletters, digits and underscores, or a sequence of other non-blank 
  752. Xcharacters, separated with white space (spaces, tabs, end of line). A WORD
  753. Xconsists of a sequence of non-blank characters, separated with white space.
  754. XAn empty line is also considered to be a word and a WORD.
  755. X
  756. XSpecial case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is 
  757. Xon a non-blank. This is because "cw" is interpreted as change-word, and a 
  758. Xword does not include the following white space. {Vi: "cw" when on a blank 
  759. Xfollowed by other blanks changes only the first blank; this is probably a 
  760. Xbug, because "dw" deletes all the blanks}
  761. X
  762. XAnother special case: When using the "w" motion in combination with an 
  763. Xoperator and the last word moved over is at the end of a line, the end of 
  764. Xthat word becomes the end of the operated text, not the first word in the 
  765. Xnext line.
  766. X
  767. XThe original vi implementation of "e" is buggy. For example, the "e" command 
  768. Xwill stop on the first character of a line if the previous line was empty. 
  769. XBut when you use "2e" this does not happen. In Vim "ee" and "2e" are the 
  770. Xsame, which is more logical. However, this causes a small incompatibility 
  771. Xbetween vi and Vim.
  772. X
  773. X
  774. X6.4 Text object motions
  775. X
  776. X(            [count] sentences backward (exclusive).
  777. X
  778. X)            [count] sentences forward (exclusive).
  779. X
  780. X{            [count] paragraphs backward (exclusive).
  781. X
  782. X}            [count] paragraphs forward (exclusive).
  783. X
  784. X]]            [count] sections forward or to the next <{> in the
  785. X            first column. When used after an operator, then the
  786. X            <}> in the first column. (linewise).
  787. X
  788. X][            [count] sections forward or to the next <}> in the
  789. X            first column (linewise).
  790. X
  791. X[[            [count] sections backward or to the previous <{> in
  792. X            the first column (linewise).
  793. X
  794. X[]            [count] sections backward or to the previous <}> in
  795. X            the first column (linewise).
  796. X
  797. XThese commands move over three kinds of text objects.
  798. X
  799. XA sentence is defined as ending at a <.>, <!> or <?> followed by either the 
  800. Xend of a line, or by a space. {Vi: two spaces} Any number of closing <)>, 
  801. X<]>, <"> and <'> characters my appear after the <.>, <!> or <?> before the 
  802. Xspaces or end of line. A paragraph and section boundary is also a sentence 
  803. Xboundary.
  804. X
  805. XA paragraph begins after each empty line, and also at each of a set of 
  806. Xparagraph macros, specified by the pairs of characters in the 'paragraphs' 
  807. Xoption. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the 
  808. Xmacros ".IP", ".LP", etc. (these are nroff macros, the dot must be in the 
  809. Xfirst column). A section boundary is also a paragraph boundary. Note that
  810. Xthis does not include a <{> or <}> in the first column.
  811. X
  812. XA section begins after a form-feed in the first column and at each of a set
  813. Xof section macros, specified by the pairs of characters in the 'sections'
  814. Xoption. The default is "SHNHH HUnhsh".
  815. X
  816. XThe "]" and "[" commands stop at the <{> or <}" in the first column. This is
  817. Xuseful to find the start or end of a function in a C program. Note that the
  818. Xfirst character of the command determines the search direction and the
  819. Xsecond character the type of brace found.
  820. X
  821. X
  822. X6.5 Pattern searches
  823. X
  824. X/{pattern}[/]        Search forward for the [count]'th occurrence of
  825. X            {pattern} (exclusive).
  826. X
  827. X/{pattern}/{offset}    Search forward for the [count]'th occurrence of
  828. X            {pattern} and go {offset} lines up or down (see 
  829. X            below). (linewise).
  830. X
  831. X/            Search forward for the [count]'th latest used
  832. X            pattern with latest used {offset}.
  833. X
  834. X//{offset}        Search forward for the [count]'th latest used
  835. X            pattern with new {offset}. If {offset} is empty no
  836. X            offset is used.
  837. X
  838. X*            Search forward for the [count]'th occurrence of the
  839. X            ident after or under the cursor (exclusive). Only
  840. X            whole words are search for, like with the command
  841. X            "/\<indent\>". If there is no identifier after or
  842. X            under the cursor, any non-blank word is used to
  843. X            search for. {not in Vi}
  844. X
  845. X#            Same as "*", but search backward. {not in Vi}
  846. X
  847. X?{pattern}[?]        Search backward for the [count]'th previous
  848. X            occurrence of {pattern} (exclusive).
  849. X
  850. X?{pattern}?{offset}    Search backward for the [count]'th previous
  851. X            occurrence of {pattern} and go {offset} lines up or
  852. X            down (see below) (linewise).
  853. X
  854. X?            Search backward for the [count]'th latest used
  855. X            pattern with latest used {offset}.
  856. X
  857. X??{offset}        Search backward for the [count]'th latest used
  858. X            pattern with new {offset}. If {offset} is empty no
  859. X            offset is used.
  860. X
  861. Xn            Repeat the latest "/" or "?" [count] times. {Vi: no
  862. X            count}
  863. X
  864. XN            Repeat the latest "/" or "?" [count] times in
  865. X            opposite direction. {Vi: no count}
  866. X
  867. XCTRL-C            Interrupt current (search) command.
  868. X
  869. XThese commands search for the specified pattern. With "/" and "?" an 
  870. Xadditional offset may be given. There are two types of offsets: line offsets 
  871. Xand character offsets. {the character offsets are not in Vi}
  872. X
  873. XThe offset gives the cursor position relative to the found match:
  874. X    [num]    [num] lines downwards, in column 1
  875. X    +[num]    [num] lines downwards, in column 1
  876. X    -[num]    [num] lines upwards, in column 1
  877. X    e[+num]    [num] characters to the right of the end of the match
  878. X    e[-num]    [num] characters to the left of the end of the match
  879. X    s[+num]    [num] characters to the right of the start of the match
  880. X    s[-num]    [num] characters to the left of the start of the match
  881. X    b[+num]    [num] characters to the right of the start (begin) of the match
  882. X    b[-num]    [num] characters to the left of the start (begin) of the match
  883. X
  884. XIf a <-> or <+> is given but [num] is omitted, a count of one will be used.
  885. XWhen including an offset with 'e', the search becomes inclusive (the
  886. Xcharacter the cursor lands on is included in operations).
  887. X
  888. XExamples:
  889. X
  890. Xpattern            cursor position
  891. X/test/+1        one line below "test", in column 1
  892. X/test/e            on the last t of "test"
  893. X/test/s+2        on the <s> of "test"
  894. X/test/b-3        three characters before "test"
  895. X
  896. XIf one of these commands is used after an operator, the characters between 
  897. Xthe cursor position before and after the search is affected. However, if a 
  898. Xline offset is given, the whole lines between the two cursor positions are 
  899. Xaffected.
  900. X
  901. XThe last used <pattern> and <offset> are remembered. They can be used to
  902. Xrepeat the search, possibly in another direction or with another count. Note
  903. Xthat two patterns are remembered: one for 'normal' search commands and one
  904. Xfor the substitute command ":s". Each time an empty <pattern> is given, the
  905. Xpreviously used <pattern> is used.
  906. X
  907. X{In vi the :tag command sets a new search pattern when the tag is searched
  908. Xfor. In Vim this is not done, the previous search pattern is still
  909. Xremembered}.
  910. X
  911. XIf the 'wrapscan' option is set (which is the default), searches wrap around 
  912. Xthe end of the buffer. If 'wrapscan' is not set, the backward search stops 
  913. Xat the beginning and the forward search stops at the end of the buffer. If 
  914. X'wrapscan' is set and the pattern was not found the error message "pattern
  915. Xnot found" is given, and the cursor will not be moved. If 'wrapscan' is not
  916. Xset the message becomes "search hit BOTTOM without match" when searching
  917. Xforward, or "search hit TOP without match" when searching backward. If
  918. Xwrapscan is set and the search wraps around the end of the file the message
  919. X"search hit TOP, continuing at BOTTOM" or "search hit BOTTOM, continuing at
  920. XTOP" is given when searching backwards or forwards respectively.
  921. X
  922. XThe "*" and "#" commands search for the identifier currently under the
  923. Xcursor. If there is no identifier under the cursor, the first one to the
  924. Xright is used. This identifier may only contain letters, digits and
  925. Xunderscores. Note that if you type with ten fingers, the characters are easy
  926. Xto remember: the "#" is under your left hand middle finger (search to the
  927. Xleft and up) and the "*" is under your right hand middle finger (search to
  928. Xthe right and down). If there is no identifier under or after the cursor, a
  929. Xsearch is done for any word under or after the cursor. Blanks (<TAB>s and/or
  930. X<SPACE>s) are recognized as delimiters for this word.
  931. X
  932. X
  933. XThe definition of a pattern:
  934. X
  935. XPatterns may contain special characters, depending on the setting of the
  936. X'magic' option.
  937. X
  938. X1.  A pattern is one or more branches, separated by '\|'. It matches anything
  939. X    that matches one of the branches. Example: "foo\|bar" matches "foo" and
  940. X    "bar.
  941. X
  942. X2.  A branch is one or more pieces, concatenated. It matches a match for the
  943. X    first, followed by a match for the second, etc. Example: "foo[0-9]bar",
  944. X    first match "foo", then a digit and then "bar".
  945. X
  946. X3.  A piece is an atom, possibly followed by:
  947. X      'magic'    'nomagic'
  948. X      option    option
  949. X    *      \*        matches 0 or more of the preceding atom
  950. X    \+      \+        matches 1 or more of the preceding atom {not
  951. X                in Vi}
  952. X    \=      \=        matches 0 or 1 of the preceding atom {not in
  953. X                Vi}
  954. X    Examples:
  955. X       .*      .\*        match anything, also empty string
  956. X       .\+      .\+        match any non-empty string
  957. X       foo\=      foo\=        match "fo" and "foo"
  958. X
  959. X
  960. X4.  An atom can be:
  961. X    - One of these five:
  962. X      magic    nomagic
  963. X    .      \.        matches any single character
  964. X    \<      \<        matches the beginning of a word
  965. X    \>      \>        matches the end of a word
  966. X    ^      ^        at beginning of pattern, matches start of
  967. X                line
  968. X    $      $        at end of pattern or in front of '\|',
  969. X                matches end of line
  970. X    - A pattern enclosed by escaped parentheses (e.g. "\(^a\)").
  971. X    - A single character, with no special meaning, matches itself
  972. X    - A backslash followed by a single character, with no special meaning,
  973. X      matches the single character.
  974. X    - A range. This is a sequence of characters enclosed in '[]' with the 
  975. X      'magic' option, or enclosed in '\[]' with the 'nomagic' option. It 
  976. X      normally matches any single character from the sequence. If the 
  977. X      sequence begins with <^>, it matches any single character NOT in the 
  978. X      sequence. If two characters in the sequence are separated by <->, this 
  979. X      is shorthand for the full list of ASCII characters between them (e.g. 
  980. X      '[0-9]' matches any decimal digit). To include a literal <]> in the 
  981. X      sequence, make it the first character (following a possible <^>). To 
  982. X      include a literal '\-', make it the first or last character.
  983. X
  984. XIf the 'ignorecase' option is set, the case of letters is ignored.
  985. X
  986. XIt is impossible to have a pattern that contains a line break.
  987. X
  988. XExamples:
  989. X^beep(            Probably the start of the C function "beep".
  990. X
  991. X[a-zA-Z]$        Any alphabetic character at the end of a line.
  992. X
  993. X\(^\|[^a-zA-Z0-9_]\)[a-zA-Z_]\+[a-zA-Z0-9_]*
  994. X            A C identifier (will stop in front of it).
  995. X
  996. X\(\.$\|\. \)        A period followed by end-of-line or a space.
  997. X            Note that "\(\. \|\.$\)" does not do the same,
  998. X            because '$' is not end-of-line in front of '\)'.
  999. X            This was done to remain vi-compatible.
  1000. X
  1001. X[.!?][])"']*\($\|[ ]\)    A search pattern that finds the end of a sentence,
  1002. X            with almost the same definition as the <)> command.
  1003. X
  1004. XTechnical detail:
  1005. X<NUL> characters in the file are stored as <LF> in memory. In the display
  1006. Xthey are shown as "^@". The translation is done when reading and writing
  1007. Xfiles. To match a <NUL> with a search pattern you can just enter CTRL-@ or
  1008. X"CTRL-V 000". This is probably just what you expect. Internally the
  1009. Xcharacter is replaced by a <LF> in the search pattern. What is unusual is
  1010. Xthat typing CTRL_V CTRL_J also inserts a <LF>, thus also searches for a
  1011. X<NUL> in the file. {vi cannot handle <NUL> characters in the file at all}
  1012. X
  1013. X
  1014. X6.6 Various motions
  1015. X
  1016. Xm<a-zA-Z>        Set mark <a-zA-Z> at cursor position (does not move 
  1017. X            the cursor, this is not a motion command).
  1018. X
  1019. X:[range]mar[k] <a-zA-Z>    Set mark <a-zA-Z> at last line number in [range], 
  1020. X            column 0. Default is cursor line.
  1021. X
  1022. X:[range]k<a-zA-Z>    Same as :mark, but the space before the mark name can
  1023. X            be omitted.
  1024. X
  1025. X'<a-z>            To the first non-blank character on the line with
  1026. X            mark <a-z> (linewise).
  1027. X
  1028. X'<A-Z>            To the first non-blank character on the line with
  1029. X            mark <A-Z> in the correct file (linewise when in 
  1030. X            same file, not a motion command when in other file). 
  1031. X            {not in Vi}
  1032. X
  1033. X`<a-z>            To the mark <a-z> (exclusive).
  1034. X
  1035. X`<A-Z>            To the mark <A-Z> in the correct file (exclusive 
  1036. X            when in same file, not a motion command when in 
  1037. X            other file). {not in Vi}
  1038. X
  1039. X:marks            List the current marks (not a motion command). {not 
  1040. X            in Vi}
  1041. X
  1042. XA mark is not visible in any way. It is just a position in the file that is
  1043. Xremembered. Do not confuse marks with named registers, they are totally 
  1044. Xunrelated.
  1045. X
  1046. XLowercase marks are only remembered as long as the file remains loaded. If
  1047. Xyou quit editing the file, change a character in a line or delete a line
  1048. Xthat contains a mark, that mark is erased. Lowercase marks can be used
  1049. Xin combination with operators. For example: "d't" deletes the lines from the
  1050. Xcursor position to mark <t>. Hint: Use mark <t> for Top, <b> for Bottom,
  1051. Xetc..
  1052. X
  1053. XMarks are restored when using undo and redo.
  1054. X
  1055. XMarks are remembered as long as the file remains in the buffer list.
  1056. X
  1057. XUppercase marks include the file name. {Vi: no uppercase marks} You can use 
  1058. Xthem to jump from file to file. You can only use an uppercase mark with 
  1059. Xan operator if the mark is in the current file. The line number of the mark
  1060. Xremains correct, even if you insert/delete lines or edit another file for a
  1061. Xmoment.
  1062. X
  1063. X
  1064. X'[            To the first non-blank character on the first line 
  1065. X            of the previously operated text or start of the last 
  1066. X            putted text. {not in Vi}
  1067. X
  1068. X`[            To the first character of the previously operated 
  1069. X            text or start of the last putted text. {not in Vi}
  1070. X
  1071. X']            To the first non-blank character on the last line of 
  1072. X            the previously operated text or end of the last 
  1073. X            putted text. {not in Vi}
  1074. X
  1075. X`]            To the last character of the previously operated 
  1076. X            text or end of the last putted text. {not in Vi}
  1077. X
  1078. XAfter executing an operator the Cursor is put at the beginning of the text 
  1079. Xthat was operated upon. After a put command ("p" or "P") the cursor is 
  1080. Xsometimes placed at the first inserted line and sometimes on the last 
  1081. Xinserted character. The four commands above put the cursor at either
  1082. Xend. Example: After yanking 10 lines you want to go to the last one of them: 
  1083. X"10Y']". After inserting several lines with the "p" command you want to jump 
  1084. Xto the lowest inserted line: "p']".
  1085. X
  1086. XNote: After deleting text, the start and end positions are the same, except 
  1087. Xwhen using blockwise Visual mode. These commands do not work when no
  1088. Xoperator or put command has been used yet in the current file. The position
  1089. Xmay be incorrect after inserting text and ".p.
  1090. X
  1091. X
  1092. X''            To the first non-blank character of the line where
  1093. X            the cursor was before the latest jump (linewise).
  1094. X
  1095. X``            To the position before latest jump (exclusive).
  1096. X
  1097. XA "jump" is one of the following commands: "'", "`", "G", "/", "?", "n", 
  1098. X"N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and
  1099. Xthe commands that start editing a new file. If you make the cursor "jump"
  1100. Xwith one of these commands, the position of the cursor before the jump is
  1101. Xremembered. You can return to that position with the "''" and "``" command,
  1102. Xunless the line containing that position was changed or deleted.
  1103. X
  1104. XCTRL-O            Go to [count] Older cursor position in jump list
  1105. X            (not a motion command). {not in Vi}
  1106. X
  1107. XCTRL-I            Go to [count] newer cursor position in jump list
  1108. X            (not a motion command). {not in Vi}
  1109. X
  1110. X:jumps            Print the jump list (not a motion command). {not in 
  1111. X            Vi} 
  1112. X
  1113. XJumps are remembered in a jump list. With the CTRL-O and CTRL-I command you 
  1114. Xcan go to cursor positions before older jumps, and back again. Thus you can 
  1115. Xmove up and down the list.
  1116. X
  1117. XFor example, after three jump commands you have this jump list:
  1118. X
  1119. X jump line  file
  1120. X   1     1  -current-
  1121. X   2    70  -current-
  1122. X   3  1154  -current-
  1123. X>
  1124. X
  1125. XYou are currently in line 1167. If you then use the CTRL-O command, the 
  1126. Xcursor is put in line 1154. This results in:
  1127. X
  1128. X jump line  file
  1129. X   1     1  -current-
  1130. X   2    70  -current-
  1131. X>  3  1154  -current-
  1132. X   4  1167  -current-
  1133. X
  1134. XThe pointer will be set at the last used jump position. The next CTRL-O 
  1135. Xcommand will use the entry above it, the next CTRL-I command will use the 
  1136. Xentry below it. If the pointer is below the last entry, this indicates that 
  1137. Xyou did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command 
  1138. Xwill cause the cursor position to be added to the jump list, so you can get 
  1139. Xback to the position before the CTRL-O. In this case this is line 1167.
  1140. X
  1141. XWith more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I 
  1142. Xyou can go back to 1154 and 1167 again.
  1143. X
  1144. XIf you use a jump command, the current line number is inserted at the end of 
  1145. Xthe jump list. If you used CTRL-O or CTRL-I just before that, the same line 
  1146. Xmay be in the list twice. This may be a bit strange. Just try it and look at 
  1147. Xthe jump list with the :jumps command. Note that this behaviour is different 
  1148. Xfrom the tag stack.
  1149. X
  1150. XAfter the CTRL-O command that got you into line 1154 you could give another 
  1151. Xjump command (e.g. "G"). The jump list would then become:
  1152. X
  1153. X jump line  file
  1154. X   1     1  -current-
  1155. X   2    70  -current-
  1156. X   3  1154  -current-
  1157. X   4  1167  -current-
  1158. X   5  1154  -current-
  1159. X>
  1160. X
  1161. XAs long as you stay in the same file, the line numbers will be adjusted for 
  1162. Xdeleted and inserted lines. If you go to another file the line numbers may 
  1163. Xbe wrong (keeping them correct would take too much time). If you want to 
  1164. Xavoid this use a :jumps command before changing files. This will update the 
  1165. Xline numbers in the current file.
  1166. X
  1167. X%            Find the next item in this line after or under the
  1168. X            cursor and jump to its match (inclusive). Items can
  1169. X            be:
  1170. X            ([{}])        parenthesis or (curly/square) brackets
  1171. X             /* */        start or end of C-style comment
  1172. X            #if, #ifdef, #else, #elif, #endif
  1173. X                    C preprocessor conditionals
  1174. X            Parens and braces preceded with a backslash are
  1175. X            ignored. Parens and braces inside quotes are ignored,
  1176. X            unless the number of parens/braces in a line is uneven
  1177. X            and this line and the previous one does not end in a
  1178. X            backslash. No count is allowed ({count}% jumps to a
  1179. X            line {count} percentage down the file).
  1180. X            Using '%' on #if/#else/#endif makes the movement
  1181. X            linewise.
  1182. X
  1183. X[(            go to [count] previous unmatched <(>. {not in Vi}
  1184. X
  1185. X[{            go to [count] previous unmatched <{>. {not in Vi}
  1186. X
  1187. X])            go to [count] next unmatched <)>. {not in Vi}
  1188. X
  1189. X]}            go to [count] next unmatched <}>. {not in Vi}
  1190. X
  1191. XThe above four commands can be used to go to the start or end of the current
  1192. Xcode block. It is like doing "%" on the <(>, <)>, <{> or <}> at the other
  1193. Xend of the code block, but you can do this from anywhere in the code block.
  1194. XVery useful for C programs. Example: When standing on "case x:", "[{" will
  1195. Xbring you back to the switch statement.
  1196. X
  1197. XH            To line [count] from top (Home) of screen (default:
  1198. X            first line on the screen) on the first non-blank 
  1199. X            character (linewise).
  1200. X
  1201. XM            To Middle line of screen, on the first non-blank
  1202. X            character (linewise).
  1203. X
  1204. XL            To line [count] from bottom of screen (default: Last
  1205. X            line on the screen) on the first non-blank character 
  1206. X            (linewise).
  1207. X
  1208. X
  1209. X    7. Scrolling
  1210. X
  1211. XMove edit window downwards (this means that more lines downwards in the text
  1212. Xbuffer are seen):
  1213. X
  1214. XCTRL-E            Window [count] lines downwards in the buffer
  1215. X
  1216. XCTRL-D            Window Downwards in the buffer. The number of lines
  1217. X            comes from the 'scroll' option (default: half a
  1218. X            screen). If [count] given, first set 'scroll' option
  1219. X            to [count].
  1220. X
  1221. X<SC_DOWN>    or
  1222. XCTRL-F            Window [count] pages Forwards (downwards) in the
  1223. X            buffer.
  1224. X
  1225. XMove edit window upwards (this means that more lines upwards in the text
  1226. Xbuffer are seen): 
  1227. X
  1228. XCTRL-Y            Window [count] lines upwards in the buffer.
  1229. X
  1230. XCTRL-U            Window Upwards in the buffer. The number of lines
  1231. END_OF_FILE
  1232.   if test 50511 -ne `wc -c <'vim/doc/reference.doc.B'`; then
  1233.     echo shar: \"'vim/doc/reference.doc.B'\" unpacked with wrong size!
  1234.   elif test -f 'vim/doc/reference.doc.A' && test -f 'vim/doc/reference.doc.C' && test -f 'vim/doc/reference.doc.D'; then
  1235.     echo shar: Combining  \"'vim/doc/reference.doc'\" \(210836 characters\)
  1236.     cat 'vim/doc/reference.doc.A' 'vim/doc/reference.doc.B' 'vim/doc/reference.doc.C' 'vim/doc/reference.doc.D' > 'vim/doc/reference.doc'
  1237.     if test 210836 -ne `wc -c <'vim/doc/reference.doc'`; then
  1238.       echo shar: \"'vim/doc/reference.doc'\" combined with wrong size!
  1239.     else
  1240.       rm vim/doc/reference.doc.A vim/doc/reference.doc.B vim/doc/reference.doc.C vim/doc/reference.doc.D
  1241.     fi
  1242.   fi
  1243.   # end of 'vim/doc/reference.doc.B'
  1244. fi
  1245. if test -f 'vim/src/termlib.c' -a "${1}" != "-c" ; then 
  1246.   echo shar: Will not clobber existing file \"'vim/src/termlib.c'\"
  1247. else
  1248.   echo shar: Extracting \"'vim/src/termlib.c'\" \(15559 characters\)
  1249.   sed "s/^X//" >'vim/src/termlib.c' <<'END_OF_FILE'
  1250. X/* vi:sw=4:ts=4:
  1251. X   The following software is (C) 1984 Peter da Silva,
  1252. X   the Mad Australian, in the public domain. It may
  1253. X   be re-distributed for any purpose with the inclusion
  1254. X   of this notice. */
  1255. X
  1256. X/* modified by Bram Moolenaar for use with VIM - Vi Improved */
  1257. X
  1258. X/* TERMLIB: Terminal independant database. */
  1259. X
  1260. X#include "vim.h"
  1261. X#include "proto.h"
  1262. X#include "proto/termlib.pro"
  1263. X
  1264. X#ifndef AMIGA
  1265. X# include <sgtty.h>
  1266. X#endif
  1267. X
  1268. Xstatic int    getent __PARMS((char *, char *, FILE *, int));
  1269. Xstatic int    nextent __PARMS((char *, FILE *, int));
  1270. Xstatic int    _match __PARMS((char *, char *));
  1271. Xstatic char    *_addfmt __PARMS((char *, char *, int));
  1272. Xstatic char    *_find __PARMS((char *, char *));
  1273. X
  1274. X/*
  1275. X * Global variables for termlib
  1276. X */
  1277. X
  1278. Xchar    *tent;                /* Pointer to terminal entry, set by tgetent */
  1279. Xchar    PC = 0;               /* Pad character, default NULL */
  1280. Xchar    *UP = 0, *BC = 0;     /* Pointers to UP and BC strings from database */
  1281. Xshort    ospeed;               /* Baud rate (1-16, 1=300, 16=19200), as in stty */
  1282. X
  1283. X/*
  1284. X * Module: tgetent
  1285. X *
  1286. X * Purpose: Get termcap entry for <term> into buffer at <tbuf>.
  1287. X *
  1288. X * Calling conventions: char tbuf[TBUFSZ+], term=canonical name for
  1289. X *            terminal.
  1290. X *
  1291. X * Returned values: 1 = success, -1 = can't open file,
  1292. X *            0 = can't find terminal.
  1293. X *
  1294. X * Notes
  1295. X *        Should probably supply static buffer.
  1296. X *
  1297. X *        Uses environment variables "TERM" and
  1298. X *    "TERMCAP". If TERM = term (that is, if the argument
  1299. X *    matches the environment) then it looks at TERMCAP.
  1300. X *        If TERMCAP begins with a slash, then it assumes
  1301. X *    this is the file to search rather than /etc/termcap.
  1302. X *        If TERMCAP does not begin with a slash, and it
  1303. X *    matches TERM, then this is used as the entry.
  1304. X *
  1305. X *        This could be simplified considerably for non-UNIX
  1306. X *    systems.
  1307. X */
  1308. X
  1309. X#ifdef AMIGA
  1310. X# define TERMCAPFILE "s:termcap"
  1311. X#else
  1312. X# define TERMCAPFILE "/etc/termcap"
  1313. X#endif
  1314. X
  1315. Xtgetent(tbuf, term)
  1316. X    char    *tbuf;               /* Buffer to hold termcap entry, TBUFSZ bytes max */
  1317. X    char    *term;               /* Name of terminal */
  1318. X{
  1319. X    char    tcbuf[32];           /* Temp buffer to handle */
  1320. X    char    *tcptr = tcbuf;      /* extended entries */
  1321. X    char    *tcap = TERMCAPFILE; /* Default termcap file */
  1322. X    char    *tmp;
  1323. X    FILE    *termcap;
  1324. X    int        retval = 0;
  1325. X    int        len;
  1326. X
  1327. X    if ((tmp = (char *)vimgetenv("TERMCAP")) != NULL)
  1328. X    {
  1329. X        if (*tmp == '/')            /* TERMCAP = name of termcap file */
  1330. X            tcap = tmp ;
  1331. X        else                        /* TERMCAP = termcap entry itself */
  1332. X        {
  1333. X            int tlen = strlen(term);
  1334. X
  1335. X            while (*tmp && *tmp != ':') /* Check if TERM matches */
  1336. X            {
  1337. X                while (*tmp == '|')
  1338. X                    tmp++;
  1339. X                if (_match(tmp, term) == tlen)
  1340. X                {
  1341. X                    strcpy(tbuf, tmp);
  1342. X                    tent = tbuf;
  1343. X                    return 1;
  1344. X                } 
  1345. X                else
  1346. X                    tmp = _find(tmp, ":|");
  1347. X            }
  1348. X        }
  1349. X    }
  1350. X    if (!(termcap = fopen(tcap, "r")))
  1351. X    {
  1352. X        strcpy(tbuf, tcap);
  1353. X        return -1;
  1354. X    }
  1355. X
  1356. X    len = 0;
  1357. X    while (getent(tbuf + len, term, termcap, TBUFSZ - len))
  1358. X    {
  1359. X        if ((term = tgetstr("tc", &tcptr)))         /* extended entry */
  1360. X        {
  1361. X            rewind(termcap);
  1362. X            len = strlen(tbuf);
  1363. X        }
  1364. X        else
  1365. X        {
  1366. X            retval = 1; 
  1367. X            tent = tbuf;
  1368. X            break;
  1369. X        }
  1370. X    }
  1371. X    fclose(termcap);
  1372. X    return retval;
  1373. X}
  1374. X
  1375. X    static int
  1376. Xgetent(tbuf, term, termcap, buflen)
  1377. X    char    *tbuf, *term;
  1378. X    FILE    *termcap;
  1379. X    int        buflen;
  1380. X{
  1381. X    char    *tptr;
  1382. X    int        tlen = strlen(term);
  1383. X
  1384. X    while (nextent(tbuf, termcap, buflen))   /* For each possible entry */
  1385. X    {
  1386. X        tptr = tbuf;
  1387. X        while (*tptr && *tptr != ':')    /* : terminates name field */
  1388. X        {
  1389. X            while (*tptr == '|')             /* | seperates names */
  1390. X                tptr++;
  1391. X            if (_match(tptr, term) == tlen)             /* FOUND! */
  1392. X            {
  1393. X                tent = tbuf;
  1394. X                return 1;
  1395. X            } 
  1396. X            else                           /* Look for next name */
  1397. X                tptr = _find(tptr, ":|");
  1398. X        }
  1399. X    }
  1400. X    return 0;
  1401. X}
  1402. X
  1403. X    static int
  1404. Xnextent(tbuf, termcap, buflen)         /* Read 1 entry from TERMCAP file */
  1405. X    char    *tbuf;
  1406. X    FILE    *termcap;
  1407. X    int        buflen;
  1408. X{
  1409. X    char *lbuf = tbuf;           /* lbuf=line buffer */
  1410. X                                 /* read lines straight into buffer */
  1411. X
  1412. X    while (lbuf < tbuf+buflen &&                        /* There's room and */
  1413. X          fgets(lbuf, (int)(tbuf+buflen-lbuf), termcap))        /* another line */
  1414. X    {
  1415. X        int llen = strlen(lbuf);
  1416. X
  1417. X        if (*lbuf == '#')                               /* eat comments */
  1418. X            continue;
  1419. X        if (lbuf[-1] == ':' &&                        /* and whitespace */
  1420. X            lbuf[0] == '\t' &&
  1421. X            lbuf[1] == ':')
  1422. X        {
  1423. X            strcpy(lbuf, lbuf+2);
  1424. X            llen -= 2;
  1425. X        }
  1426. X        if (lbuf[llen-2] == '\\')                  /* and continuations */
  1427. X            lbuf += llen-2;
  1428. X        else
  1429. X        {
  1430. X            lbuf[llen-1]=0;           /* no continuation, return */
  1431. X            return 1;
  1432. X        }
  1433. X    }
  1434. X
  1435. X    return 0;                                    /* ran into end of file */
  1436. X}
  1437. X
  1438. X/*
  1439. X * Module: tgetflag
  1440. X *
  1441. X * Purpose: returns flag true or false as to the existence of a given
  1442. X *        entry. used with 'bs', 'am', etc...
  1443. X *
  1444. X * Calling conventions: id is the 2 character capability id.
  1445. X *
  1446. X * Returned values: 1 for success, 0 for failure.
  1447. X */
  1448. X
  1449. Xtgetflag(id)
  1450. X    char *id;
  1451. X{
  1452. X    char    buf[256], *ptr = buf;
  1453. X
  1454. X    return tgetstr(id, &ptr) ? 1 : 0;
  1455. X}
  1456. X
  1457. X/*
  1458. X * Module: tgetnum
  1459. X *
  1460. X * Purpose: get numeric value such as 'li' or 'co' from termcap.
  1461. X *
  1462. X * Calling conventions: id = 2 character id.
  1463. X *
  1464. X * Returned values: -1 for failure, else numerical value.
  1465. X */
  1466. X
  1467. Xtgetnum(id)
  1468. Xchar *id;
  1469. X{
  1470. X    char *ptr, buf[256];
  1471. X    ptr = buf;
  1472. X
  1473. X    if (tgetstr(id, &ptr))
  1474. X        return atoi(buf);
  1475. X    else
  1476. X        return 0;
  1477. X}
  1478. X
  1479. X/*
  1480. X * Module: tgetstr
  1481. X *
  1482. X * Purpose: get terminal capability string from database.
  1483. X *
  1484. X * Calling conventions: id is the two character capability id.
  1485. X *            (*buf) points into a hold buffer for the
  1486. X *            id. the capability is copied into the buffer
  1487. X *            and (*buf) is advanced to point to the next
  1488. X *            free byte in the buffer.
  1489. X *
  1490. X * Returned values: 0 = no such entry, otherwise returns original
  1491. X *            (*buf) (now a pointer to the string).
  1492. X *
  1493. X * Notes
  1494. X *        It also decodes certain escape sequences in the buffer.
  1495. X *    they should be obvious from the code:
  1496. X *        \E = escape.
  1497. X *        \n, \r, \t, \f, \b match the 'c' escapes.
  1498. X *        ^x matches control-x (^@...^_).
  1499. X *        \nnn matches nnn octal.
  1500. X *        \x, where x is anything else, matches x. I differ
  1501. X *    from the standard library here, in that I allow ^: to match
  1502. X *    :.
  1503. X *
  1504. X */
  1505. X
  1506. Xchar *
  1507. Xtgetstr(id, buf)
  1508. Xchar    *id, **buf;
  1509. X{
  1510. X    int    len = strlen(id);
  1511. X    char *tmp=tent;
  1512. X    char *hold;
  1513. X    int        i;
  1514. X
  1515. X    do {
  1516. X        tmp = _find(tmp, ":");                     /* For each field */
  1517. X        while (*tmp == ':')                        /* skip empty fields */
  1518. X            tmp++;
  1519. X        if (!*tmp)
  1520. X            break;
  1521. X
  1522. X        if (_match(id, tmp) == len) {
  1523. X            tmp += len;                   /* find '=' '@' or '#' */
  1524. X            if (*tmp == '@')                  /* :xx@: entry for tc */
  1525. X                return 0;                   /* deleted entry */
  1526. X            hold= *buf;
  1527. X            while (*++tmp && *tmp != ':') {/* not at end of field */
  1528. X                switch(*tmp) {
  1529. X                case '\\':            /* Expand escapes here */
  1530. X                    switch(*++tmp) {
  1531. X                    case 0:        /* ignore backslashes */
  1532. X                        tmp--;    /* at end of entry */
  1533. X                        break;   /* shouldn't happen */
  1534. X                    case 'e':
  1535. X                    case 'E':                     /* ESC */
  1536. X                        *(*buf)++ = '\033'; 
  1537. X                        break;
  1538. X                    case 'n':                      /* \n */
  1539. X                        *(*buf)++ = '\n'; 
  1540. X                        break;
  1541. X                    case 'r':                      /* \r */
  1542. X                        *(*buf)++ = '\r'; 
  1543. X                        break;
  1544. X                    case 't':                      /* \t */
  1545. X                        *(*buf)++ = '\t'; 
  1546. X                        break;
  1547. X                    case 'b':                      /* \b */
  1548. X                        *(*buf)++ = '\b'; 
  1549. X                        break;
  1550. X                    case 'f':                      /* \f */
  1551. X                        *(*buf)++ = '\f'; 
  1552. X                        break;
  1553. X                    case '0':                    /* \nnn */
  1554. X                    case '1': 
  1555. X                    case '2': 
  1556. X                    case '3': 
  1557. X                    case '4':
  1558. X                    case '5': 
  1559. X                    case '6': 
  1560. X                    case '7': 
  1561. X                    case '8': 
  1562. X                    case '9':
  1563. X                        **buf = 0;
  1564. X                            /* get up to three digits */
  1565. X                        for (i = 0; i < 3 && isdigit(*tmp); ++i)
  1566. X                            **buf = **buf * 8 + *tmp++ - '0';
  1567. X                        (*buf)++;
  1568. X                        tmp--;
  1569. X                        break;
  1570. X                    default:      /* \x, for all other x */
  1571. X                        *(*buf)++= *tmp;
  1572. X                    }
  1573. X                    break;
  1574. X                case '^':              /* control characters */
  1575. X                    *(*buf)++ = *++tmp - '@'; 
  1576. X                    break;
  1577. X                default: 
  1578. X                    *(*buf)++ = *tmp;
  1579. X                }
  1580. X            }
  1581. X            *(*buf)++ = 0;
  1582. X            return hold;
  1583. X        }
  1584. X    } while (*tmp);
  1585. X
  1586. X    return 0;
  1587. X}
  1588. X
  1589. X/*
  1590. X * Module: tgoto
  1591. X *
  1592. X * Purpose: decode cm cursor motion string.
  1593. X *
  1594. X * Calling conventions: cm is cursor motion string.
  1595. X *            line, col, are the desired destination.
  1596. X *
  1597. X * Returned values: a string pointing to the decoded string, or
  1598. X *            "OOPS" if it cannot be decoded.
  1599. X *
  1600. X * Notes
  1601. X *        The accepted escapes are:
  1602. X *            %d     as in printf, 0 origin.
  1603. X *            %2, %3     like %02d, %03d in printf.
  1604. X *            %.     like %c
  1605. X *            %+x     adds <x> to value, then %.
  1606. X *            %>xy     if value>x, adds y. No output.
  1607. X *            %i     increments line& col, no output.
  1608. X *            %r     reverses order of line&col. No output.
  1609. X *            %%     prints as a single %.
  1610. X *            %n     exclusive or row & col with 0140.
  1611. X *            %B     BCD, no output.
  1612. X *            %D     reverse coding (x-2*(x%16)), no output.
  1613. X */
  1614. X
  1615. Xchar *
  1616. Xtgoto(cm, col, line)
  1617. Xchar    *cm;                                      /* cm string, from termcap */
  1618. Xint    col,                                           /* column, x position */
  1619. X    line;                                            /* line, y position */
  1620. X{
  1621. X    char    gx, gy,                                           /*    x, y */
  1622. X        *ptr,                                     /* pointer in 'cm' */
  1623. X        reverse = 0,                                 /* reverse flag */
  1624. X        *bufp,                         /* pointer in returned string */
  1625. X        addup = 0,                                     /* add upline */
  1626. X        addbak = 0,                                    /* add backup */
  1627. X        c;
  1628. X    static char buffer[32];
  1629. X
  1630. X    if (!cm)
  1631. X        return "OOPS";                       /* Kludge, but standard */
  1632. X
  1633. X    bufp = buffer;
  1634. X    ptr = cm;
  1635. X
  1636. X    while (*ptr) {
  1637. X        if ((c = *ptr++) != '%') {                     /* normal char */
  1638. X            *bufp++ = c;
  1639. X        } else {                                         /* % escape */
  1640. X            switch(c = *ptr++) {
  1641. X            case 'd':                                 /* decimal */
  1642. X                bufp = _addfmt(bufp, "%d", line);
  1643. X                line = col;
  1644. X                break;
  1645. X            case '2':                         /* 2 digit decimal */
  1646. X                bufp = _addfmt(bufp, "%02d", line);
  1647. X                line = col;
  1648. X                break;
  1649. X            case '3':                         /* 3 digit decimal */
  1650. X                bufp = _addfmt(bufp, "%03d", line);
  1651. X                line = col;
  1652. X                break;
  1653. X            case '>':                      /* %>xy: if >x, add y */
  1654. X                gx = *ptr++;
  1655. X                gy = *ptr++;
  1656. X                if (col>gx) col += gy;
  1657. X                if (line>gx) line += gy;
  1658. X                break;
  1659. X            case '+':                              /* %+c: add c */
  1660. X                line += *ptr++;
  1661. X            case '.':                               /* print x/y */
  1662. X                if (line == '\t' ||                /* these are */
  1663. X                   line == '\n' ||             /* chars that */
  1664. X                   line == '\004' ||             /* UNIX hates */
  1665. X                   line == '\0') {
  1666. X                    line++;         /* so go to next pos */
  1667. X                    if (reverse == (line == col))
  1668. X                        addup=1;      /* and mark UP */
  1669. X                    else
  1670. X                        addbak=1;           /* or BC */
  1671. X                }
  1672. X                *bufp++=line;
  1673. X                line = col;
  1674. X                break;
  1675. X            case 'r':                              /* r: reverse */
  1676. X                gx = line; 
  1677. X                line = col; 
  1678. X                col = gx;
  1679. X                reverse = 1;
  1680. X                break;
  1681. X            case 'i':             /* increment (1-origin screen) */
  1682. X                col++;
  1683. X                line++;
  1684. X                break;
  1685. X            case '%':                          /* %%=% literally */
  1686. X                *bufp++='%';
  1687. X                break;
  1688. X            case 'n':                       /* magic DM2500 code */
  1689. X                line ^= 0140;
  1690. X                col ^= 0140;
  1691. X                break;
  1692. X            case 'B':                            /* bcd encoding */
  1693. X                line = line/10<<4+line%10;
  1694. X                col = col/10<<4+col%10;
  1695. X                break;
  1696. X            case 'D':                   /* magic Delta Data code */
  1697. X                line = line-2*(line&15);
  1698. X                col = col-2*(col&15);
  1699. X                break;
  1700. X            default:                           /* Unknown escape */
  1701. X                return "OOPS";
  1702. X            }
  1703. X        }
  1704. X    }
  1705. X
  1706. X    if (addup)                                              /* add upline */
  1707. X        if (UP) {
  1708. X            ptr=UP;
  1709. X            while (isdigit(*ptr) || *ptr == '.')
  1710. X                ptr++;
  1711. X            if (*ptr == '*')
  1712. X                ptr++;
  1713. X            while (*ptr)
  1714. X                *bufp++ = *ptr++;
  1715. X        }
  1716. X
  1717. X    if (addbak)                                          /* add backspace */
  1718. X        if (BC) {
  1719. X            ptr=BC;
  1720. X            while (isdigit(*ptr) || *ptr == '.')
  1721. X                ptr++;
  1722. X            if (*ptr == '*')
  1723. X                ptr++;
  1724. X            while (*ptr)
  1725. X                *bufp++ = *ptr++;
  1726. X        } 
  1727. X        else
  1728. X            *bufp++='\b';
  1729. X
  1730. X    *bufp = 0;
  1731. X
  1732. X    return(buffer);
  1733. X}
  1734. X
  1735. X/*
  1736. X * Module: tinit
  1737. X *
  1738. X * Purpose: simplified terminal initialisation.
  1739. X *
  1740. X * Calling conventions: name is name of terminal.
  1741. X *
  1742. X * Returned values: none.
  1743. X *
  1744. X * Notes
  1745. X *        tinit calls tgetent, then sets up the global
  1746. X *    variables PC, UP, BC, ospeed appropriately.
  1747. X *
  1748. X */
  1749. X
  1750. X#if 0        /* already included in term.c */
  1751. X
  1752. Xchar tbuf[TBUFSZ];                                /* Buffer for termcap entry */
  1753. Xchar junkbuf[TBUFSZ];                                  /* Big buffer for junk */
  1754. Xchar *junkptr;
  1755. X
  1756. Xtinit(name)
  1757. Xchar *name;
  1758. X{
  1759. X#ifndef AMIGA
  1760. X    struct sgttyb sgbuf;
  1761. X#endif
  1762. X    char *ps;
  1763. X
  1764. X    junkptr = junkbuf;
  1765. X
  1766. X    tgetent(tbuf, name);
  1767. X
  1768. X    ps = tgetstr("pc", &junkptr);
  1769. X    if (ps) PC = *ps;
  1770. X    UP = tgetstr("up", &junkptr);
  1771. X    BC = tgetstr("bc", &junkptr);
  1772. X
  1773. X#ifdef AMIGA
  1774. X    ospeed=0;
  1775. X#else
  1776. X    gtty(1, &sgbuf);
  1777. X    ospeed=sgbuf.sg_ospeed;
  1778. X#endif
  1779. X    return 0;
  1780. X}
  1781. X#endif
  1782. X
  1783. X/*
  1784. X * Module: tputs
  1785. X *
  1786. X * Purpose: decode padding information
  1787. X *
  1788. X * Calling conventions: cp = string to be padded, affcnt = # of items
  1789. X *            affected (lines, characters, whatever),
  1790. X *            outc = routine to output 1 character.
  1791. X *
  1792. X * Returned values: none
  1793. X *
  1794. X * Notes
  1795. X *        cp has padding information ahead of it, in the form
  1796. X *    nnnTEXT or nnn*TEXT. nnn is the number of milliseconds to delay,
  1797. X *    and may be a decimal (nnn.mmm). If the asterisk is given, then
  1798. X *    the delay is multiplied by afcnt. The delay is produced by outputting
  1799. X *    a number of nulls (or other padding char) after printing the
  1800. X *    TEXT.
  1801. X *
  1802. X */
  1803. X
  1804. Xlong _bauds[16]={
  1805. X    0,    50,    75,    110,
  1806. X    134,    150,    200,    300,
  1807. X    600,    1200,    1800,    2400,
  1808. X    4800,    9600,    19200,    19200 };
  1809. X
  1810. Xtputs(cp, affcnt, outc)
  1811. Xchar *cp;                                                 /* string to print */
  1812. Xint affcnt;                                      /* Number of lines affected */
  1813. Xvoid (*outc) __ARGS((unsigned int));                              /* routine to output 1 character */
  1814. X{
  1815. X    long    frac,                    /* 10^(#digits after decimal point) */
  1816. X        counter,                                           /* digits */
  1817. X        atol();
  1818. X
  1819. X    if (isdigit(*cp)) {
  1820. X        counter = 0;
  1821. X        frac = 1000;
  1822. X        while (isdigit(*cp))
  1823. X            counter = counter * 10L + (long)(*cp++ - '0');
  1824. X        if (*cp == '.')
  1825. X            while (isdigit(*++cp)) {
  1826. X                counter = counter * 10L + (long)(*cp++ - '0');
  1827. X                frac = frac * 10;
  1828. X            }
  1829. X        if (*cp!='*') {                 /* multiply by affected lines */
  1830. X            if (affcnt>1) affcnt = 1;
  1831. X        } 
  1832. X        else
  1833. X            cp++;
  1834. X
  1835. X        /* Calculate number of characters for padding counter/frac ms delay */
  1836. X        if (ospeed)
  1837. X            counter = (counter * _bauds[ospeed] * (long)affcnt) / frac;
  1838. X
  1839. X        while (*cp)                                  /* output string */
  1840. X            (*outc)(*cp++);
  1841. X        if (ospeed)
  1842. X            while (counter--)            /* followed by pad characters */
  1843. X                (*outc)(PC);
  1844. X    } 
  1845. X    else
  1846. X        while (*cp)
  1847. X            (*outc)(*cp++);
  1848. X    return 0;
  1849. X}
  1850. X
  1851. X/*
  1852. X * Module: tutil.c
  1853. X *
  1854. X * Purpose: Utility routines for TERMLIB functions.
  1855. X *
  1856. X */
  1857. X
  1858. X    static int
  1859. X_match(s1, s2)                 /* returns length of text common to s1 and s2 */
  1860. Xchar *s1, *s2;
  1861. X{
  1862. X    int i = 0;
  1863. X
  1864. X    while (s1[i] && s1[i] == s2[i])
  1865. X        i++;
  1866. X
  1867. X    return i;
  1868. X}
  1869. X
  1870. X    static char *
  1871. X_find(s, set)   /* finds next c in s that's a member of set, returns pointer */
  1872. Xchar *s, *set;
  1873. X{
  1874. X    for(; *s; s++) {
  1875. X        char    *ptr = set;
  1876. X
  1877. X        while (*ptr && *s != *ptr)
  1878. X            ptr++;
  1879. X
  1880. X        if (*ptr)
  1881. X            return s;
  1882. X    }
  1883. X
  1884. X    return s;
  1885. X}
  1886. X
  1887. X    static char *
  1888. X_addfmt(buf, fmt, val)             /* add val to buf according to format fmt */
  1889. Xchar *buf, *fmt;
  1890. Xint val;
  1891. X{
  1892. X    sprintf(buf, fmt, val);
  1893. X    while (*buf)
  1894. X        buf++;
  1895. X    return buf;
  1896. X}
  1897. END_OF_FILE
  1898.   if test 15559 -ne `wc -c <'vim/src/termlib.c'`; then
  1899.     echo shar: \"'vim/src/termlib.c'\" unpacked with wrong size!
  1900.   fi
  1901.   # end of 'vim/src/termlib.c'
  1902. fi
  1903. echo shar: End of archive 4 \(of 26\).
  1904. cp /dev/null ark4isdone
  1905. MISSING=""
  1906. 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 24 25 26 ; do
  1907.     if test ! -f ark${I}isdone ; then
  1908.     MISSING="${MISSING} ${I}"
  1909.     fi
  1910. done
  1911. if test "${MISSING}" = "" ; then
  1912.     echo You have unpacked all 26 archives.
  1913.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1914. else
  1915.     echo You still must unpack the following archives:
  1916.     echo "        " ${MISSING}
  1917. fi
  1918. exit 0
  1919. exit 0 # Just in case...
  1920.