home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Spezial / SPEZIAL2_97.zip / SPEZIAL2_97.iso / ANWEND / EDITOR / NVI179B / NVI179B.ZIP / docs / USD.doc / vi.ref / ex.cmd.roff next >
Text File  |  1996-08-17  |  41KB  |  1,925 lines

  1. .\" Copyright (c) 1994
  2. .\"    The Regents of the University of California.  All rights reserved.
  3. .\" Copyright (c) 1994, 1995, 1996
  4. .\"    Keith Bostic.  All rights reserved.
  5. .\"
  6. .\" See the LICENSE file for redistribution information.
  7. .\"
  8. .\"    @(#)ex.cmd.roff    8.41 (Berkeley) 8/17/96
  9. .\"
  10. .SH 1 "Ex Description"
  11. .pp
  12. The following words have special meanings for
  13. .CO ex
  14. commands.
  15. .KY "<end-of-file>"
  16. .IP "<end-of-file>"
  17. The end-of-file character is used to scroll the screen in the
  18. .CO ex
  19. editor.
  20. This character is normally
  21. .LI <control-D> .
  22. However, whatever character is set for the current terminal is supported
  23. as well as
  24. .LI <control-D> .
  25. .KY "line"
  26. .IP "line"
  27. A single-line address, given in any of the forms described in the
  28. section entitled
  29. .QB "Ex Addressing" .
  30. The default for
  31. .LI line
  32. is the current line.
  33. .KY "range"
  34. .IP "range"
  35. A line, or a pair of line addresses, separated by a comma or semicolon.
  36. (See the section entitled
  37. .QB "Ex Addressing"
  38. for more information.)
  39. The default for range is the current line
  40. .i only ,
  41. i.e.
  42. .QT \&.,. .
  43. A percent sign
  44. .PQ %
  45. stands for the range
  46. .QT 1,$ .
  47. The starting address must be less than, or equal to, the ending address.
  48. .KY "count"
  49. .IP "count"
  50. A positive integer, specifying the number of lines to be affected by
  51. the command; the default is 1.
  52. Generally, a count past the end-of-file may be specified, e.g. the
  53. command
  54. .QT "p 3000"
  55. in a 10 line file is acceptable, and will print from the current line
  56. through the last line in the file.
  57. .KY "flags"
  58. .IP "flags"
  59. One or more of the characters
  60. .QQ # ,
  61. .QQ p ,
  62. and
  63. .QQ l .
  64. When a command that accepts these flags completes, the addressed line(s)
  65. are written out as if by the corresponding
  66. .CO # ,
  67. .CO l
  68. or
  69. .CO p
  70. commands.
  71. In addition, any number of
  72. .QT +
  73. or
  74. .QT \-
  75. characters can be specified before, after, or during the flags, in which
  76. case the line written is not necessarily the one affected by the command,
  77. but rather the line addressed by the offset address specified.
  78. The default for
  79. .LI flags
  80. is none.
  81. .KY "file"
  82. .IP "file"
  83. A pattern used to derive a pathname; the default is the current file.
  84. File names are subjected to normal
  85. .XR sh 1
  86. word expansions.
  87. .pp
  88. Anywhere a file name is specified, it is also possible to use
  89. the special string
  90. .QT /tmp .
  91. This will be replaced with a temporary file name which can be used
  92. for temporary work, e.g.
  93. .QT ":e /tmp"
  94. creates and edits a new file.
  95. .pp
  96. If both a count and a range are specified for commands that use either,
  97. the starting line for the command is the
  98. .i last
  99. line addressed by the range, and
  100. .LI count - 1
  101. subsequent lines are affected by the command, e.g. the command
  102. .QT 2,3p4
  103. prints out lines 3, 4, 5 and 6.
  104. .pp
  105. When only a line or range is specified, with no command, the implied
  106. command is either a
  107. .CO list ,
  108. .CO number
  109. or
  110. .CO print
  111. command.
  112. The command used is the most recent of the three commands to have been
  113. used (including any use as a flag).
  114. If none of these commands have been used before, the
  115. .CO print
  116. command is the implied command.
  117. When no range or count is specified and the command line is a blank line,
  118. the current line is incremented by 1 and then the current line is displayed.
  119. .pp
  120. Zero or more whitespace characters may precede or follow the addresses,
  121. count, flags, or command name.
  122. Any object following a command name (such as buffer, file, etc.),
  123. that begins with an alphabetic character,
  124. should be separated from the command name by at least one whitespace
  125. character.
  126. .pp
  127. Any character, including
  128. .LI <carriage-return> ,
  129. .QT %
  130. and
  131. .QT #
  132. retain their literal value when preceded by a backslash.
  133. .SH 1 "Ex Commands"
  134. .pp
  135. The following section describes the commands available in the
  136. .CO ex
  137. editor.
  138. In each entry below, the tag line is a usage synopsis for the command.
  139. .pp
  140. Each command can be entered as the abbreviation
  141. (those characters in the synopsis command word preceding the
  142. .QQ [
  143. character),
  144. the full command (all characters shown for the command word,
  145. omitting the
  146. .QQ [
  147. and
  148. .QQ ]
  149. characters),
  150. or any leading subset of the full command down to the abbreviation.
  151. For example, the args command (shown as
  152. .QT ar[gs]
  153. in the synopsis)
  154. can be entered as
  155. .QT ar ,
  156. .QT arg
  157. or
  158. .QT args .
  159. .pp
  160. Each
  161. .CO ex
  162. command described below notes the new current line after it
  163. is executed, as well as any options that affect the command.
  164. .\" I cannot get a double quote to print to save my life.  The ONLY way
  165. .\" I've been able to get this to work is with the .tr command.
  166. .tr Q"
  167. .ds ms Q
  168. .KY DOUBLEQUOTE
  169. .IP "\*(ms"
  170. .tr QQ
  171. A comment.
  172. Command lines beginning with the double-quote character
  173. .PQ """"
  174. are ignored.
  175. This permits comments in editor scripts and startup files.
  176. .KY "<control-D>"
  177. .KY "<end-of-file>"
  178. .IP "<control-D>"
  179. .IP "<end-of-file>"
  180. Scroll the screen.
  181. Write the next N lines, where N is the value of the
  182. .OP scroll
  183. option.
  184. The command is the end-of-file terminal character, which may be
  185. different on different terminals.
  186. Traditionally, it is the
  187. .LI <control-D>
  188. key.
  189. .sp
  190. Historically, the
  191. .CO eof
  192. command ignored any preceding count, and the
  193. .LI <end-of-file>
  194. character was ignored unless it was entered as the first character
  195. of the command.
  196. This implementation treats it as a command
  197. .i only
  198. if entered as the first character of the command line, and otherwise
  199. treats it as any other character.
  200. .SS
  201. .SP Line:
  202. Set to the last line written.
  203. .SP Options:
  204. Affected by the
  205. .OP scroll
  206. option.
  207. .SE
  208. .KY "!"
  209. .IP "! argument(s)"
  210. .Ip "[range]! argument(s)"
  211. Execute a shell command, or filter lines through a shell command.
  212. In the first synopsis, the remainder of the line after the
  213. .QT !
  214. character is passed to the program named by the
  215. .OP shell
  216. option, as a single argument.
  217. .sp
  218. Within the rest of the line,
  219. .QT %
  220. and
  221. .QT #
  222. are expanded into the current and alternate pathnames, respectively.
  223. The character
  224. .QT !
  225. is expanded with the command text of the previous
  226. .CO !
  227. command.
  228. (Therefore, the command
  229. .CO !!
  230. repeats the previous
  231. .CO !
  232. command.)
  233. The special meanings of
  234. .QT % ,
  235. .QT # ,
  236. and
  237. .QT !
  238. can be overridden by escaping them with a backslash.
  239. If no
  240. .CO !
  241. or
  242. .CO :!
  243. command has yet been executed, it is an error to use an unescaped
  244. .QT !
  245. character.
  246. The
  247. .CO !
  248. command does
  249. .i not
  250. do shell expansion on the strings provided as arguments.
  251. If any of the above expansions change the command the user entered,
  252. the command is redisplayed at the bottom of the screen.
  253. .sp
  254. .CO Ex
  255. then executes the program named by the
  256. .OP shell
  257. option, with a
  258. .b \-c
  259. flag followed by the arguments (which are bundled into a single argument).
  260. .sp
  261. The
  262. .CO !
  263. command is permitted in an empty file.
  264. .sp
  265. If the file has been modified since it was last completely written,
  266. the
  267. .Co !
  268. command will warn you.
  269. .sp
  270. A single
  271. .QT !
  272. character is displayed when the command completes.
  273. .sp
  274. In the second form of the
  275. .CO !
  276. command, the remainder of the line after the
  277. .QT !
  278. is passed to the program named by the
  279. .OP shell
  280. option, as described above.
  281. The specified lines are passed to the program as standard input,
  282. and the standard and standard error output of the program replace
  283. the original lines.
  284. .SS
  285. .SP Line:
  286. Unchanged if no range was specified, otherwise set to the first
  287. line of the range.
  288. .SP Options:
  289. Affected by the
  290. .OP shell
  291. and
  292. .OP warn
  293. options.
  294. .SE
  295. .KY "#"
  296. .IP "[range] # [count] [flags]"
  297. .KY "number"
  298. .Ip "[range] nu[mber] [count] [flags]"
  299. Display the selected lines, each preceded with its line number.
  300. .sp
  301. The line number format is
  302. .QQ %6d ,
  303. followed by two spaces.
  304. .SS
  305. .SP Line:
  306. Set to the last line displayed.
  307. .SP Options:
  308. Affected by the
  309. .OP list
  310. option.
  311. .SE
  312. .KY "@"
  313. .IP "@ buffer"
  314. .KY "*"
  315. .Ip "* buffer"
  316. Execute a buffer.
  317. Each line in the named buffer is executed as an
  318. .CO ex
  319. command.
  320. If no buffer is specified, or if the specified buffer is
  321. .QT @
  322. or
  323. .QT * ,
  324. the last buffer executed is used.
  325. .KY <
  326. .IP "[range] <[< ...] [count] [flags]"
  327. Shift lines left or right.
  328. The specified lines are shifted to the left (for the
  329. .CO <
  330. command) or right (for the
  331. .CO >
  332. command), by the number of columns specified by the
  333. .OP shiftwidth
  334. option.
  335. Only leading whitespace characters are deleted when shifting left;
  336. once the first column of the line contains a nonblank character,
  337. the
  338. .CO shift
  339. command will succeed, but the line will not be modified.
  340. .sp
  341. If the command character
  342. .CO <
  343. or
  344. .CO >
  345. is repeated more than once, the command is repeated once for each
  346. additional command character.
  347. .SS
  348. .SP Line:
  349. If the current line is set to one of the lines that are affected
  350. by the command, it is unchanged.
  351. Otherwise, it is set to the first nonblank character of the lowest
  352. numbered line shifted.
  353. .SP Options:
  354. Affected by the
  355. .OP shiftwidth
  356. option.
  357. .SE
  358. .KY =
  359. .IP "[line] = [flags]"
  360. Display the line number of
  361. .LI line
  362. (which defaults to the last line in the file).
  363. .SS
  364. .SP Line:
  365. Unchanged.
  366. .SP Options:
  367. None.
  368. .SE
  369. .KY >
  370. .IP "[range] >[> ...] [count] [flags]"
  371. Shift right.
  372. The specified lines are shifted to the right by the number of columns
  373. specified by the
  374. .OP shiftwidth
  375. option, by inserting tab and space characters.
  376. Empty lines are not changed.
  377. .sp
  378. If the command character
  379. .QT >
  380. is repeated more than once, the command is repeated once for each
  381. additional command character.
  382. .SS
  383. .SP Line:
  384. Set to the last line modified by the command.
  385. .SP Options:
  386. Affected by the
  387. .OP shiftwidth
  388. option.
  389. .SE
  390. .KY abbrev
  391. .IP "ab[brev] lhs rhs"
  392. Add an abbreviation to the current abbreviation list.
  393. When inserting text in
  394. .CO vi ,
  395. each time a non-word character is entered after a word character,
  396. a set of characters ending at the word character are checked for
  397. a match with
  398. .LI lhs .
  399. If a match is found, they are replaced with
  400. .LI rhs .
  401. The set of characters that are checked for a match are defined as follows,
  402. for inexplicable historical reasons.
  403. If only one or two characters were entered before the non-word character
  404. that triggered the check,
  405. and after the beginning of the insertion,
  406. or the beginning of the line or the file,
  407. or the last
  408. .LI <blank>
  409. character that was entered,
  410. then the one or the both characters are checked for a match.
  411. Otherwise, the set includes both characters,
  412. as well as the characters that precede them that are the same word
  413. class (i.e. word or non-word) as the
  414. .b second
  415. to last character entered before the non-word character that triggered
  416. the check,
  417. back to the first
  418. .LI <blank> character,
  419. the beginning of the insertion,
  420. or the beginning of the line or the file.
  421. .sp
  422. For example, the abbreviations:
  423. .sp
  424. .ne 3v
  425. .ft C
  426. .TS
  427. r l l.
  428. :abbreviate    abc    ABC
  429. :abbreviate    #i    #include
  430. :abbreviate    /*#i    /*#include
  431. .TE
  432. .ft R
  433. will all work, while the abbreviations:
  434. .sp
  435. .ne 2v
  436. .ft C
  437. .TS
  438. r l l.
  439. :abbreviate    a#i    A#include
  440. :abbreviate    /*    /********************
  441. .TE
  442. .ft R
  443. will not work, and are not permitted by
  444. .CO nvi .
  445. .sp
  446. To keep the abbreviation expansion from happening,
  447. the character immediately following the
  448. .LI lhs
  449. characters should be quoted with a
  450. .LI <literal-next>
  451. character.
  452. .sp
  453. The replacement
  454. .LI rhs
  455. is itself subject to both further abbreviation expansion and further
  456. map expansion.
  457. .SS
  458. .SP Line:
  459. Unchanged.
  460. .SP Options:
  461. None.
  462. .SE
  463. .KY append
  464. .IP "[line] a[ppend][!]"
  465. The input text is appended to the specified line.
  466. If line 0 is specified, the text is inserted at the beginning of the file.
  467. Set to the last line input.
  468. If no lines are input, then set to
  469. .LI line ,
  470. or to the first line of the file if a
  471. .LI line
  472. of 0 was specified.
  473. Following the command name with a
  474. .QT !
  475. character causes the
  476. .OP autoindent
  477. option to be toggled for the duration of the command.
  478. .SS
  479. .SP Line:
  480. Unchanged.
  481. .SP Options:
  482. Affected by the
  483. .OP autoindent
  484. and
  485. .OP number
  486. options.
  487. .SE
  488. .KY args
  489. .IP "ar[gs]"
  490. Display the argument list.
  491. The current argument is displayed inside of
  492. .QT [
  493. and
  494. .QT ]
  495. characters.
  496. The argument list is the list of operands specified on startup,
  497. which can be replaced using the
  498. .CO next
  499. command.
  500. .SS
  501. .SP Line:
  502. Unchanged.
  503. .SP Options:
  504. None.
  505. .SE
  506. .KY bg
  507. .IP bg
  508. .CO Vi
  509. mode only.
  510. Background the current screen.
  511. The screen is unchanged,
  512. but is no longer accessible and disappears from the display.
  513. Use the
  514. .CO fg
  515. command to bring the screen back to the display foreground.
  516. .SS
  517. .SP Line:
  518. Set to the current line when the screen was last edited.
  519. .SP Options:
  520. None.
  521. .SE
  522. .KY change
  523. .IP "[range] c[hange][!] [count]"
  524. Replace the lines with input text.
  525. Following the command name with a
  526. .QT !
  527. character causes the
  528. .OP autoindent
  529. option to be toggled for the duration of the command.
  530. .SS
  531. .SP Line:
  532. Set to the last line input, or, if no lines were input,
  533. set to the line before the target line, or to the first
  534. line of the file if there are no lines preceding the target line.
  535. .SP Options:
  536. Affected by the
  537. .OP autoindent
  538. and
  539. .OP number
  540. options.
  541. .SE
  542. .KY cd
  543. .KY chdir
  544. .IP "chd[ir][!] [directory]"
  545. .Ip "cd[!] [directory]"
  546. Change the current working directory.
  547. The
  548. .LI directory
  549. argument is subjected to
  550. .XR sh 1
  551. word expansions.
  552. When invoked with no directory argument and the
  553. .LI HOME
  554. environment variable is set, the directory named by the
  555. .LI HOME
  556. environment variable becomes the new current directory.
  557. Otherwise, the new current directory becomes the directory returned
  558. by the
  559. .XR getpwent 3
  560. routine.
  561. .sp
  562. The
  563. .CO chdir
  564. command will fail if the file has been modified since the last complete
  565. write of the file.
  566. You can override this check by appending a
  567. .QT !
  568. character to the command.
  569. .SS
  570. .SP Line:
  571. Unchanged.
  572. .SP Options:
  573. Affected by the
  574. .OP cdpath
  575. option.
  576. .SE
  577. .KY copy
  578. .KY t
  579. .IP "[range] co[py] line [flags]"
  580. .Ip "[range] t line [flags]"
  581. Copy the specified lines (range) after the destination line.
  582. Line 0 may be specified to insert the lines at the beginning of
  583. the file.
  584. .SS
  585. .SP Line:
  586. Unchanged.
  587. .SP Options:
  588. None.
  589. .SE
  590. .KY cscope
  591. .IP "cs[cope] command [args]"
  592. Execute a
  593. .CO cscope
  594. command.
  595. For more information, see the section of the reference manual entitled
  596. .QB "Tags, Tag Stacks, and Cscope" .
  597. .KY delete
  598. .IP "[range] d[elete] [buffer] [count] [flags]"
  599. Delete the lines from the file.
  600. The deleted text is saved in the specified buffer, or, if no buffer
  601. is specified, in the unnamed buffer.
  602. If the command name is followed by a letter that could be interpreted
  603. as either a buffer name or a flag value (because neither a
  604. .LI count
  605. or
  606. .LI flags
  607. values were given),
  608. .CO ex
  609. treats the letter as a
  610. .LI flags
  611. value if the letter immediately follows the command name,
  612. without any whitespace separation.
  613. If the letter is preceded by whitespace characters,
  614. it treats it as a buffer name.
  615. .SS
  616. .SP Line:
  617. Set to the line following the deleted lines,
  618. or to the last line if the deleted lines were at the end.
  619. .SP Options:
  620. None.
  621. .SE
  622. .KY display
  623. .IP "di[splay] b[uffers] | c[onnections] | s[creens] | t[ags]"
  624. Display buffers,
  625. .CO cscope
  626. connections, screens or tags.
  627. The
  628. .CO display
  629. command takes one of three additional arguments, which are as follows:
  630. .SS
  631. .SP b[uffers]
  632. Display all buffers (including named, unnamed, and numeric)
  633. that contain text.
  634. .SP c[onnections]
  635. Display the source directories for all attached
  636. .CO cscope
  637. databases.
  638. .SP s[creens]
  639. Display the file names of all background screens.
  640. .SP t[ags]
  641. Display the tags stack.
  642. .SE
  643. .SS
  644. .SP Line:
  645. Unchanged.
  646. .SP Options:
  647. None.
  648. .SE
  649. .KY edit
  650. .IP "e[dit][!] [+cmd] [file]"
  651. .Ip "ex[!] [+cmd] [file]"
  652. Edit a different file.
  653. If the current buffer has been modified since the last complete write,
  654. the command will fail.
  655. You can override this by appending a
  656. .QT !
  657. character to the command name.
  658. .sp
  659. If the
  660. .QT +cmd
  661. option is specified, that
  662. .CO ex
  663. command will be executed in the new file.
  664. Any
  665. .CO ex
  666. command may be used, although the most common use of this feature is
  667. to specify a line number or search pattern to set the initial location
  668. in the new file.
  669. .sp
  670. Capitalizing the first letter of the command, i.e.
  671. .CO Edit
  672. or
  673. .CO Ex ,
  674. while in
  675. .CO vi
  676. mode, will edit the file in a new screen.
  677. In this case, any modifications to the current file are ignored.
  678. .SS
  679. .SP Line:
  680. If you have previously edited the file, the current line will be set
  681. to your last position in the file.
  682. If that position does not exist, or you have not previously edited the
  683. file, the current line will be set to the first line of the file if
  684. you are in
  685. .CO vi
  686. mode, and the last line of the file if you are in
  687. .CO ex .
  688. .SP Options:
  689. None.
  690. .SE
  691. .KY exusage
  692. .IP "exu[sage] [command]"
  693. Display usage for an
  694. .CO ex
  695. command.
  696. If
  697. .LI command
  698. is specified, a usage statement for that command is displayed.
  699. Otherwise, usage statements for all
  700. .CO ex
  701. commands are displayed.
  702. .SS
  703. .SP Line:
  704. Unchanged.
  705. .SP Options:
  706. None.
  707. .SE
  708. .KY file
  709. .IP "f[ile] [file]"
  710. Display and optionally change the file name.
  711. If a file name is specified, the current pathname is changed to the
  712. specified name.
  713. The current pathname, the number of lines, and the current position
  714. in the file are displayed.
  715. .SS
  716. .SP Line:
  717. Unchanged.
  718. .SP Options:
  719. None.
  720. .SE
  721. .KY fg
  722. .IP "fg [name]"
  723. .CO Vi
  724. mode only.
  725. Foreground the specified screen.
  726. If the argument name doesn't exactly match the name of a file displayed
  727. by a background screen,
  728. it is compared against the last component of each of the file names.
  729. If no background screen is specified,
  730. the first background screen is foregrounded.
  731. .sp
  732. By default,
  733. foregrounding causes the current screen to be swapped with the backgrounded
  734. screen.
  735. Capitalizing the first letter of the command, i.e.
  736. .CO Fg ,
  737. will foreground the backgrounded screen in a new screen instead of
  738. swapping it with the current screen.
  739. .SS
  740. .SP Line:
  741. Set to the current line when the screen was last edited.
  742. .SP Options:
  743. None.
  744. .SE
  745. .KY global
  746. .IP "[range] g[lobal] /pattern/ [commands]"
  747. .KY v
  748. .Ip "[range] v /pattern/ [commands]"
  749. Apply commands to lines matching (or not matching) a pattern.
  750. The lines within the given range that match
  751. .PQ g[lobal] ,
  752. or do not match
  753. .PQ v
  754. the given pattern are selected.
  755. Then, the specified
  756. .CO ex
  757. command(s) are executed with the current line
  758. .PQ \&.
  759. set to each selected line.
  760. If no range is specified, the entire file is searched for matching,
  761. or not matching, lines.
  762. .sp
  763. Multiple commands can be specified, one per line, by escaping each
  764. .LI <newline>
  765. character with a backslash, or by separating commands with a
  766. .QT |
  767. character.
  768. If no commands are specified, the command defaults to the
  769. .CO print
  770. command.
  771. .sp
  772. For the
  773. .CO append ,
  774. .CO change
  775. and
  776. .CO insert
  777. commands, the input text must be part of the global command line.
  778. In this case, the terminating period can be omitted if it ends the commands.
  779. .sp
  780. The
  781. .CO visual
  782. command may also be specified as one of the
  783. .CO ex
  784. commands.
  785. In this mode, input is taken from the terminal.
  786. Entering a
  787. .CO Q
  788. command in
  789. .CO vi
  790. mode causes the next line matching the pattern to be selected and
  791. .CO vi
  792. to be reentered, until the list is exhausted.
  793. .sp
  794. The
  795. .CO global ,
  796. .CO v
  797. and
  798. .CO undo
  799. commands cannot be used as part of these commands.
  800. .sp
  801. The editor options
  802. .OP autoindent ,
  803. .OP autoprint
  804. and
  805. .OP report
  806. are turned off for the duration of the
  807. .CO global
  808. and
  809. .CO v
  810. commands.
  811. .SS
  812. .SP Line:
  813. The last line modified.
  814. .SP Options:
  815. Affected by the
  816. .OP ignorecase
  817. and
  818. .OP magic
  819. options.
  820. Turns off the
  821. .OP autoindent ,
  822. .OP autoprint
  823. and
  824. .OP report
  825. options.
  826. .SE
  827. .KY help
  828. .IP "he[lp]"
  829. Display a help message.
  830. .SS
  831. .SP Line:
  832. Unchanged.
  833. .SP Options:
  834. None.
  835. .SE
  836. .KY insert
  837. .IP "[line] i[nsert][!]"
  838. The input text is inserted before the specified line.
  839. Following the command name with a
  840. .QT !
  841. character causes the
  842. .OP autoindent
  843. option setting to be toggled for the duration of this command.
  844. .SS
  845. .SP Line:
  846. Set to the last line input; if no lines were input,
  847. set to the line before the target line, or to the first line
  848. of the file if there are no lines preceding the target line.
  849. Affected by the
  850. .OP autoindent
  851. and
  852. .OP number
  853. options.
  854. .SE
  855. .KY join
  856. .IP "[range] j[oin][!] [count] [flags]"
  857. Join lines of text together.
  858. .sp
  859. A
  860. .LI count
  861. specified to the
  862. .Sy join
  863. command specifies that the last line of the
  864. .LI range
  865. plus
  866. .LI count
  867. subsequent lines will be joined.
  868. (Note, this differs by one from the general rule where only
  869. .LI count - 1
  870. subsequent lines are affected.)
  871. .sp
  872. If the current line ends with a whitespace character, all whitespace
  873. is stripped from the next line.
  874. Otherwise, if the next line starts with a open parenthesis
  875. .PQ ( ,
  876. do nothing.
  877. Otherwise, if the current line ends with a question mark
  878. .PQ ? ,
  879. period
  880. .PQ \&.
  881. or exclamation point
  882. .PQ ! ,
  883. insert two spaces.
  884. Otherwise, insert a single space.
  885. .sp
  886. Appending a
  887. .QT !
  888. character to the command name causes a simpler join with no
  889. white-space processing.
  890. .SS
  891. .SP Line:
  892. Unchanged.
  893. .SP Options:
  894. None.
  895. .SE
  896. .KY list
  897. .IP "[range] l[ist] [count] [flags]"
  898. Display the lines unambiguously.
  899. Tabs are displayed as
  900. .QT ^I ,
  901. and the end of the line is marked with a
  902. .QT $
  903. character.
  904. .SS
  905. .SP Line:
  906. Set to the last line displayed.
  907. .SP Options:
  908. Affected by the
  909. .OP number
  910. option.
  911. .SE
  912. .KY map
  913. .IP "map[!] [lhs rhs]"
  914. Define or display maps (for
  915. .CO vi
  916. only).
  917. .sp
  918. If
  919. .QT lhs
  920. and
  921. .QT rhs
  922. are not specified, the current set of command mode maps are displayed.
  923. If a
  924. .QT !
  925. character is appended to to the command,
  926. the text input mode maps are displayed.
  927. .sp
  928. Otherwise, when the
  929. .QT lhs
  930. character sequence is entered in
  931. .CO vi ,
  932. the action is as if the corresponding
  933. .QT rhs
  934. had been entered.
  935. If a
  936. .QT !
  937. character is appended to the command name,
  938. the mapping is effective during text input mode,
  939. otherwise, it is effective during command mode.
  940. This allows
  941. .QT lhs
  942. to have two different macro definitions at the same time: one for command
  943. mode and one for input mode.
  944. .sp
  945. Whitespace characters require escaping with a
  946. .LI <literal-next>
  947. character to be entered in the
  948. .LI lhs
  949. string in visual mode.
  950. .sp
  951. Normally, keys in the
  952. .LI rhs
  953. string are remapped (see the
  954. .OP remap
  955. option),
  956. and it is possible to create infinite loops.
  957. However, keys which map to themselves are not further remapped,
  958. regardless of the setting of the
  959. .OP remap
  960. option.
  961. For example, the command
  962. .QT ":map n nz."
  963. maps the
  964. .QT n
  965. key to the
  966. .CO n
  967. and
  968. .CO z
  969. commands.
  970. .sp
  971. To exit an infinitely looping map, use the terminal
  972. .LI <interrupt>
  973. character.
  974. .SS
  975. .SP Line:
  976. Unchanged.
  977. .SP Options:
  978. Affected by the
  979. .OP remap
  980. option.
  981. .SE
  982. .KY mark
  983. .KY k
  984. .IP "[line] ma[rk] <character>"
  985. .Ip "[line] k <character>"
  986. Mark the line with the mark
  987. .LI <character> .
  988. The expressions
  989. .QT '<character>
  990. and
  991. .QT `<character>
  992. can then be used as an address in any command that uses one.
  993. .SS
  994. .SP Line:
  995. Unchanged.
  996. .SP Options:
  997. None.
  998. .SE
  999. .KY move
  1000. .IP "[range] m[ove] line"
  1001. Move the specified lines after the target line.
  1002. A target line of 0 places the lines at the beginning of the file.
  1003. .SS
  1004. .SP Line:
  1005. Set to the first of the moved lines.
  1006. .SP Options:
  1007. None.
  1008. .SE
  1009. .KY mkexrc
  1010. .IP "mk[exrc][!] file"
  1011. Write the abbreviations, editor options and maps to the specified
  1012. file.
  1013. Information is written in a form which can later be read back in
  1014. using the
  1015. .CO ex
  1016. .CO source
  1017. command.
  1018. If
  1019. .LI file
  1020. already exists, the
  1021. .CO mkexrc
  1022. command will fail.
  1023. This check can be overridden by appending a
  1024. .QT !
  1025. character to the command.
  1026. .SS
  1027. .SP Line:
  1028. Unchanged.
  1029. .SP Options:
  1030. None.
  1031. .SE
  1032. .KY next
  1033. .IP "n[ext][!] [file ...]"
  1034. Edit the next file from the argument list.
  1035. The
  1036. .CO next
  1037. command will fail if the file has been modified since the last complete
  1038. write.
  1039. This check can be overridden by appending the
  1040. .QT !
  1041. character to the command name.
  1042. The argument list can optionally be replaced by specifying a new one
  1043. as arguments to this command.
  1044. In this case, editing starts with the first file on the new list.
  1045. .sp
  1046. Capitalizing the first letter of the command, i.e.
  1047. .CO Next ,
  1048. while in
  1049. .CO vi
  1050. mode, will set the argument list and edit the file in a new screen.
  1051. In this case, any modifications to the current file are ignored.
  1052. .SS
  1053. .SP Line:
  1054. Set as described for the
  1055. .CO edit
  1056. command.
  1057. .SP Options:
  1058. Affected by the options
  1059. .OP autowrite
  1060. and
  1061. .OP writeany .
  1062. .SE
  1063. .KY open
  1064. .IP "[line] o[pen] /pattern/ [flags]"
  1065. Enter open mode.
  1066. Open mode is the same as being in
  1067. .CO vi ,
  1068. but with a one-line window.
  1069. All the standard
  1070. .CO vi
  1071. commands are available.
  1072. If a match is found for the optional RE argument,
  1073. the cursor is set to the start of the matching pattern.
  1074. .sp
  1075. .i "This command is not yet implemented."
  1076. .SS
  1077. .SP Line:
  1078. Unchanged, unless the optional RE is specified, in which case it is
  1079. set to the line where the matching pattern is found.
  1080. .SP Options:
  1081. Affected by the
  1082. .OP open
  1083. option.
  1084. .SE
  1085. .KY preserve
  1086. .IP "pre[serve]"
  1087. Save the file in a form that can later be recovered using the
  1088. .CO ex
  1089. .b \-r
  1090. option.
  1091. When the file is preserved, an email message is sent to the user.
  1092. .SS
  1093. .SP Line:
  1094. Unchanged.
  1095. .SP Options:
  1096. None.
  1097. .SE
  1098. .KY previous
  1099. .IP "prev[ious][!]"
  1100. Edit the previous file from the argument list.
  1101. The
  1102. .CO previous
  1103. command will fail if the file has been modified since the last complete
  1104. write.
  1105. This check can be overridden by appending the
  1106. .QT !
  1107. character to the command name.
  1108. .sp
  1109. Capitalizing the first letter of the command, i.e.
  1110. .CO Previous ,
  1111. while in
  1112. .CO vi
  1113. mode, will edit the file in a new screen.
  1114. In this case, any modifications to the current file are ignored.
  1115. .SS
  1116. .SP Line:
  1117. Set as described for the
  1118. .CO edit
  1119. command.
  1120. .SP Options:
  1121. Affected by the options
  1122. .OP autowrite
  1123. and
  1124. .OP writeany .
  1125. None.
  1126. .SE
  1127. .KY print
  1128. .IP "[range] p[rint] [count] [flags]"
  1129. Display the specified lines.
  1130. .SS
  1131. .SP Line:
  1132. Set to the last line displayed.
  1133. .SP Options:
  1134. Affected by the
  1135. .OP list
  1136. and
  1137. .OP number
  1138. option.
  1139. .SE
  1140. .KY put
  1141. .IP "[line] pu[t] [buffer]"
  1142. Append buffer contents to the current line.
  1143. If a buffer is specified, its contents are appended to the line,
  1144. otherwise, the contents of the unnamed buffer are used.
  1145. .SS
  1146. .SP Line:
  1147. Set to the line after the current line.
  1148. .SP Options:
  1149. None.
  1150. .SE
  1151. .KY quit
  1152. .IP "q[uit][!]"
  1153. End the editing session.
  1154. If the file has been modified since the last complete write, the
  1155. .CO quit
  1156. command will fail.
  1157. This check may be overridden by appending a
  1158. .QT !
  1159. character to the command.
  1160. .sp
  1161. If there are more files to edit, the
  1162. .CO quit
  1163. command will fail.
  1164. Appending a
  1165. .QT !
  1166. character to the command name or entering two
  1167. .CO quit
  1168. commands (i.e.
  1169. .CO wq ,
  1170. .CO quit ,
  1171. .CO xit
  1172. or
  1173. .CO ZZ )
  1174. in a row) will override this check and the editor will exit.
  1175. .SS
  1176. .SP Line:
  1177. Unchanged.
  1178. .SP Options:
  1179. None.
  1180. .SE
  1181. .KY read
  1182. .IP "[line] r[ead][!] [file]"
  1183. Read a file.
  1184. A copy of the specified file is appended to the line.
  1185. If
  1186. .LI line
  1187. is 0, the copy is inserted at the beginning of the file.
  1188. If no file is specified, the current file is read; if there is no
  1189. current file, then
  1190. .LI file
  1191. becomes the current file.
  1192. If there is no current file and no
  1193. .LI file
  1194. is specified, then the
  1195. .CO read
  1196. command will fail.
  1197. .sp
  1198. If
  1199. .LI file
  1200. is preceded by a
  1201. .QT !
  1202. character,
  1203. .LI file
  1204. is treated as if it were a shell command, and passed to the program
  1205. named by the
  1206. .OP shell
  1207. edit option.
  1208. The standard and standard error outputs of that command are read into
  1209. the file after the specified line.
  1210. The special meaning of the
  1211. .QT !
  1212. character can be overridden by escaping it with a backslash
  1213. .PQ \e
  1214. character.
  1215. .SS
  1216. .SP Line:
  1217. When executed from
  1218. .CO ex ,
  1219. the current line is set to the last line read.
  1220. When executed from
  1221. .CO vi ,
  1222. the current line is set to the first line read.
  1223. .SP Options:
  1224. None.
  1225. .SE
  1226. .KY recover
  1227. .IP "rec[over] file"
  1228. Recover
  1229. .LI file
  1230. if it was previously saved.
  1231. If no saved file by that name exists, the
  1232. .CO recover
  1233. command behaves equivalently to the
  1234. .CO edit
  1235. command.
  1236. .SS
  1237. .SP Line:
  1238. Set as described for the
  1239. .CO edit
  1240. command.
  1241. .SP Options:
  1242. None.
  1243. .SE
  1244. .KY resize
  1245. .IP "res[ize] [+|-]size"
  1246. .CO Vi
  1247. mode only.
  1248. Grow or shrink the current screen.
  1249. If
  1250. .LI size
  1251. is a positive, signed number, the current screen is grown by that many lines.
  1252. If
  1253. .LI size
  1254. is a negative, signed number, the current screen is shrunk by that many lines.
  1255. If
  1256. .LI size
  1257. is not signed, the current screen is set to the specified
  1258. .LI size .
  1259. Applicable only to split screens.
  1260. .SS
  1261. .SP Line:
  1262. Unchanged.
  1263. .SP Options:
  1264. None.
  1265. .SE
  1266. .KY rewind
  1267. .IP "rew[ind][!]"
  1268. Rewind the argument list.
  1269. If the current file has been modified since the last complete write,
  1270. the
  1271. .CO rewind
  1272. command will fail.
  1273. This check may be overridden by appending the
  1274. .QT !
  1275. character to the command.
  1276. .sp
  1277. Otherwise, the current file is set to the first file in the argument
  1278. list.
  1279. .SS
  1280. .SP Line:
  1281. Set as described for the
  1282. .CO edit
  1283. command.
  1284. .SP Options:
  1285. Affected by the
  1286. .OP autowrite
  1287. and
  1288. .OP writeany
  1289. options.
  1290. .SE
  1291. .KY set
  1292. .IP "se[t] [option[=[value]] ...] [nooption ...] [option? ...] [all]"
  1293. Display or set editor options.
  1294. When no arguments are specified, the editor option
  1295. .OP term ,
  1296. and any editor options whose values have been changed from the
  1297. default settings are displayed.
  1298. If the argument
  1299. .LI all
  1300. is specified, the values of all of editor options are displayed.
  1301. .sp
  1302. Specifying an option name followed by the character
  1303. .QT ?
  1304. causes the current value of that option to be displayed.
  1305. The
  1306. .QT ?
  1307. can be separated from the option name by whitespace characters.
  1308. The
  1309. .QT ?
  1310. is necessary only for Boolean valued options.
  1311. Boolean options can be given values by the form
  1312. .QT "set option"
  1313. to turn them on, or
  1314. .QT "set nooption"
  1315. to turn them off.
  1316. String and numeric options can be assigned by the form
  1317. .QT "set option=value" .
  1318. Any whitespace characters in strings can be included literally by preceding
  1319. each with a backslash.
  1320. More than one option can be set or listed by a single set command,
  1321. by specifying multiple arguments, each separated from the next by
  1322. whitespace characters.
  1323. .SS
  1324. .SP Line:
  1325. Unchanged.
  1326. .SP Options:
  1327. None.
  1328. .SE
  1329. .KY shell
  1330. .IP "sh[ell]"
  1331. Run the shell program.
  1332. The program named by the
  1333. .OP shell
  1334. option is run with a
  1335. .b \-i
  1336. (for interactive) flag.
  1337. Editing is resumed when that program exits.
  1338. .SS
  1339. .SP Line:
  1340. Unchanged.
  1341. .SP Options:
  1342. Affected by the
  1343. .OP shell
  1344. option.
  1345. .SE
  1346. .KY source
  1347. .IP "so[urce] file"
  1348. Read and execute
  1349. .CO ex
  1350. commands from a file.
  1351. .CO Source
  1352. commands may be nested.
  1353. .SS
  1354. .SP Line:
  1355. Unchanged.
  1356. .SP Options:
  1357. None.
  1358. .SE
  1359. .KY substitute
  1360. .IP "[range] s[ubstitute] [/pattern/replace/] [options] [count] [flags]"
  1361. .KY &
  1362. .Ip "[range] & [options] [count] [flags]"
  1363. .KY ~
  1364. .Ip "[range] ~ [options] [count] [flags]"
  1365. Make substitutions.
  1366. Replace the first instance of
  1367. .LI pattern
  1368. with the string
  1369. .LI replace
  1370. on the specified line(s).
  1371. If the
  1372. .QT /pattern/repl/
  1373. argument is not specified, the
  1374. .QT /pattern/repl/
  1375. from the previous
  1376. .CO substitute
  1377. command is used.
  1378. Any character other than an alphabetic, numeric, <blank> or backslash
  1379. character may be used as the delimiter.
  1380. .sp
  1381. If
  1382. .LI options
  1383. includes the letter
  1384. .QT c
  1385. (confirm), you will be prompted for confirmation before each replacement
  1386. is done.
  1387. An affirmative response (in English, a
  1388. .QT y
  1389. character) causes the replacement to be made.
  1390. A quit response (in English, a
  1391. .QT q
  1392. character) causes the
  1393. .CO substitute
  1394. command to be terminated.
  1395. Any other response causes the replacement not to be made, and the
  1396. .CO substitute
  1397. command continues.
  1398. If
  1399. .LI options
  1400. includes the letter
  1401. .QT g
  1402. (global), all nonoverlapping instances of
  1403. .LI pattern
  1404. in the line are replaced.
  1405. .sp
  1406. The
  1407. .CO &
  1408. version of the command is the same as not specifying a pattern
  1409. or replacement string to the
  1410. .CO substitute
  1411. command, and the
  1412. .QT &
  1413. is replaced by the pattern and replacement information from the
  1414. previous substitute command.
  1415. .sp
  1416. The
  1417. .CO ~
  1418. version of the command is the same as
  1419. .CO &
  1420. and
  1421. .CO s ,
  1422. except that the search pattern used is the last RE used in
  1423. .i any
  1424. command, not necessarily the one used in the last
  1425. .CO substitute
  1426. command.
  1427. .sp
  1428. For example, in the sequence
  1429. .ft C
  1430. .(b
  1431. s/red/blue/
  1432. /green
  1433. ~
  1434. .)b
  1435. .ft R
  1436. the
  1437. .QT ~
  1438. is equivalent to
  1439. .QT s/green/blue/ .
  1440. .sp
  1441. The
  1442. .CO substitute
  1443. command may be interrupted, using the terminal interrupt character.
  1444. All substitutions completed before the interrupt are retained.
  1445. .SS
  1446. .SP Line:
  1447. Set to the last line upon which a substitution was made.
  1448. .SP Options:
  1449. Affected by the
  1450. .OP ignorecase
  1451. and
  1452. .OP magic
  1453. option.
  1454. .SE
  1455. .KY suspend
  1456. .IP "su[spend][!]"
  1457. .KY stop
  1458. .Ip "st[op][!]"
  1459. .KY <control-Z>
  1460. .Ip <control-Z>
  1461. Suspend the edit session.
  1462. Appending a
  1463. .QT !
  1464. character to these commands turns off the
  1465. .OP autowrite
  1466. option for the command.
  1467. .SS
  1468. .SP Line:
  1469. Unchanged.
  1470. .SP Options:
  1471. Affected by the
  1472. .OP autowrite
  1473. and
  1474. .OP writeany
  1475. options.
  1476. .SE
  1477. .KY tag
  1478. .IP "ta[g][!] tagstring"
  1479. Edit the file containing the specified tag.
  1480. If the tag is in a different file, then the new file is edited.
  1481. If the current file has been modified since the last complete write,
  1482. the
  1483. .CO tag
  1484. command will fail.
  1485. This check can be overridden by appending the
  1486. .QT !
  1487. character to the command name.
  1488. .sp
  1489. The
  1490. .CO tag
  1491. command searches for
  1492. .LI tagstring
  1493. in the tags file(s) specified by the
  1494. .Op tags
  1495. option.
  1496. (See
  1497. .XR ctags 1
  1498. for more information on tags files.)
  1499. .sp
  1500. Capitalizing the first letter of the command, i.e.
  1501. .CO Tag ,
  1502. while in
  1503. .CO vi
  1504. mode, will edit the file in a new screen.
  1505. In this case, any modifications to the current file are ignored.
  1506. .SS
  1507. .SP Line:
  1508. Set to the line indicated by the tag.
  1509. .SP Options:
  1510. Affected by the
  1511. .OP autowrite ,
  1512. .OP taglength ,
  1513. .OP tags
  1514. and
  1515. .OP writeany
  1516. options.
  1517. .SE
  1518. .KY tagnext
  1519. .IP "tagn[ext][!]"
  1520. Edit the file containing the next context for the current tag.
  1521. If the context is in a different file, then the new file is edited.
  1522. If the current file has been modified since the last complete write,
  1523. the
  1524. .CO tagnext
  1525. command will fail.
  1526. This check can be overridden by appending the
  1527. .QT !
  1528. character to the command name.
  1529. .sp
  1530. Capitalizing the first letter of the command, i.e.
  1531. .CO Tagnext ,
  1532. while in 
  1533. .CO vi 
  1534. mode, will edit the file in a new screen.
  1535. In this case, any modifications to the current file are ignored.
  1536. .SS 
  1537. .SP Line:
  1538. Set to the line indicated by the tag.
  1539. .SP Options:
  1540. Affected by the 
  1541. .OP autowrite
  1542. and
  1543. .OP writeany
  1544. options.
  1545. .SE
  1546. .KY tagpop
  1547. .IP "tagp[op][!] [file | number]"
  1548. Pop to the specified tag in the tags stack.
  1549. If neither
  1550. .LI file
  1551. or
  1552. .LI number
  1553. is specified, the
  1554. .CO tagpop
  1555. command pops to the most recent entry on the tags stack.
  1556. If
  1557. .LI file
  1558. or
  1559. .LI number
  1560. is specified, the
  1561. .CO tagpop
  1562. command pops to the most recent entry in the tags stack for that file,
  1563. or numbered entry in the tags stack, respectively.
  1564. (See the
  1565. .CO display
  1566. command for information on displaying the tags stack.)
  1567. .sp
  1568. If the file has been modified since the last complete write, the
  1569. .CO tagpop
  1570. command will fail.
  1571. This check may be overridden by appending a
  1572. .QT !
  1573. character to the command name.
  1574. .SS
  1575. .SP Line:
  1576. Set to the line indicated by the tag.
  1577. .SP Options:
  1578. Affected by the
  1579. .OP autowrite
  1580. and
  1581. .OP writeany
  1582. options.
  1583. .SE
  1584. .KY tagprev
  1585. .IP "tagp[rev][!]"
  1586. Edit the file containing the previous context for the current tag.
  1587. If the context is in a different file, then the new file is edited.
  1588. If the current file has been modified since the last complete write,
  1589. the
  1590. .CO tagprev
  1591. command will fail.
  1592. This check can be overridden by appending the
  1593. .QT !
  1594. character to the command name.
  1595. .sp
  1596. Capitalizing the first letter of the command, i.e.
  1597. .CO Tagprev ,
  1598. while in 
  1599. .CO vi 
  1600. mode, will edit the file in a new screen.
  1601. In this case, any modifications to the current file are ignored.
  1602. .SS 
  1603. .SP Line:
  1604. Set to the line indicated by the tag.
  1605. .SP Options:
  1606. Affected by the 
  1607. .OP autowrite
  1608. and
  1609. .OP writeany
  1610. options.
  1611. .SE
  1612. .KY tagtop
  1613. .IP "tagt[op][!]"
  1614. Pop to the least recent tag on the tags stack, clearing the tags stack.
  1615. .sp
  1616. If the file has been modified since the last complete write, the
  1617. .CO tagtop
  1618. command will fail.
  1619. This check may be overridden by appending a
  1620. .QT !
  1621. character to the command name.
  1622. .SS
  1623. .SP Line:
  1624. Set to the line indicated by the tag.
  1625. .SP Options:
  1626. Affected by the
  1627. .OP autowrite
  1628. and
  1629. .OP writeany
  1630. options.
  1631. .SE
  1632. .KY unabbrev
  1633. .IP "una[bbrev] lhs"
  1634. Delete an abbreviation.
  1635. Delete
  1636. .LI lhs
  1637. from the current list of abbreviations.
  1638. .SS
  1639. .SP Line:
  1640. Unchanged.
  1641. .SP Options:
  1642. None.
  1643. .SE
  1644. .KY undo
  1645. .IP "u[ndo]"
  1646. Undo the last change made to the file.
  1647. Changes made by
  1648. .CO global ,
  1649. .CO v ,
  1650. .CO visual
  1651. and map sequences are considered a single command.
  1652. If repeated, the
  1653. .CO u
  1654. command alternates between these two states, and is its own inverse.
  1655. .SS
  1656. .SP Line:
  1657. Set to the last line modified by the command.
  1658. .SP Options:
  1659. None.
  1660. .SE
  1661. .KY unmap
  1662. .IP "unm[ap][!] lhs"
  1663. Unmap a mapped string.
  1664. Delete the command mode map definition for
  1665. .LI lhs .
  1666. If a
  1667. .QT !
  1668. character is appended to the command name, delete the text input mode
  1669. map definition instead.
  1670. .SS
  1671. .SP Line:
  1672. Unchanged.
  1673. .SP Options:
  1674. None.
  1675. .SE
  1676. .KY version
  1677. .IP "ve[rsion]"
  1678. Display the version of the
  1679. .CO ex/vi
  1680. editor.
  1681. .KY visual
  1682. .IP "[line] vi[sual] [type] [count] [flags]"
  1683. .CO Ex
  1684. mode only.
  1685. Enter
  1686. .CO vi .
  1687. The
  1688. .LI type
  1689. is optional, and can be
  1690. .QT \- ,
  1691. .QT +
  1692. or
  1693. .QT ^ ,
  1694. as in the
  1695. .CO ex
  1696. .CO z
  1697. command, to specify the position of the specified line in the screen
  1698. window.
  1699. (The default is to place the line at the top of the screen window.)
  1700. A
  1701. .LI count
  1702. specifies the number of lines that will initially be displayed.
  1703. (The default is the value of the
  1704. .OP window
  1705. editor option.)
  1706. .SS
  1707. .SP Line:
  1708. Unchanged unless
  1709. .LI line
  1710. is specified, in which case it is set to that line.
  1711. .SP Options:
  1712. None.
  1713. .SE
  1714. .KY visual
  1715. .IP "vi[sual][!] [+cmd] [file]"
  1716. .CO Vi
  1717. mode only.
  1718. Edit a new file.
  1719. Identical to the
  1720. .QT "edit[!] [+cmd] [file]"
  1721. command.
  1722. .sp
  1723. Capitalizing the first letter of the command, i.e.
  1724. .CO Visual ,
  1725. will edit the file in a new screen.
  1726. In this case, any modifications to the current file are ignored.
  1727. .KY viusage
  1728. .IP "viu[sage] [command]"
  1729. Display usage for a
  1730. .CO vi
  1731. command.
  1732. If
  1733. .LI command
  1734. is specified, a usage statement for that command is displayed.
  1735. Otherwise, usage statements for all
  1736. .CO vi
  1737. commands are displayed.
  1738. .SS
  1739. .SP Line:
  1740. Unchanged.
  1741. .SP Options:
  1742. None.
  1743. .SE
  1744. .KY write
  1745. .IP "[range] w[rite][!] [>>] [file]"
  1746. .Ip "[range] w[rite] [!] [file]"
  1747. .KY wn
  1748. .Ip "[range] wn[!] [>>] [file]"
  1749. .KY wq
  1750. .Ip "[range] wq[!] [>>] [file]"
  1751. Write the file.
  1752. The specified lines (the entire file, if no range is given) is written
  1753. to
  1754. .LI file .
  1755. If
  1756. .LI file
  1757. is not specified, the current pathname is used.
  1758. If
  1759. .LI file
  1760. is specified, and it exists, or if the current pathname was set using the
  1761. .CO file
  1762. command, and the file already exists, these commands will fail.
  1763. Appending a
  1764. .QT !
  1765. character to the command name will override this check and the write
  1766. will be attempted, regardless.
  1767. .sp
  1768. Specifying the optional
  1769. .QT >>
  1770. string will cause the write to be appended to the file, in which case
  1771. no tests are made for the file already existing.
  1772. .sp
  1773. If the file is preceded by a
  1774. .QT !
  1775. character, the program named by the shell edit option is
  1776. invoked with file as its second argument, and the specified
  1777. lines are passed as standard input to that command.
  1778. The
  1779. .QT !
  1780. in this usage must be separated from command name by at least one
  1781. whitespace character.
  1782. The special meaning of the
  1783. .QT !
  1784. may be overridden by escaping it with a backslash
  1785. .PQ \e
  1786. character.
  1787. .sp
  1788. The
  1789. .CO wq
  1790. version of the write command will exit the editor after writing the file,
  1791. if there are no further files to edit.
  1792. Appending a
  1793. .QT !
  1794. character to the command name or entering two
  1795. .QQ quit
  1796. commands (i.e.
  1797. .CO wq ,
  1798. .CO quit ,
  1799. .CO xit
  1800. or
  1801. .CO ZZ )
  1802. in a row) will override this check and the editor will exit,
  1803. ignoring any files that have not yet been edited.
  1804. .sp
  1805. The
  1806. .CO wn
  1807. version of the write command will move to the next file after writing
  1808. the file, unless the write fails.
  1809. .SS
  1810. .SP Line:
  1811. Unchanged.
  1812. .SP Options:
  1813. Affected by the
  1814. .OP readonly
  1815. and
  1816. .OP writeany
  1817. options.
  1818. .SE
  1819. .KY xit
  1820. .IP "[range] x[it][!] [file]"
  1821. Write the file if it has been modified.
  1822. The specified lines are written to
  1823. .LI file ,
  1824. if the file has been modified since the last complete write to any
  1825. file.
  1826. If no
  1827. .LI range
  1828. is specified, the entire file is written.
  1829. .sp
  1830. The
  1831. .CO xit
  1832. command will exit the editor after writing the file,
  1833. if there are no further files to edit.
  1834. Appending a
  1835. .QT !
  1836. character to the command name or entering two
  1837. .QQ quit
  1838. commands (i.e.
  1839. .CO wq ,
  1840. .CO quit ,
  1841. .CO xit
  1842. or
  1843. .CO ZZ )
  1844. in a row) will override this check and the editor will exit,
  1845. ignoring any files that have not yet been edited.
  1846. .SS
  1847. .SP Line:
  1848. Unchanged.
  1849. .SP Options:
  1850. Affected by the
  1851. .OP readonly
  1852. and
  1853. .OP writeany
  1854. options.
  1855. .SE
  1856. .KY yank
  1857. .IP "[range] ya[nk] [buffer] [count]"
  1858. Copy the specified lines to a buffer.
  1859. If no buffer is specified, the unnamed buffer is used.
  1860. .SS
  1861. .SP Line:
  1862. Unchanged.
  1863. .SP Options:
  1864. None.
  1865. .SE
  1866. .KY z
  1867. .IP "[line] z [type] [count] [flags]"
  1868. Adjust the window.
  1869. If no
  1870. .LI type
  1871. is specified, then
  1872. .LI count
  1873. lines following the specified line are displayed.
  1874. The default
  1875. .LI count
  1876. is the value of the
  1877. .OP window
  1878. option.
  1879. The
  1880. .LI type
  1881. argument changes the position at which
  1882. .LI line
  1883. is displayed on the screen by changing the number of lines
  1884. displayed before and after
  1885. .LI line .
  1886. The following
  1887. .LI type
  1888. characters may be used:
  1889. .SS
  1890. .SP \-
  1891. Place the line at the bottom of the screen.
  1892. .SP +
  1893. Place the line at the top of the screen.
  1894. .SP \&.
  1895. Place the line in the middle of the screen.
  1896. .SP ^
  1897. Write out count lines starting
  1898. .LI "count * 2"
  1899. lines before
  1900. .LI line ;
  1901. the net effect of this is that a
  1902. .QT z^
  1903. command following a
  1904. .CO z
  1905. command writes the previous page.
  1906. .SP =
  1907. Center
  1908. .LI line
  1909. on the screen with a line of hyphens displayed immediately before and
  1910. after it.
  1911. The number of preceding and following lines of text displayed are
  1912. reduced to account for those lines.
  1913. .SE
  1914. .SS
  1915. .SP Line:
  1916. Set to the last line displayed, with the exception of the
  1917. .Dq Li \&=
  1918. .LI type ,
  1919. where the current line is set to the line specified by the command.
  1920. .SP Options:
  1921. Affected by the
  1922. .OP scroll
  1923. option.
  1924. .SE
  1925.