logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

vi.1p (155097B)


  1. '\" et
  2. .TH VI "1P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. vi
  12. \(em screen-oriented (visual) display editor
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. vi \fB[\fR-rR\fB] [\fR-c \fIcommand\fB] [\fR-t \fItagstring\fB] [\fR-w \fIsize\fB] [\fIfile\fR...\fB]\fR
  17. .fi
  18. .SH DESCRIPTION
  19. This utility shall be provided on systems that both support the User
  20. Portability Utilities option and define the POSIX2_CHAR_TERM symbol.
  21. On other systems it is optional.
  22. .P
  23. The
  24. .IR vi
  25. (visual) utility is a screen-oriented text editor. Only the open and
  26. visual modes of the editor are described in POSIX.1\(hy2008; see the line editor
  27. .IR ex
  28. for additional editing capabilities used in
  29. .IR vi .
  30. The user can switch back and forth between
  31. .IR vi
  32. and
  33. .IR ex
  34. and execute
  35. .IR ex
  36. commands from within
  37. .IR vi .
  38. .P
  39. This reference page uses the term
  40. .IR "edit buffer"
  41. to describe the current working text. No specific implementation is
  42. implied by this term. All editing changes are performed on the edit
  43. buffer, and no changes to it shall affect any file until an editor
  44. command writes the file.
  45. .P
  46. When using
  47. .IR vi ,
  48. the terminal screen acts as a window into the editing buffer. Changes
  49. made to the editing buffer shall be reflected in the screen display;
  50. the position of the cursor on the screen shall indicate the position
  51. within the editing buffer.
  52. .P
  53. Certain terminals do not have all the capabilities necessary to support
  54. the complete
  55. .IR vi
  56. definition. When these commands cannot be supported on such terminals,
  57. this condition shall not produce an error message such as ``not an
  58. editor command'' or report a syntax error. The implementation may
  59. either accept the commands and produce results on the screen that are
  60. the result of an unsuccessful attempt to meet the requirements of this volume of POSIX.1\(hy2017
  61. or report an error describing the terminal-related deficiency.
  62. .SH OPTIONS
  63. The
  64. .IR vi
  65. utility shall conform to the Base Definitions volume of POSIX.1\(hy2017,
  66. .IR "Section 12.2" ", " "Utility Syntax Guidelines",
  67. except that
  68. .BR '\(pl'
  69. may be recognized as an option delimiter as well as
  70. .BR '\-' .
  71. .P
  72. The following options shall be supported:
  73. .IP "\fB\-c\ \fIcommand\fR" 10
  74. See the
  75. .IR ex
  76. command description of the
  77. .BR \-c
  78. option.
  79. .IP "\fB\-r\fP" 10
  80. See the
  81. .IR ex
  82. command description of the
  83. .BR \-r
  84. option.
  85. .IP "\fB\-R\fP" 10
  86. See the
  87. .IR ex
  88. command description of the
  89. .BR \-R
  90. option.
  91. .IP "\fB\-t\ \fItagstring\fR" 10
  92. See the
  93. .IR ex
  94. command description of the
  95. .BR \-t
  96. option.
  97. .IP "\fB\-w\ \fIsize\fR" 10
  98. See the
  99. .IR ex
  100. command description of the
  101. .BR \-w
  102. option.
  103. .SH OPERANDS
  104. See the OPERANDS section of the
  105. .IR ex
  106. command for a description of the operands supported by the
  107. .IR vi
  108. command.
  109. .SH STDIN
  110. If standard input is not a terminal device, the results are undefined.
  111. The standard input consists of a series of commands and input text, as
  112. described in the EXTENDED DESCRIPTION section.
  113. .P
  114. If a read from the standard input returns an error, or if the editor
  115. detects an end-of-file condition from the standard input, it shall be
  116. equivalent to a SIGHUP asynchronous event.
  117. .SH "INPUT FILES"
  118. See the INPUT FILES section of the
  119. .IR ex
  120. command for a description of the input files supported by the
  121. .IR vi
  122. command.
  123. .SH "ENVIRONMENT VARIABLES"
  124. See the ENVIRONMENT VARIABLES section of the
  125. .IR ex
  126. command for the environment variables that affect the execution of the
  127. .IR vi
  128. command.
  129. .SH "ASYNCHRONOUS EVENTS"
  130. See the ASYNCHRONOUS EVENTS section of the
  131. .IR ex
  132. for the asynchronous events that affect the execution of the
  133. .IR vi
  134. command.
  135. .SH STDOUT
  136. If standard output is not a terminal device, undefined results occur.
  137. .P
  138. Standard output may be used for writing prompts to the user, for
  139. informational messages, and for writing lines from the file.
  140. .SH STDERR
  141. If standard output is not a terminal device, undefined results occur.
  142. .P
  143. The standard error shall be used only for diagnostic messages.
  144. .SH "OUTPUT FILES"
  145. See the OUTPUT FILES section of the
  146. .IR ex
  147. command for a description of the output files supported by the
  148. .IR vi
  149. command.
  150. .SH "EXTENDED DESCRIPTION"
  151. If the terminal does not have the capabilities necessary to support an
  152. unspecified portion of the
  153. .IR vi
  154. definition, implementations shall start initially in
  155. .IR ex
  156. mode or open mode. Otherwise, after initialization,
  157. .IR vi
  158. shall be in command mode; text input mode can be entered by one of
  159. several commands used to insert or change text. In text input mode,
  160. <ESC>
  161. can be used to return to command mode; other uses of
  162. <ESC>
  163. are described later in this section; see
  164. .IR "Terminate Command or Input Mode".
  165. .SS "Initialization in ex and vi"
  166. .P
  167. See
  168. .IR "Initialization in ex and vi"
  169. for a description of
  170. .IR ex
  171. and
  172. .IR vi
  173. initialization for the
  174. .IR vi
  175. utility.
  176. .SS "Command Descriptions in vi"
  177. .P
  178. The following symbols are used in this reference page to represent
  179. arguments to commands.
  180. .IP "\fIbuffer\fR" 8
  181. See the description of
  182. .IR buffer
  183. in the EXTENDED DESCRIPTION section of the
  184. .IR ex
  185. utility; see
  186. .IR "Command Descriptions in ex".
  187. .RS 8
  188. .P
  189. In open and visual mode, when a command synopsis shows both [\c
  190. .IR buffer ]
  191. and [\c
  192. .IR count ]
  193. preceding the command name, they can be specified in either order.
  194. .RE
  195. .IP "\fIcount\fR" 8
  196. A positive integer used as an optional argument to most commands,
  197. either to give a repeat count or as a size. This argument is optional
  198. and shall default to 1 unless otherwise specified.
  199. .RS 8
  200. .P
  201. The Synopsis lines for the
  202. .IR vi
  203. commands
  204. <control>\(hyG,
  205. <control>\(hyL,
  206. <control>\(hyR,
  207. <control>\(hy],
  208. .BR % ,
  209. .BR & ,
  210. .BR ^ ,
  211. .BR D ,
  212. .BR m ,
  213. .BR M ,
  214. .BR Q ,
  215. .BR u ,
  216. .BR U ,
  217. and
  218. .BR ZZ
  219. do not have
  220. .IR count
  221. as an optional argument. Regardless, it shall not be an error to
  222. specify a
  223. .IR count
  224. to these commands, and any specified
  225. .IR count
  226. shall be ignored.
  227. .RE
  228. .IP "\fImotion\fR" 8
  229. An optional trailing argument used by the
  230. .BR ! ,
  231. .BR < ,
  232. .BR > ,
  233. .BR c ,
  234. .BR d ,
  235. and
  236. .BR y
  237. commands, which is used to indicate the region of text that shall be
  238. affected by the command. The motion can be either one of the command
  239. characters repeated or one of several other
  240. .IR vi
  241. commands (listed in the following table). Each of the applicable
  242. commands specifies the region of text matched by repeating the command;
  243. each command that can be used as a motion command specifies the region
  244. of text it affects.
  245. .RS 8
  246. .P
  247. Commands that take
  248. .IR motion
  249. arguments operate on either lines or characters, depending on the
  250. circumstances. When operating on lines, all lines that fall partially
  251. or wholly within the text region specified for the command shall be
  252. affected. When operating on characters, only the exact characters in
  253. the specified text region shall be affected. Each motion command
  254. specifies this individually.
  255. .P
  256. When commands that may be motion commands are not used as motion
  257. commands, they shall set the current position to the current line and
  258. column as specified.
  259. .P
  260. The following commands shall be valid cursor motion commands:
  261. .sp
  262. .RS 4
  263. .nf
  264. <apostrophe> ( - j H
  265. <carriage-return> ) $ k L
  266. <comma> [[ % l M
  267. <control>-H ]] _ n N
  268. <control>-N { ; t T
  269. <control>-P } ? w W
  270. <grave-accent> \(ha b B
  271. <newline> + e E
  272. <space> | f F
  273. <zero> / h G
  274. .fi
  275. .P
  276. .RE
  277. .P
  278. Any
  279. .IR count
  280. that is specified to a command that has an associated motion command
  281. shall be applied to the motion command. If a
  282. .IR count
  283. is applied to both the command and its associated motion command, the
  284. effect shall be multiplicative.
  285. .RE
  286. .P
  287. The following symbols are used in this section to specify locations
  288. in the edit buffer:
  289. .IP "\fIcurrent\ character\fP" 8
  290. .br
  291. The character that is currently indicated by the cursor.
  292. .IP "\fIend\ of\ a\ line\fP" 8
  293. .br
  294. The point located between the last non-\c
  295. <newline>
  296. (if any) and the terminating
  297. <newline>
  298. of a line. For an empty line, this location coincides with the
  299. beginning of the line.
  300. .IP "\fIend\ of\ the\ edit\ buffer\fP" 8
  301. .br
  302. The location corresponding to the end of the last line in the edit
  303. buffer.
  304. .P
  305. The following symbols are used in this section to specify command
  306. actions:
  307. .IP "\fIbigword\fP" 8
  308. In the POSIX locale,
  309. .IR vi
  310. shall recognize four kinds of
  311. .IR bigwords :
  312. .RS 8
  313. .IP " 1." 4
  314. A maximal sequence of non-\c
  315. <blank>
  316. characters preceded and followed by
  317. <blank>
  318. characters or the beginning or end of a line or the edit buffer
  319. .IP " 2." 4
  320. One or more sequential blank lines
  321. .IP " 3." 4
  322. The first character in the edit buffer
  323. .IP " 4." 4
  324. The last non-\c
  325. <newline>
  326. in the edit buffer
  327. .RE
  328. .IP "\fIword\fP" 8
  329. In the POSIX locale,
  330. .IR vi
  331. shall recognize five kinds of words:
  332. .RS 8
  333. .IP " 1." 4
  334. A maximal sequence of letters, digits, and underscores, delimited at
  335. both ends by:
  336. .RS 4
  337. .IP -- 4
  338. Characters other than letters, digits, or underscores
  339. .IP -- 4
  340. The beginning or end of a line
  341. .IP -- 4
  342. The beginning or end of the edit buffer
  343. .RE
  344. .IP " 2." 4
  345. A maximal sequence of characters other than letters, digits, underscores, or
  346. <blank>
  347. characters, delimited at both ends by:
  348. .RS 4
  349. .IP -- 4
  350. A letter, digit, underscore
  351. .IP -- 4
  352. <blank>
  353. characters
  354. .IP -- 4
  355. The beginning or end of a line
  356. .IP -- 4
  357. The beginning or end of the edit buffer
  358. .RE
  359. .IP " 3." 4
  360. One or more sequential blank lines
  361. .IP " 4." 4
  362. The first character in the edit buffer
  363. .IP " 5." 4
  364. The last non-\c
  365. <newline>
  366. in the edit buffer
  367. .RE
  368. .IP "\fIsection\ boundary\fR" 8
  369. .br
  370. A
  371. .IR "section boundary"
  372. is one of the following:
  373. .RS 8
  374. .IP " 1." 4
  375. A line whose first character is a
  376. <form-feed>
  377. .IP " 2." 4
  378. A line whose first character is an open curly brace (\c
  379. .BR '{' )
  380. .IP " 3." 4
  381. A line whose first character is a
  382. <period>
  383. and whose second and third characters match a two-character pair in the
  384. .BR sections
  385. edit option (see
  386. .IR ex )
  387. .IP " 4." 4
  388. A line whose first character is a
  389. <period>
  390. and whose only other character matches the first character of a
  391. two-character pair in the
  392. .BR sections
  393. edit option, where the second character of the two-character pair is a
  394. <space>
  395. .IP " 5." 4
  396. The first line of the edit buffer
  397. .IP " 6." 4
  398. The last line of the edit buffer if the last line of the edit buffer is
  399. empty or if it is a
  400. .BR ]]
  401. or
  402. .BR }
  403. command; otherwise, the last non-\c
  404. <newline>
  405. of the last line of the edit buffer
  406. .RE
  407. .IP "\fIparagraph\ boundary\fR" 8
  408. .br
  409. A
  410. .IR "paragraph boundary"
  411. is one of the following:
  412. .RS 8
  413. .IP " 1." 4
  414. A section boundary
  415. .IP " 2." 4
  416. A line whose first character is a
  417. <period>
  418. and whose second and third characters match a two-character pair in the
  419. .BR paragraphs
  420. edit option (see
  421. .IR ex )
  422. .IP " 3." 4
  423. A line whose first character is a
  424. <period>
  425. and whose only other character matches the first character of a
  426. two-character pair in the
  427. .IR paragraphs
  428. edit option, where the second character of the two-character pair is a
  429. <space>
  430. .IP " 4." 4
  431. One or more sequential blank lines
  432. .RE
  433. .IP "\fIremembered\ search\ direction\fR" 8
  434. .br
  435. See the description of \fIremembered search direction\fP in
  436. .IR ex .
  437. .IP "\fIsentence\ boundary\fR" 8
  438. .br
  439. A
  440. .IR "sentence boundary"
  441. is one of the following:
  442. .RS 8
  443. .IP " 1." 4
  444. A paragraph boundary
  445. .IP " 2." 4
  446. The first non-\c
  447. <blank>
  448. that occurs after a paragraph boundary
  449. .IP " 3." 4
  450. The first non-\c
  451. <blank>
  452. that occurs after a
  453. <period>
  454. (\c
  455. .BR '.' ),
  456. <exclamation-mark>
  457. (\c
  458. .BR '!' ),
  459. or
  460. <question-mark>
  461. (\c
  462. .BR '?' ),
  463. followed by two
  464. <space>
  465. characters or the end of a line; any number of closing parenthesis (\c
  466. .BR ')' ),
  467. closing brackets (\c
  468. .BR ']' ),
  469. double-quote (\c
  470. .BR '\&"' ),
  471. or single-quote (\c
  472. <apostrophe>)
  473. characters can appear between the punctuation mark and the two
  474. <space>
  475. characters or end-of-line
  476. .RE
  477. .P
  478. In the remainder of the description of the
  479. .IR vi
  480. utility, the term ``buffer line'' refers to a line in the edit buffer
  481. and the term ``display line'' refers to the line or lines on the
  482. display screen used to display one buffer line. The term ``current
  483. line'' refers to a specific ``buffer line''.
  484. .P
  485. If there are display lines on the screen for which there are no
  486. corresponding buffer lines because they correspond to lines that would
  487. be after the end of the file, they shall be displayed as a single
  488. <tilde>
  489. (\c
  490. .BR '\(ti' )
  491. character, plus the terminating
  492. <newline>.
  493. .P
  494. The last line of the screen shall be used to report errors or display
  495. informational messages. It shall also be used to display the input for
  496. ``line-oriented commands'' (\c
  497. .BR / ,
  498. .BR ? ,
  499. .BR : ,
  500. and
  501. .BR ! ).
  502. When a line-oriented command is executed, the editor shall enter text
  503. input mode on the last line on the screen, using the respective command
  504. characters as prompt characters. (In the case of the
  505. .BR !
  506. command, the associated motion shall be entered by the user before the
  507. editor enters text input mode.) The line entered by the user shall be
  508. terminated by a
  509. <newline>,
  510. a non-\c
  511. <control>\(hyV-escaped
  512. <carriage-return>,
  513. or unescaped
  514. <ESC>.
  515. It is unspecified if more characters than require a display width minus
  516. one column number of screen columns can be entered.
  517. .P
  518. If any command is executed that overwrites a portion of the screen
  519. other than the last line of the screen (for example, the
  520. .IR ex
  521. .BR suspend
  522. or
  523. .BR !
  524. commands), other than the
  525. .IR ex
  526. .BR shell
  527. command, the user shall be prompted for a character before the screen
  528. is refreshed and the edit session continued.
  529. .P
  530. <tab>
  531. characters shall take up the number of columns on the screen set by the
  532. .BR tabstop
  533. edit option (see
  534. .IR ex ),
  535. unless there are less than that number of columns before the display
  536. margin that will cause the displayed line to be folded; in this case,
  537. they shall only take up the number of columns up to that boundary.
  538. .P
  539. The cursor shall be placed on the current line and relative to the
  540. current column as specified by each command described in the following
  541. sections.
  542. .P
  543. In open mode, if the current line is not already displayed, then it
  544. shall be displayed.
  545. .P
  546. In visual mode, if the current line is not displayed, then the lines
  547. that are displayed shall be expanded, scrolled, or redrawn to cause an
  548. unspecified portion of the current line to be displayed. If the screen
  549. is redrawn, no more than the number of display lines specified by the
  550. value of the
  551. .BR window
  552. edit option shall be displayed (unless the current line cannot be
  553. completely displayed in the number of display lines specified by the
  554. .BR window
  555. edit option) and the current line shall be positioned as close to the
  556. center of the displayed lines as possible (within the constraints
  557. imposed by the distance of the line from the beginning or end of the
  558. edit buffer). If the current line is before the first line in the
  559. display and the screen is scrolled, an unspecified portion of the
  560. current line shall be placed on the first line of the display. If the
  561. current line is after the last line in the display and the screen is
  562. scrolled, an unspecified portion of the current line shall be placed on
  563. the last line of the display.
  564. .P
  565. In visual mode, if a line from the edit buffer (other than the current
  566. line) does not entirely fit into the lines at the bottom of the display
  567. that are available for its presentation, the editor may choose not to
  568. display any portion of the line. The lines of the display that do not
  569. contain text from the edit buffer for this reason shall each consist of
  570. a single
  571. .BR '@'
  572. character.
  573. .P
  574. In visual mode, the editor may choose for unspecified reasons to not
  575. update lines in the display to correspond to the underlying edit buffer
  576. text. The lines of the display that do not correctly correspond to text
  577. from the edit buffer for this reason shall consist of a single
  578. .BR '@'
  579. character (plus the terminating
  580. <newline>),
  581. and the
  582. <control>\(hyR
  583. command shall cause the editor to update the screen to correctly
  584. represent the edit buffer.
  585. .P
  586. Open and visual mode commands that set the current column set it to a
  587. column position in the display, and not a character position in the
  588. line. In this case, however, the column position in the display shall
  589. be calculated for an infinite width display; for example, the column
  590. related to a character that is part of a line that has been folded onto
  591. additional screen lines will be offset from the display line column
  592. where the buffer line begins, not from the beginning of a particular
  593. display line.
  594. .P
  595. The display cursor column in the display is based on the value of the
  596. current column, as follows, with each rule applied in turn:
  597. .IP " 1." 4
  598. If the current column is after the last display line column used by the
  599. displayed line, the display cursor column shall be set to the last
  600. display line column occupied by the last non-\c
  601. <newline>
  602. in the current line; otherwise, the display cursor column shall be set
  603. to the current column.
  604. .IP " 2." 4
  605. If the character of which some portion is displayed in the display line
  606. column specified by the display cursor column requires more than a
  607. single display line column:
  608. .RS 4
  609. .IP " a." 4
  610. If in text input mode, the display cursor column shall be adjusted to
  611. the first display line column in which any portion of that character is
  612. displayed.
  613. .IP " b." 4
  614. Otherwise, the display cursor column shall be adjusted to the last
  615. display line column in which any portion of that character is
  616. displayed.
  617. .RE
  618. .P
  619. The current column shall not be changed by these adjustments to the
  620. display cursor column.
  621. .P
  622. If an error occurs during the parsing or execution of a
  623. .IR vi
  624. command:
  625. .IP " *" 4
  626. The terminal shall be alerted. Execution of the
  627. .IR vi
  628. command shall stop, and the cursor (for example, the current line and
  629. column) shall not be further modified.
  630. .IP " *" 4
  631. Unless otherwise specified by the following command sections, it is
  632. unspecified whether an informational message shall be displayed.
  633. .IP " *" 4
  634. Any partially entered
  635. .IR vi
  636. command shall be discarded.
  637. .IP " *" 4
  638. If the
  639. .IR vi
  640. command resulted from a
  641. .BR map
  642. expansion, all characters from that
  643. .BR map
  644. expansion shall be discarded, except as otherwise specified by the
  645. .BR map
  646. command (see
  647. .IR ex ).
  648. .IP " *" 4
  649. If the
  650. .IR vi
  651. command resulted from the execution of a buffer, no further commands
  652. caused by the execution of the buffer shall be executed.
  653. .SS "Page Backwards"
  654. .IP "\fISynopsis\fR:" 10
  655. .sp -1v
  656. .RS 10
  657. .sp
  658. .RS 4
  659. .nf
  660. \fB[\fIcount\fB]\fR <control>-B
  661. .fi
  662. .P
  663. .RE
  664. .RE
  665. .P
  666. If in open mode, the
  667. <control>\(hyB
  668. command shall behave identically to the
  669. .BR z
  670. command. Otherwise, if the current line is the first line of the edit
  671. buffer, it shall be an error.
  672. .P
  673. If the
  674. .BR window
  675. edit option is less than 3, display a screen where the last line of the
  676. display shall be some portion of:
  677. .sp
  678. .RS 4
  679. .nf
  680. (\fIcurrent first line\fR) -1
  681. .fi
  682. .P
  683. .RE
  684. .P
  685. otherwise, display a screen where the first line of the display shall
  686. be some portion of:
  687. .sp
  688. .RS 4
  689. .nf
  690. (\fIcurrent first line\fR) - \fIcount\fR x ((window edit option) -2)
  691. .fi
  692. .P
  693. .RE
  694. .P
  695. If this calculation would result in a line that is before the first
  696. line of the edit buffer, the first line of the display shall display
  697. some portion of the first line of the edit buffer.
  698. .P
  699. .IR "Current line" :
  700. If no lines from the previous display remain on the screen, set to the
  701. last line of the display; otherwise, set to (\c
  702. .IR line
  703. \- the number of new lines displayed on this screen).
  704. .P
  705. .IR "Current column" :
  706. Set to non-\c
  707. <blank>.
  708. .SS "Scroll Forward"
  709. .IP "\fISynopsis\fR:" 10
  710. .sp -1v
  711. .RS 10
  712. .sp
  713. .RS 4
  714. .nf
  715. \fB[\fIcount\fB]\fR <control>-D
  716. .fi
  717. .P
  718. .RE
  719. .RE
  720. .P
  721. If the current line is the last line of the edit buffer, it shall be an
  722. error.
  723. .P
  724. If no
  725. .IR count
  726. is specified,
  727. .IR count
  728. shall default to the
  729. .IR count
  730. associated with the previous
  731. <control>\(hyD
  732. or
  733. <control>\(hyU
  734. command. If there was no previous
  735. <control>\(hyD
  736. or
  737. <control>\(hyU
  738. command,
  739. .IR count
  740. shall default to the value of the
  741. .BR scroll
  742. edit option.
  743. .P
  744. If in open mode, write lines starting with the line after the current
  745. line, until
  746. .IR count
  747. lines or the last line of the file have been written.
  748. .P
  749. .IR "Current line" :
  750. If the current line +
  751. .IR count
  752. is past the last line of the edit buffer, set to the last line of the
  753. edit buffer; otherwise, set to the current line +
  754. .IR count .
  755. .P
  756. .IR "Current column" :
  757. Set to non-\c
  758. <blank>.
  759. .SS "Scroll Forward by Line"
  760. .IP "\fISynopsis\fR:" 10
  761. .sp -1v
  762. .RS 10
  763. .sp
  764. .RS 4
  765. .nf
  766. \fB[\fIcount\fB]\fR <control>-E
  767. .fi
  768. .P
  769. .RE
  770. .RE
  771. .P
  772. Display the line count lines after the last line currently displayed.
  773. .P
  774. If the last line of the edit buffer is displayed, it shall be an error.
  775. If there is no line
  776. .IR count
  777. lines after the last line currently displayed, the last line of the
  778. display shall display some portion of the last line of the edit
  779. buffer.
  780. .P
  781. .IR "Current line" :
  782. Unchanged if the previous current character is displayed; otherwise,
  783. set to the first line displayed.
  784. .P
  785. .IR "Current column" :
  786. Unchanged.
  787. .SS "Page Forward"
  788. .IP "\fISynopsis\fR:" 10
  789. .sp -1v
  790. .RS 10
  791. .sp
  792. .RS 4
  793. .nf
  794. \fB[\fIcount\fB]\fR <control>-F
  795. .fi
  796. .P
  797. .RE
  798. .RE
  799. .P
  800. If in open mode, the
  801. <control>\(hyF
  802. command shall behave identically to the
  803. .BR z
  804. command. Otherwise, if the current line is the last line of the edit
  805. buffer, it shall be an error.
  806. .P
  807. If the
  808. .BR window
  809. edit option is less than 3, display a screen where the first line of
  810. the display shall be some portion of:
  811. .sp
  812. .RS 4
  813. .nf
  814. (\fIcurrent last line\fR) +1
  815. .fi
  816. .P
  817. .RE
  818. .P
  819. otherwise, display a screen where the first line of the display shall
  820. be some portion of:
  821. .sp
  822. .RS 4
  823. .nf
  824. (\fIcurrent first line\fR) + \fIcount\fR x ((window edit option) -2)
  825. .fi
  826. .P
  827. .RE
  828. .P
  829. If this calculation would result in a line that is after the last line
  830. of the edit buffer, the last line of the display shall display some
  831. portion of the last line of the edit buffer.
  832. .P
  833. .IR "Current line" :
  834. If no lines from the previous display remain on the screen, set to the
  835. first line of the display; otherwise, set to (\c
  836. .IR line
  837. + the number of new lines displayed on this screen).
  838. .P
  839. .IR "Current column" :
  840. Set to non-\c
  841. <blank>.
  842. .SS "Display Information"
  843. .IP "\fISynopsis\fR:" 10
  844. .sp -1v
  845. .RS 10
  846. .sp
  847. .RS 4
  848. .nf
  849. <control>-G
  850. .fi
  851. .P
  852. .RE
  853. .RE
  854. .P
  855. This command shall be equivalent to the
  856. .IR ex
  857. .BR file
  858. command.
  859. .SS "Move Cursor Backwards"
  860. .IP "\fISynopsis\fR:" 10
  861. .sp -1v
  862. .RS 10
  863. .sp
  864. .RS 4
  865. .nf
  866. \fB[\fIcount\fB]\fR <control>-H
  867. .br
  868. \fB[\fIcount\fB]\fR h
  869. .br
  870. the current \fIerase\fP character (see stty)
  871. .fi
  872. .P
  873. .RE
  874. .RE
  875. .P
  876. If there are no characters before the current character on the current
  877. line, it shall be an error. If there are less than
  878. .IR count
  879. previous characters on the current line,
  880. .IR count
  881. shall be adjusted to the number of previous characters on the line.
  882. .P
  883. If used as a motion command:
  884. .IP " 1." 4
  885. The text region shall be from the character before the starting cursor
  886. up to and including the
  887. .IR count th
  888. character before the starting cursor.
  889. .IP " 2." 4
  890. Any text copied to a buffer shall be in character mode.
  891. .P
  892. If not used as a motion command:
  893. .P
  894. .IR "Current line" :
  895. Unchanged.
  896. .P
  897. .IR "Current column" :
  898. Set to (\c
  899. .IR column
  900. \- the number of columns occupied by
  901. .IR count
  902. characters ending with the previous current column).
  903. .SS "Move Down"
  904. .IP "\fISynopsis\fR:" 10
  905. .sp -1v
  906. .RS 10
  907. .sp
  908. .RS 4
  909. .nf
  910. \fB[\fIcount\fB]\fR <newline>
  911. .br
  912. \fB[\fIcount\fB]\fR <control>-J
  913. .br
  914. \fB[\fIcount\fB]\fR <control>-M
  915. .br
  916. \fB[\fIcount\fB]\fR <control>-N
  917. .br
  918. \fB[\fIcount\fB]\fR j
  919. .br
  920. \fB[\fIcount\fB]\fR <carriage-return>
  921. .br
  922. \fB[\fIcount\fB]\fR +
  923. .fi
  924. .P
  925. .RE
  926. .RE
  927. .P
  928. If there are less than
  929. .IR count
  930. lines after the current line in the edit buffer, it shall be an error.
  931. .P
  932. If used as a motion command:
  933. .IP " 1." 4
  934. The text region shall include the starting line and the next
  935. .IR count
  936. \- 1 lines.
  937. .IP " 2." 4
  938. Any text copied to a buffer shall be in line mode.
  939. .P
  940. If not used as a motion command:
  941. .P
  942. .IR "Current line" :
  943. Set to
  944. .IR "current line" +
  945. .IR count .
  946. .P
  947. .IR "Current column" :
  948. Set to non-\c
  949. <blank>
  950. for the
  951. <carriage-return>,
  952. <control>\(hyM,
  953. and
  954. .BR +
  955. commands; otherwise, unchanged.
  956. .SS "Clear and Redisplay"
  957. .IP "\fISynopsis\fR:" 10
  958. .sp -1v
  959. .RS 10
  960. .sp
  961. .RS 4
  962. .nf
  963. <control>-L
  964. .fi
  965. .P
  966. .RE
  967. .RE
  968. .P
  969. If in open mode, clear the screen and redisplay the current line.
  970. Otherwise, clear and redisplay the screen.
  971. .P
  972. .IR "Current line" :
  973. Unchanged.
  974. .P
  975. .IR "Current column" :
  976. Unchanged.
  977. .SS "Move Up"
  978. .IP "\fISynopsis\fR:" 10
  979. .sp -1v
  980. .RS 10
  981. .sp
  982. .RS 4
  983. .nf
  984. \fB[\fIcount\fB]\fR <control>-P
  985. .br
  986. \fB[\fIcount\fB]\fR k
  987. .br
  988. \fB[\fIcount\fB]\fR -
  989. .fi
  990. .P
  991. .RE
  992. .RE
  993. .P
  994. If there are less than
  995. .IR count
  996. lines before the current line in the edit buffer, it shall be an
  997. error.
  998. .P
  999. If used as a motion command:
  1000. .IP " 1." 4
  1001. The text region shall include the starting line and the previous
  1002. .IR count
  1003. lines.
  1004. .IP " 2." 4
  1005. Any text copied to a buffer shall be in line mode.
  1006. .P
  1007. If not used as a motion command:
  1008. .P
  1009. .IR "Current line" :
  1010. Set to
  1011. .IR "current line"
  1012. \-
  1013. .IR count .
  1014. .P
  1015. .IR "Current column" :
  1016. Set to non-\c
  1017. <blank>
  1018. for the
  1019. .BR \-
  1020. command; otherwise, unchanged.
  1021. .SS "Redraw Screen"
  1022. .IP "\fISynopsis\fR:" 10
  1023. .sp -1v
  1024. .RS 10
  1025. .sp
  1026. .RS 4
  1027. .nf
  1028. <control>-R
  1029. .fi
  1030. .P
  1031. .RE
  1032. .RE
  1033. .P
  1034. If any lines have been deleted from the display screen and flagged as
  1035. deleted on the terminal using the
  1036. .BR @
  1037. convention (see the beginning of the EXTENDED DESCRIPTION section),
  1038. they shall be redisplayed to match the contents of the edit buffer.
  1039. .P
  1040. It is unspecified whether lines flagged with
  1041. .BR @
  1042. because they do not fit on the terminal display shall be affected.
  1043. .P
  1044. .IR "Current line" :
  1045. Unchanged.
  1046. .P
  1047. .IR "Current column" :
  1048. Unchanged.
  1049. .SS "Scroll Backward"
  1050. .IP "\fISynopsis\fR:" 10
  1051. .sp -1v
  1052. .RS 10
  1053. .sp
  1054. .RS 4
  1055. .nf
  1056. \fB[\fIcount\fB]\fR <control>-U
  1057. .fi
  1058. .P
  1059. .RE
  1060. .RE
  1061. .P
  1062. If the current line is the first line of the edit buffer, it shall be
  1063. an error.
  1064. .P
  1065. If no
  1066. .IR count
  1067. is specified,
  1068. .IR count
  1069. shall default to the
  1070. .IR count
  1071. associated with the previous
  1072. <control>\(hyD
  1073. or
  1074. <control>\(hyU
  1075. command. If there was no previous
  1076. <control>\(hyD
  1077. or
  1078. <control>\(hyU
  1079. command,
  1080. .IR count
  1081. shall default to the value of the
  1082. .BR scroll
  1083. edit option.
  1084. .P
  1085. .IR "Current line" :
  1086. If
  1087. .IR count
  1088. is greater than the current line, set to 1; otherwise, set to the
  1089. current line \-
  1090. .IR count .
  1091. .P
  1092. .IR "Current column" :
  1093. Set to non-\c
  1094. <blank>.
  1095. .SS "Scroll Backward by Line"
  1096. .IP "\fISynopsis\fR:" 10
  1097. .sp -1v
  1098. .RS 10
  1099. .sp
  1100. .RS 4
  1101. .nf
  1102. \fB[\fIcount\fB]\fR <control>-Y
  1103. .fi
  1104. .P
  1105. .RE
  1106. .RE
  1107. .P
  1108. Display the line
  1109. .IR count
  1110. lines before the first line currently displayed.
  1111. .P
  1112. If the current line is the first line of the edit buffer, it shall be
  1113. an error. If this calculation would result in a line that is before the
  1114. first line of the edit buffer, the first line of the display shall
  1115. display some portion of the first line of the edit buffer.
  1116. .P
  1117. .IR "Current line" :
  1118. Unchanged if the previous current character is displayed; otherwise,
  1119. set to the first line displayed.
  1120. .P
  1121. .IR "Current column" :
  1122. Unchanged.
  1123. .SS "Edit the Alternate File"
  1124. .IP "\fISynopsis\fR:" 10
  1125. .sp -1v
  1126. .RS 10
  1127. .sp
  1128. .RS 4
  1129. .nf
  1130. <control>-\(ha
  1131. .fi
  1132. .P
  1133. .RE
  1134. .RE
  1135. This command shall be equivalent to the
  1136. .IR ex
  1137. .BR edit
  1138. command, with the alternate pathname as its argument.
  1139. .SS "Terminate Command or Input Mode"
  1140. .IP "\fISynopsis\fR:" 10
  1141. .sp -1v
  1142. .RS 10
  1143. .sp
  1144. .RS 4
  1145. .nf
  1146. <ESC>
  1147. .fi
  1148. .P
  1149. .RE
  1150. .RE
  1151. .P
  1152. If a partial
  1153. .IR vi
  1154. command (as defined by at least one, non-\c
  1155. .IR count
  1156. character) has been entered, discard the
  1157. .IR count
  1158. and the command character(s).
  1159. .P
  1160. Otherwise, if no command characters have been entered, and the
  1161. <ESC>
  1162. was the result of a map expansion, the terminal shall be alerted and
  1163. the
  1164. <ESC>
  1165. character shall be discarded, but it shall not be an error.
  1166. .P
  1167. Otherwise, it shall be an error.
  1168. .P
  1169. .IR "Current line" :
  1170. Unchanged.
  1171. .P
  1172. .IR "Current column" :
  1173. Unchanged.
  1174. .SS "Search for tagstring"
  1175. .IP "\fISynopsis\fR:" 10
  1176. .sp -1v
  1177. .RS 10
  1178. .sp
  1179. .RS 4
  1180. .nf
  1181. <control>-]
  1182. .fi
  1183. .P
  1184. .RE
  1185. .RE
  1186. .P
  1187. If the current character is not a word or
  1188. <blank>,
  1189. it shall be an error.
  1190. .P
  1191. This command shall be equivalent to the
  1192. .IR ex
  1193. .BR tag
  1194. command, with the argument to that command defined as follows.
  1195. .P
  1196. If the current character is a
  1197. <blank>:
  1198. .IP " 1." 4
  1199. Skip all
  1200. <blank>
  1201. characters after the cursor up to the end of the line.
  1202. .IP " 2." 4
  1203. If the end of the line is reached, it shall be an error.
  1204. .P
  1205. Then, the argument to the
  1206. .IR ex
  1207. .BR tag
  1208. command shall be the current character and all subsequent characters,
  1209. up to the first non-word character or the end of the line.
  1210. .SS "Move Cursor Forward"
  1211. .IP "\fISynopsis\fR:" 10
  1212. .sp -1v
  1213. .RS 10
  1214. .sp
  1215. .RS 4
  1216. .nf
  1217. \fB[\fIcount\fB]\fR <space>
  1218. .br
  1219. \fB[\fIcount\fB]\fR l\fR (ell)\fR
  1220. .fi
  1221. .P
  1222. .RE
  1223. .RE
  1224. .P
  1225. If there are less than
  1226. .IR count
  1227. non-\c
  1228. <newline>
  1229. characters after the cursor on the current line,
  1230. .IR count
  1231. shall be adjusted to the number of non-\c
  1232. <newline>
  1233. characters after the cursor on the line.
  1234. .P
  1235. If used as a motion command:
  1236. .IP " 1." 4
  1237. If the current or
  1238. .IR count th
  1239. character after the cursor is the last non-\c
  1240. <newline>
  1241. in the line, the text region shall be comprised of the current
  1242. character up to and including the last non-\c
  1243. <newline>
  1244. in the line. Otherwise, the text region shall be from the current
  1245. character up to, but not including, the
  1246. .IR count th
  1247. character after the cursor.
  1248. .IP " 2." 4
  1249. Any text copied to a buffer shall be in character mode.
  1250. .P
  1251. If not used as a motion command:
  1252. .P
  1253. If there are no non-\c
  1254. <newline>
  1255. characters after the current character on the current line, it shall be
  1256. an error.
  1257. .P
  1258. .IR "Current line" :
  1259. Unchanged.
  1260. .P
  1261. .IR "Current column" :
  1262. Set to the last column that displays any portion of the
  1263. .IR count th
  1264. character after the current character.
  1265. .SS "Replace Text with Results from Shell Command"
  1266. .IP "\fISynopsis\fR:" 10
  1267. .sp -1v
  1268. .RS 10
  1269. .sp
  1270. .RS 4
  1271. .nf
  1272. \fB[\fIcount\fB]\fR ! \fImotion shell-commands\fR <newline>
  1273. .fi
  1274. .P
  1275. .RE
  1276. .RE
  1277. .P
  1278. If the motion command is the
  1279. .BR !
  1280. command repeated:
  1281. .IP " 1." 4
  1282. If the edit buffer is empty and no
  1283. .IR count
  1284. was supplied, the command shall be the equivalent of the
  1285. .IR ex
  1286. .BR :read
  1287. .BR !
  1288. command, with the text input, and no text shall be copied to any
  1289. buffer.
  1290. .IP " 2." 4
  1291. Otherwise:
  1292. .RS 4
  1293. .IP " a." 4
  1294. If there are less than
  1295. .IR count
  1296. \-1 lines after the current line in the edit buffer, it shall be an
  1297. error.
  1298. .IP " b." 4
  1299. The text region shall be from the current line up to and including the
  1300. next
  1301. .IR count
  1302. \-1 lines.
  1303. .RE
  1304. .P
  1305. Otherwise, the text region shall be the lines in which any character of
  1306. the text region specified by the motion command appear.
  1307. .P
  1308. Any text copied to a buffer shall be in line mode.
  1309. .P
  1310. This command shall be equivalent to the
  1311. .IR ex
  1312. .BR !
  1313. command for the specified lines.
  1314. .SS "Move Cursor to End-of-Line"
  1315. .IP "\fISynopsis\fR:" 10
  1316. .sp -1v
  1317. .RS 10
  1318. .sp
  1319. .RS 4
  1320. .nf
  1321. \fB[\fIcount\fB]\fR $
  1322. .fi
  1323. .P
  1324. .RE
  1325. .RE
  1326. .P
  1327. It shall be an error if there are less than (\c
  1328. .IR count
  1329. \-1) lines after the current line in the edit buffer.
  1330. .P
  1331. If used as a motion command:
  1332. .IP " 1." 4
  1333. If
  1334. .IR count
  1335. is 1:
  1336. .RS 4
  1337. .IP " a." 4
  1338. It shall be an error if the line is empty.
  1339. .IP " b." 4
  1340. Otherwise, the text region shall consist of all characters from the
  1341. starting cursor to the last non-\c
  1342. <newline>
  1343. in the line, inclusive, and any text copied to a buffer shall be in
  1344. character mode.
  1345. .RE
  1346. .IP " 2." 4
  1347. Otherwise, if the starting cursor position is at or before the first
  1348. non-\c
  1349. <blank>
  1350. in the line, the text region shall consist of the current and the next
  1351. .IR count
  1352. \-1 lines, and any text saved to a buffer shall be in line mode.
  1353. .IP " 3." 4
  1354. Otherwise, the text region shall consist of all characters from the
  1355. starting cursor to the last non-\c
  1356. <newline>
  1357. in the line that is
  1358. .IR count
  1359. \-1 lines forward from the current line, and any text copied to a
  1360. buffer shall be in character mode.
  1361. .P
  1362. If not used as a motion command:
  1363. .P
  1364. .IR "Current line" :
  1365. Set to the
  1366. .IR "current line"
  1367. +
  1368. .IR count \-1.
  1369. .P
  1370. .IR "Current column" :
  1371. The current column is set to the last display line column of the last
  1372. non-\c
  1373. <newline>
  1374. in the line, or column position 1 if the line is empty.
  1375. .P
  1376. The current column shall be adjusted to be on the last display line
  1377. column of the last non-\c
  1378. <newline>
  1379. of the current line as subsequent commands change the current line,
  1380. until a command changes the current column.
  1381. .SS "Move to Matching Character"
  1382. .IP "\fISynopsis\fR:" 10
  1383. .sp -1v
  1384. .RS 10
  1385. .sp
  1386. .RS 4
  1387. .nf
  1388. %
  1389. .fi
  1390. .P
  1391. .RE
  1392. .RE
  1393. .P
  1394. If the character at the current position is not a parenthesis, bracket,
  1395. or curly brace, search forward in the line to the first one of those
  1396. characters. If no such character is found, it shall be an error.
  1397. .P
  1398. The matching character shall be the parenthesis, bracket, or curly
  1399. brace matching the parenthesis, bracket, or curly brace, respectively,
  1400. that was at the current position or that was found on the current
  1401. line.
  1402. .P
  1403. Matching shall be determined as follows, for an open parenthesis:
  1404. .IP " 1." 4
  1405. Set a counter to 1.
  1406. .IP " 2." 4
  1407. Search forwards until a parenthesis is found or the end of the edit
  1408. buffer is reached.
  1409. .IP " 3." 4
  1410. If the end of the edit buffer is reached, it shall be an error.
  1411. .IP " 4." 4
  1412. If an open parenthesis is found, increment the counter by 1.
  1413. .IP " 5." 4
  1414. If a close parenthesis is found, decrement the counter by 1.
  1415. .IP " 6." 4
  1416. If the counter is zero, the current character is the matching
  1417. character.
  1418. .P
  1419. Matching for a close parenthesis shall be equivalent, except that the
  1420. search shall be backwards, from the starting character to the beginning
  1421. of the buffer, a close parenthesis shall increment the counter by 1,
  1422. and an open parenthesis shall decrement the counter by 1.
  1423. .P
  1424. Matching for brackets and curly braces shall be equivalent, except that
  1425. searching shall be done for open and close brackets or open and close
  1426. curly braces. It is implementation-defined whether other characters
  1427. are searched for and matched as well.
  1428. .P
  1429. If used as a motion command:
  1430. .IP " 1." 4
  1431. If the matching cursor was after the starting cursor in the edit
  1432. buffer, and the starting cursor position was at or before the first
  1433. non-\c
  1434. <blank>
  1435. non-\c
  1436. <newline>
  1437. in the starting line, and the matching cursor position was at or after
  1438. the last non-\c
  1439. <blank>
  1440. non-\c
  1441. <newline>
  1442. in the matching line, the text region shall consist of the current line
  1443. to the matching line, inclusive, and any text copied to a buffer shall
  1444. be in line mode.
  1445. .IP " 2." 4
  1446. If the matching cursor was before the starting cursor in the edit
  1447. buffer, and the starting cursor position was at or after the last
  1448. non-\c
  1449. <blank>
  1450. non-\c
  1451. <newline>
  1452. in the starting line, and the matching cursor position was at or before
  1453. the first non-\c
  1454. <blank>
  1455. non-\c
  1456. <newline>
  1457. in the matching line, the text region shall consist of the current line
  1458. to the matching line, inclusive, and any text copied to a buffer shall
  1459. be in line mode.
  1460. .IP " 3." 4
  1461. Otherwise, the text region shall consist of the starting character to
  1462. the matching character, inclusive, and any text copied to a buffer
  1463. shall be in character mode.
  1464. .P
  1465. If not used as a motion command:
  1466. .P
  1467. .IR "Current line" :
  1468. Set to the line where the matching character is located.
  1469. .P
  1470. .IR "Current column" :
  1471. Set to the last column where any portion of the matching character is
  1472. displayed.
  1473. .SS "Repeat Substitution"
  1474. .IP "\fISynopsis\fR:" 10
  1475. .sp -1v
  1476. .RS 10
  1477. .sp
  1478. .RS 4
  1479. .nf
  1480. &
  1481. .fi
  1482. .P
  1483. .RE
  1484. .RE
  1485. .P
  1486. Repeat the previous substitution command. This command shall be
  1487. equivalent to the
  1488. .IR ex
  1489. .BR &
  1490. command with the current line as its addresses, and without
  1491. .IR options ,
  1492. .IR count ,
  1493. or
  1494. .IR flags .
  1495. .SS "Return to Previous Context at Beginning of Line"
  1496. .IP "\fISynopsis\fR:" 10
  1497. .sp -1v
  1498. .RS 10
  1499. .sp
  1500. .RS 4
  1501. .nf
  1502. \&\(aq \fIcharacter\fR
  1503. .fi
  1504. .P
  1505. .RE
  1506. .RE
  1507. .P
  1508. It shall be an error if there is no line in the edit buffer marked by
  1509. .IR character .
  1510. .P
  1511. If used as a motion command:
  1512. .IP " 1." 4
  1513. If the starting cursor is after the marked cursor, then the locations
  1514. of the starting cursor and the marked cursor in the edit buffer shall
  1515. be logically swapped.
  1516. .IP " 2." 4
  1517. The text region shall consist of the starting line up to and including
  1518. the marked line, and any text copied to a buffer shall be in line
  1519. mode.
  1520. .P
  1521. If not used as a motion command:
  1522. .P
  1523. .IR "Current line" :
  1524. Set to the line referenced by the mark.
  1525. .P
  1526. .IR "Current column" :
  1527. Set to non-\c
  1528. <blank>.
  1529. .SS "Return to Previous Context"
  1530. .IP "\fISynopsis\fR:" 10
  1531. .sp -1v
  1532. .RS 10
  1533. .sp
  1534. .RS 4
  1535. .nf
  1536. \&` \fIcharacter\fR
  1537. .fi
  1538. .P
  1539. .RE
  1540. .RE
  1541. .P
  1542. It shall be an error if the marked line is no longer in the edit
  1543. buffer. If the marked line no longer contains a character in the saved
  1544. numbered character position, it shall be as if the marked position is
  1545. the first non-\c
  1546. <blank>.
  1547. .P
  1548. If used as a motion command:
  1549. .IP " 1." 4
  1550. It shall be an error if the marked cursor references the same character
  1551. in the edit buffer as the starting cursor.
  1552. .IP " 2." 4
  1553. If the starting cursor is after the marked cursor, then the locations
  1554. of the starting cursor and the marked cursor in the edit buffer shall
  1555. be logically swapped.
  1556. .IP " 3." 4
  1557. If the starting line is empty or the starting cursor is at or before
  1558. the first non-\c
  1559. <blank>
  1560. non-\c
  1561. <newline>
  1562. of the starting line, and the marked cursor line is empty or the marked
  1563. cursor references the first character of the marked cursor line, the
  1564. text region shall consist of all lines containing characters from the
  1565. starting cursor to the line before the marked cursor line, inclusive,
  1566. and any text copied to a buffer shall be in line mode.
  1567. .IP " 4." 4
  1568. Otherwise, if the marked cursor line is empty or the marked cursor
  1569. references a character at or before the first non-\c
  1570. <blank>
  1571. non-\c
  1572. <newline>
  1573. of the marked cursor line, the region of text shall be from the
  1574. starting cursor to the last non-\c
  1575. <newline>
  1576. of the line before the marked cursor line, inclusive, and any text
  1577. copied to a buffer shall be in character mode.
  1578. .IP " 5." 4
  1579. Otherwise, the region of text shall be from the starting cursor
  1580. (inclusive), to the marked cursor (exclusive), and any text copied to a
  1581. buffer shall be in character mode.
  1582. .P
  1583. If not used as a motion command:
  1584. .P
  1585. .IR "Current line" :
  1586. Set to the line referenced by the mark.
  1587. .P
  1588. .IR "Current column" :
  1589. Set to the last column in which any portion of the character referenced
  1590. by the mark is displayed.
  1591. .SS "Return to Previous Section"
  1592. .IP "\fISynopsis\fR:" 10
  1593. .sp -1v
  1594. .RS 10
  1595. .sp
  1596. .RS 4
  1597. .nf
  1598. \fB[\fIcount\fB]\fR [[
  1599. .fi
  1600. .P
  1601. .RE
  1602. .RE
  1603. .P
  1604. Move the cursor backward through the edit buffer to the first character
  1605. of the previous section boundary,
  1606. .IR count
  1607. times.
  1608. .P
  1609. If used as a motion command:
  1610. .IP " 1." 4
  1611. If the starting cursor was at the first character of the starting line
  1612. or the starting line was empty, and the first character of the boundary
  1613. was the first character of the boundary line, the text region shall
  1614. consist of the current line up to and including the line where the
  1615. .IR count th
  1616. next boundary starts, and any text copied to a buffer shall be in line
  1617. mode.
  1618. .IP " 2." 4
  1619. If the boundary was the last line of the edit buffer or the last non-\c
  1620. <newline>
  1621. of the last line of the edit buffer, the text region shall consist of
  1622. the last character in the edit buffer up to and including the starting
  1623. character, and any text saved to a buffer shall be in character mode.
  1624. .IP " 3." 4
  1625. Otherwise, the text region shall consist of the starting character up
  1626. to but not including the first character in the
  1627. .IR count th
  1628. next boundary, and any text copied to a buffer shall be in character
  1629. mode.
  1630. .P
  1631. If not used as a motion command:
  1632. .P
  1633. .IR "Current line" :
  1634. Set to the line where the
  1635. .IR count th
  1636. next boundary in the edit buffer starts.
  1637. .P
  1638. .IR "Current column" :
  1639. Set to the last column in which any portion of the first character of
  1640. the
  1641. .IR count th
  1642. next boundary is displayed, or column position 1 if the line is empty.
  1643. .SS "Move to Next Section"
  1644. .IP "\fISynopsis\fR:" 10
  1645. .sp -1v
  1646. .RS 10
  1647. .sp
  1648. .RS 4
  1649. .nf
  1650. \fB[\fIcount\fB]\fR ]]
  1651. .fi
  1652. .P
  1653. .RE
  1654. .RE
  1655. .P
  1656. Move the cursor forward through the edit buffer to the first character
  1657. of the next section boundary,
  1658. .IR count
  1659. times.
  1660. .P
  1661. If used as a motion command:
  1662. .IP " 1." 4
  1663. If the starting cursor was at the first character of the starting line
  1664. or the starting line was empty, and the first character of the boundary
  1665. was the first character of the boundary line, the text region shall
  1666. consist of the current line up to and including the line where the
  1667. .IR count th
  1668. previous boundary starts, and any text copied to a buffer shall be in
  1669. line mode.
  1670. .IP " 2." 4
  1671. If the boundary was the first line of the edit buffer, the text region
  1672. shall consist of the first character in the edit buffer up to but not
  1673. including the starting character, and any text copied to a buffer shall
  1674. be in character mode.
  1675. .IP " 3." 4
  1676. Otherwise, the text region shall consist of the first character in the
  1677. .IR count th
  1678. previous section boundary up to but not including the starting
  1679. character, and any text copied to a buffer shall be in character mode.
  1680. .P
  1681. If not used as a motion command:
  1682. .P
  1683. .IR "Current line" :
  1684. Set to the line where the
  1685. .IR count th
  1686. previous boundary in the edit buffer starts.
  1687. .P
  1688. .IR "Current column" :
  1689. Set to the last column in which any portion of the first character of
  1690. the
  1691. .IR count th
  1692. previous boundary is displayed, or column position 1 if the line is
  1693. empty.
  1694. .SS "Move to First Non-<blank> Position on Current Line"
  1695. .IP "\fISynopsis\fR:" 10
  1696. .sp -1v
  1697. .RS 10
  1698. .sp
  1699. .RS 4
  1700. .nf
  1701. \&\(ha
  1702. .fi
  1703. .P
  1704. .RE
  1705. .RE
  1706. If used as a motion command:
  1707. .IP " 1." 4
  1708. If the line has no non-\c
  1709. <blank>
  1710. non-\c
  1711. <newline>
  1712. characters, or if the cursor is at the first non-\c
  1713. <blank>
  1714. non-\c
  1715. <newline>
  1716. of the line, it shall be an error.
  1717. .IP " 2." 4
  1718. If the cursor is before the first non-\c
  1719. <blank>
  1720. non-\c
  1721. <newline>
  1722. of the line, the text region shall be comprised of the current
  1723. character, up to, but not including, the first non-\c
  1724. <blank>
  1725. non-\c
  1726. <newline>
  1727. of the line.
  1728. .IP " 3." 4
  1729. If the cursor is after the first non-\c
  1730. <blank>
  1731. non-\c
  1732. <newline>
  1733. of the line, the text region shall be from the character before the
  1734. starting cursor up to and including the first non-\c
  1735. <blank>
  1736. non-\c
  1737. <newline>
  1738. of the line.
  1739. .IP " 4." 4
  1740. Any text copied to a buffer shall be in character mode.
  1741. .P
  1742. If not used as a motion command:
  1743. .P
  1744. .IR "Current line" :
  1745. Unchanged.
  1746. .P
  1747. .IR "Current column" :
  1748. Set to non-\c
  1749. <blank>.
  1750. .SS "Current and Line Above"
  1751. .IP "\fISynopsis\fR:" 10
  1752. .sp -1v
  1753. .RS 10
  1754. .sp
  1755. .RS 4
  1756. .nf
  1757. \fB[\fIcount\fB]\fR _
  1758. .fi
  1759. .P
  1760. .RE
  1761. .RE
  1762. .P
  1763. If there are less than
  1764. .IR count
  1765. \-1 lines after the current line in the edit buffer, it shall be an
  1766. error.
  1767. .P
  1768. If used as a motion command:
  1769. .IP " 1." 4
  1770. If
  1771. .IR count
  1772. is less than 2, the text region shall be the current line.
  1773. .IP " 2." 4
  1774. Otherwise, the text region shall include the starting line and the next
  1775. .IR count
  1776. \-1 lines.
  1777. .IP " 3." 4
  1778. Any text copied to a buffer shall be in line mode.
  1779. .P
  1780. If not used as a motion command:
  1781. .P
  1782. .IR "Current line" :
  1783. Set to current line +
  1784. .IR count
  1785. \-1.
  1786. .P
  1787. .IR "Current column" :
  1788. Set to non-\c
  1789. <blank>.
  1790. .SS "Move Back to Beginning of Sentence"
  1791. .IP "\fISynopsis\fR:" 10
  1792. .sp -1v
  1793. .RS 10
  1794. .sp
  1795. .RS 4
  1796. .nf
  1797. \fB[\fIcount\fB]\fR (
  1798. .fi
  1799. .P
  1800. .RE
  1801. .RE
  1802. .P
  1803. Move backward to the beginning of a sentence. This command shall be
  1804. equivalent to the
  1805. .BR [[
  1806. command, with the exception that sentence boundaries shall be used
  1807. instead of section boundaries.
  1808. .SS "Move Forward to Beginning of Sentence"
  1809. .IP "\fISynopsis\fR:" 10
  1810. .sp -1v
  1811. .RS 10
  1812. .sp
  1813. .RS 4
  1814. .nf
  1815. \fB[\fIcount\fB]\fR )
  1816. .fi
  1817. .P
  1818. .RE
  1819. .RE
  1820. .P
  1821. Move forward to the beginning of a sentence. This command shall be
  1822. equivalent to the
  1823. .BR ]]
  1824. command, with the exception that sentence boundaries shall be used
  1825. instead of section boundaries.
  1826. .SS "Move Back to Preceding Paragraph"
  1827. .IP "\fISynopsis\fR:" 10
  1828. .sp -1v
  1829. .RS 10
  1830. .sp
  1831. .RS 4
  1832. .nf
  1833. \fB[\fIcount\fB]\fR {
  1834. .fi
  1835. .P
  1836. .RE
  1837. .RE
  1838. .P
  1839. Move back to the beginning of the preceding paragraph. This command
  1840. shall be equivalent to the
  1841. .BR [[
  1842. command, with the exception that paragraph boundaries shall be used
  1843. instead of section boundaries.
  1844. .SS "Move Forward to Next Paragraph"
  1845. .IP "\fISynopsis\fR:" 10
  1846. .sp -1v
  1847. .RS 10
  1848. .sp
  1849. .RS 4
  1850. .nf
  1851. \fB[\fIcount\fB]\fR }
  1852. .fi
  1853. .P
  1854. .RE
  1855. .RE
  1856. .P
  1857. Move forward to the beginning of the next paragraph. This command
  1858. shall be equivalent to the
  1859. .BR ]]
  1860. command, with the exception that paragraph boundaries shall be used
  1861. instead of section boundaries.
  1862. .SS "Move to Specific Column Position"
  1863. .IP "\fISynopsis\fR:" 10
  1864. .sp -1v
  1865. .RS 10
  1866. .sp
  1867. .RS 4
  1868. .nf
  1869. \fB[\fIcount\fB]\fR |
  1870. .fi
  1871. .P
  1872. .RE
  1873. .RE
  1874. .P
  1875. For the purposes of this command, lines that are too long for the
  1876. current display and that have been folded shall be treated as having a
  1877. single, 1\-based, number of columns.
  1878. .P
  1879. If there are less than
  1880. .IR count
  1881. columns in which characters from the current line are displayed on the
  1882. screen,
  1883. .IR count
  1884. shall be adjusted to be the last column in which any portion of the
  1885. line is displayed on the screen.
  1886. .P
  1887. If used as a motion command:
  1888. .IP " 1." 4
  1889. If the line is empty, or the cursor character is the same as the
  1890. character on the
  1891. .IR count th
  1892. column of the line, it shall be an error.
  1893. .IP " 2." 4
  1894. If the cursor is before the
  1895. .IR count th
  1896. column of the line, the text region shall be comprised of the current
  1897. character, up to but not including the character on the
  1898. .IR count th
  1899. column of the line.
  1900. .IP " 3." 4
  1901. If the cursor is after the
  1902. .IR count th
  1903. column of the line, the text region shall be from the character before
  1904. the starting cursor up to and including the character on the
  1905. .IR count th
  1906. column of the line.
  1907. .IP " 4." 4
  1908. Any text copied to a buffer shall be in character mode.
  1909. .P
  1910. If not used as a motion command:
  1911. .P
  1912. .IR "Current line" :
  1913. Unchanged.
  1914. .P
  1915. .IR "Current column" :
  1916. Set to the last column in which any portion of the character that is
  1917. displayed in the
  1918. .IR count
  1919. column of the line is displayed.
  1920. .SS "Reverse Find Character"
  1921. .IP "\fISynopsis\fR:" 10
  1922. .sp -1v
  1923. .RS 10
  1924. .sp
  1925. .RS 4
  1926. .nf
  1927. \fB[\fIcount\fB]\fR ,
  1928. .fi
  1929. .P
  1930. .RE
  1931. .RE
  1932. .P
  1933. If the last
  1934. .BR F ,
  1935. .BR f ,
  1936. .BR T ,
  1937. or
  1938. .BR t
  1939. command was
  1940. .BR F ,
  1941. .BR f ,
  1942. .BR T ,
  1943. or
  1944. .BR t ,
  1945. this command shall be equivalent to an
  1946. .BR f ,
  1947. .BR F ,
  1948. .BR t ,
  1949. or
  1950. .BR T
  1951. command, respectively, with the specified
  1952. .IR count
  1953. and the same search character.
  1954. .P
  1955. If there was no previous
  1956. .BR F ,
  1957. .BR f ,
  1958. .BR T ,
  1959. or
  1960. .BR t
  1961. command, it shall be an error.
  1962. .SS "Repeat"
  1963. .IP "\fISynopsis\fR:" 10
  1964. .sp -1v
  1965. .RS 10
  1966. .sp
  1967. .RS 4
  1968. .nf
  1969. \fB[\fIcount\fB]\fR .
  1970. .fi
  1971. .P
  1972. .RE
  1973. .RE
  1974. .P
  1975. Repeat the last
  1976. .BR ! ,
  1977. .BR < ,
  1978. .BR > ,
  1979. .BR A ,
  1980. .BR C ,
  1981. .BR D ,
  1982. .BR I ,
  1983. .BR J ,
  1984. .BR O ,
  1985. .BR P ,
  1986. .BR R ,
  1987. .BR S ,
  1988. .BR X ,
  1989. .BR Y ,
  1990. .BR a ,
  1991. .BR c ,
  1992. .BR d ,
  1993. .BR i ,
  1994. .BR o ,
  1995. .BR p ,
  1996. .BR r ,
  1997. .BR s ,
  1998. .BR x ,
  1999. .BR y ,
  2000. or
  2001. .BR ~
  2002. command. It shall be an error if none of these commands have been
  2003. executed. Commands (other than commands that enter text input mode)
  2004. executed as a result of map expansions, shall not change the value of
  2005. the last repeatable command.
  2006. .P
  2007. Repeated commands with associated motion commands shall repeat the
  2008. motion command as well; however, any specified
  2009. .IR count
  2010. shall replace the
  2011. .IR count (s)
  2012. that were originally specified to the repeated command or its
  2013. associated motion command.
  2014. .P
  2015. If the motion component of the repeated command is
  2016. .BR f ,
  2017. .BR F ,
  2018. .BR t ,
  2019. or
  2020. .BR T ,
  2021. the repeated command shall not set the remembered search character for
  2022. the
  2023. .BR ;
  2024. and
  2025. .BR ,
  2026. commands.
  2027. .P
  2028. If the repeated command is
  2029. .BR p
  2030. or
  2031. .BR P ,
  2032. and the buffer associated with that command was a numeric buffer named
  2033. with a number less than 9, the buffer associated with the repeated
  2034. command shall be set to be the buffer named by the name of the previous
  2035. buffer logically incremented by 1.
  2036. .P
  2037. If the repeated character is a text input command, the input text
  2038. associated with that command is repeated literally:
  2039. .IP " *" 4
  2040. Input characters are neither macro or abbreviation-expanded.
  2041. .IP " *" 4
  2042. Input characters are not interpreted in any special way with the
  2043. exception that
  2044. <newline>,
  2045. <carriage-return>,
  2046. and
  2047. <control>\(hyT
  2048. behave as described in
  2049. .IR "Input Mode Commands in vi".
  2050. .P
  2051. .IR "Current line" :
  2052. Set as described for the repeated command.
  2053. .P
  2054. .IR "Current column" :
  2055. Set as described for the repeated command.
  2056. .SS "Find Regular Expression"
  2057. .IP "\fISynopsis\fR:" 10
  2058. .sp -1v
  2059. .RS 10
  2060. .sp
  2061. .RS 4
  2062. .nf
  2063. /
  2064. .fi
  2065. .P
  2066. .RE
  2067. .RE
  2068. .P
  2069. If the input line contains no non-\c
  2070. <newline>
  2071. characters, it shall be equivalent to a line containing only the
  2072. last regular expression encountered. The enhanced regular expressions
  2073. supported by
  2074. .IR vi
  2075. are described in
  2076. .IR "Regular Expressions in ex".
  2077. .P
  2078. Otherwise, the line shall be interpreted as one or more regular
  2079. expressions, optionally followed by an address offset or a
  2080. .IR vi
  2081. .BR z
  2082. command.
  2083. .P
  2084. If the regular expression is not the last regular expression on the
  2085. line, or if a line offset or
  2086. .BR z
  2087. command is specified, the regular expression shall be terminated by an
  2088. unescaped
  2089. .BR '/'
  2090. character, which shall not be used as part of the regular expression.
  2091. If the regular expression is not the first regular expression on the
  2092. line, it shall be preceded by zero or more
  2093. <blank>
  2094. characters, a
  2095. <semicolon>,
  2096. zero or more
  2097. <blank>
  2098. characters, and a leading
  2099. .BR '/'
  2100. character, which shall not be interpreted as part of the regular
  2101. expression. It shall be an error to precede any regular expression with
  2102. any characters other than these.
  2103. .P
  2104. Each search shall begin from the character after the first character of
  2105. the last match (or, if it is the first search, after the cursor). If
  2106. the
  2107. .BR wrapscan
  2108. edit option is set, the search shall continue to the character before
  2109. the starting cursor character; otherwise, to the end of the edit
  2110. buffer. It shall be an error if any search fails to find a match, and
  2111. an informational message to this effect shall be displayed.
  2112. .P
  2113. An optional address offset (see
  2114. .IR "Addressing in ex")
  2115. can be specified after the last regular expression by including a
  2116. trailing
  2117. .BR '/'
  2118. character after the regular expression and specifying the address
  2119. offset. This offset will be from the line containing the match for the
  2120. last regular expression specified. It shall be an error if the line
  2121. offset would indicate a line address less than 1 or greater than the
  2122. last line in the edit buffer. An address offset of zero shall be
  2123. supported. It shall be an error to follow the address offset with any
  2124. other characters than
  2125. <blank>
  2126. characters.
  2127. .P
  2128. If not used as a motion command, an optional
  2129. .BR z
  2130. command (see
  2131. .IR "Redraw Window")
  2132. can be specified after the last regular expression by including a
  2133. trailing
  2134. .BR '/'
  2135. character after the regular expression, zero or more
  2136. <blank>
  2137. characters, a
  2138. .BR 'z' ,
  2139. zero or more
  2140. <blank>
  2141. characters, an optional new
  2142. .BR window
  2143. edit option value, zero or more
  2144. <blank>
  2145. characters, and a location character. The effect shall be as if the
  2146. .BR z
  2147. command was executed after the
  2148. .BR /
  2149. command. It shall be an error to follow the
  2150. .BR z
  2151. command with any other characters than
  2152. <blank>
  2153. characters.
  2154. .P
  2155. The remembered search direction shall be set to forward.
  2156. .P
  2157. If used as a motion command:
  2158. .IP " 1." 4
  2159. It shall be an error if the last match references the same character in
  2160. the edit buffer as the starting cursor.
  2161. .IP " 2." 4
  2162. If any address offset is specified, the last match shall be adjusted by
  2163. the specified offset as described previously.
  2164. .IP " 3." 4
  2165. If the starting cursor is after the last match, then the locations of
  2166. the starting cursor and the last match in the edit buffer shall be
  2167. logically swapped.
  2168. .IP " 4." 4
  2169. If any address offset is specified, the text region shall consist of
  2170. all lines containing characters from the starting cursor to the last
  2171. match line, inclusive, and any text copied to a buffer shall be in line
  2172. mode.
  2173. .IP " 5." 4
  2174. Otherwise, if the starting line is empty or the starting cursor is at
  2175. or before the first non-\c
  2176. <blank>
  2177. non-\c
  2178. <newline>
  2179. of the starting line, and the last match line is empty or the last
  2180. match starts at the first character of the last match line, the text
  2181. region shall consist of all lines containing characters from the
  2182. starting cursor to the line before the last match line, inclusive, and
  2183. any text copied to a buffer shall be in line mode.
  2184. .IP " 6." 4
  2185. Otherwise, if the last match line is empty or the last match begins at
  2186. a character at or before the first non-\c
  2187. <blank>
  2188. non-\c
  2189. <newline>
  2190. of the last match line, the region of text shall be from the current
  2191. cursor to the last non-\c
  2192. <newline>
  2193. of the line before the last match line, inclusive, and any text copied
  2194. to a buffer shall be in character mode.
  2195. .IP " 7." 4
  2196. Otherwise, the region of text shall be from the current cursor
  2197. (inclusive), to the first character of the last match (exclusive), and
  2198. any text copied to a buffer shall be in character mode.
  2199. .P
  2200. If not used as a motion command:
  2201. .P
  2202. .IR "Current line" :
  2203. If a match is found, set to the last matched line plus the address
  2204. offset, if any; otherwise, unchanged.
  2205. .P
  2206. .IR "Current column" :
  2207. Set to the last column on which any portion of the first character in
  2208. the last matched string is displayed, if a match is found; otherwise,
  2209. unchanged.
  2210. .SS "Move to First Character in Line"
  2211. .IP "\fISynopsis\fR:" 10
  2212. .sp -1v
  2213. .RS 10
  2214. .sp
  2215. .RS 4
  2216. .nf
  2217. 0 \fR(zero)\fR
  2218. .fi
  2219. .P
  2220. .RE
  2221. .RE
  2222. .P
  2223. Move to the first character on the current line. The character
  2224. .BR '0'
  2225. shall not be interpreted as a command if it is immediately preceded by
  2226. a digit.
  2227. .P
  2228. If used as a motion command:
  2229. .IP " 1." 4
  2230. If the cursor character is the first character in the line, it shall be
  2231. an error.
  2232. .IP " 2." 4
  2233. The text region shall be from the character before the cursor character
  2234. up to and including the first character in the line.
  2235. .IP " 3." 4
  2236. Any text copied to a buffer shall be in character mode.
  2237. .P
  2238. If not used as a motion command:
  2239. .P
  2240. .IR "Current line" :
  2241. Unchanged.
  2242. .P
  2243. .IR "Current column" :
  2244. The last column in which any portion of the first character in the line
  2245. is displayed, or if the line is empty, unchanged.
  2246. .SS "Execute an ex Command"
  2247. .IP "\fISynopsis\fR:" 10
  2248. .sp -1v
  2249. .RS 10
  2250. .sp
  2251. .RS 4
  2252. .nf
  2253. :
  2254. .fi
  2255. .P
  2256. .RE
  2257. .RE
  2258. .P
  2259. Execute one or more
  2260. .IR ex
  2261. commands.
  2262. .P
  2263. If any portion of the screen other than the last line of the screen was
  2264. overwritten by any
  2265. .IR ex
  2266. command (except
  2267. .BR shell ),
  2268. .IR vi
  2269. shall display a message indicating that it is waiting for an input from
  2270. the user, and shall then read a character. This action may also be
  2271. taken for other, unspecified reasons.
  2272. .P
  2273. If the next character entered is a
  2274. .BR ':' ,
  2275. another
  2276. .IR ex
  2277. command shall be accepted and executed. Any other character shall cause
  2278. the screen to be refreshed and
  2279. .IR vi
  2280. shall return to command mode.
  2281. .P
  2282. .IR "Current line" :
  2283. As specified for the
  2284. .IR ex
  2285. command.
  2286. .P
  2287. .IR "Current column" :
  2288. As specified for the
  2289. .IR ex
  2290. command.
  2291. .SS "Repeat Find"
  2292. .IP "\fISynopsis\fR:" 10
  2293. .sp -1v
  2294. .RS 10
  2295. .sp
  2296. .RS 4
  2297. .nf
  2298. \fB[\fIcount\fB]\fR ;
  2299. .fi
  2300. .P
  2301. .RE
  2302. .RE
  2303. .P
  2304. This command shall be equivalent to the last
  2305. .BR F ,
  2306. .BR f ,
  2307. .BR T ,
  2308. or
  2309. .BR t
  2310. command, with the specified
  2311. .IR count ,
  2312. and with the same search character used for the last
  2313. .BR F ,
  2314. .BR f ,
  2315. .BR T ,
  2316. or
  2317. .BR t
  2318. command. If there was no previous
  2319. .BR F ,
  2320. .BR f ,
  2321. .BR T ,
  2322. or
  2323. .BR t
  2324. command, it shall be an error.
  2325. .SS "Shift Left"
  2326. .IP "\fISynopsis\fR:" 10
  2327. .sp -1v
  2328. .RS 10
  2329. .sp
  2330. .RS 4
  2331. .nf
  2332. \fB[\fIcount\fB]\fR < \fImotion\fR
  2333. .fi
  2334. .P
  2335. .RE
  2336. .RE
  2337. .P
  2338. If the motion command is the
  2339. .BR <
  2340. command repeated:
  2341. .IP " 1." 4
  2342. If there are less than
  2343. .IR count
  2344. \-1 lines after the current line in the edit buffer, it shall be an
  2345. error.
  2346. .IP " 2." 4
  2347. The text region shall be from the current line, up to and including the
  2348. next
  2349. .IR count
  2350. \-1 lines.
  2351. .P
  2352. Shift any line in the text region specified by the
  2353. .IR count
  2354. and motion command one shiftwidth (see the
  2355. .IR ex
  2356. .BR shiftwidth
  2357. option) toward the start of the line, as described by the
  2358. .IR ex
  2359. .BR <
  2360. command. The unshifted lines shall be copied to the unnamed buffer in
  2361. line mode.
  2362. .P
  2363. .IR "Current line" :
  2364. If the motion was from the current cursor position toward the end of
  2365. the edit buffer, unchanged. Otherwise, set to the first line in the
  2366. edit buffer that is part of the text region specified by the motion
  2367. command.
  2368. .P
  2369. .IR "Current column" :
  2370. Set to non-\c
  2371. <blank>.
  2372. .SS "Shift Right"
  2373. .IP "\fISynopsis\fR:" 10
  2374. .sp -1v
  2375. .RS 10
  2376. .sp
  2377. .RS 4
  2378. .nf
  2379. \fB[\fIcount\fB]\fR > \fImotion\fR
  2380. .fi
  2381. .P
  2382. .RE
  2383. .RE
  2384. .P
  2385. If the motion command is the
  2386. .BR >
  2387. command repeated:
  2388. .IP " 1." 4
  2389. If there are less than
  2390. .IR count
  2391. \-1 lines after the current line in the edit buffer, it shall be an
  2392. error.
  2393. .IP " 2." 4
  2394. The text region shall be from the current line, up to and including the
  2395. next
  2396. .IR count
  2397. \-1 lines.
  2398. .P
  2399. Shift any line with characters in the text region specified by the
  2400. .IR count
  2401. and motion command one shiftwidth (see the
  2402. .IR ex
  2403. .BR shiftwidth
  2404. option) away from the start of the line, as described by the
  2405. .IR ex
  2406. .BR >
  2407. command. The unshifted lines shall be copied into the unnamed buffer in
  2408. line mode.
  2409. .P
  2410. .IR "Current line" :
  2411. If the motion was from the current cursor position toward the end of
  2412. the edit buffer, unchanged. Otherwise, set to the first line in the
  2413. edit buffer that is part of the text region specified by the
  2414. motion command.
  2415. .P
  2416. .IR "Current column" :
  2417. Set to non-\c
  2418. <blank>.
  2419. .SS "Scan Backwards for Regular Expression"
  2420. .IP "\fISynopsis\fR:" 10
  2421. .sp -1v
  2422. .RS 10
  2423. .sp
  2424. .RS 4
  2425. .nf
  2426. ?
  2427. .fi
  2428. .P
  2429. .RE
  2430. .RE
  2431. .P
  2432. Scan backwards; the
  2433. .BR ?
  2434. command shall be equivalent to the
  2435. .BR /
  2436. command (see
  2437. .IR "Find Regular Expression")
  2438. with the following exceptions:
  2439. .IP " 1." 4
  2440. The input prompt shall be a
  2441. .BR '?' .
  2442. .IP " 2." 4
  2443. Each search shall begin from the character before the first character
  2444. of the last match (or, if it is the first search, the character before
  2445. the cursor character).
  2446. .IP " 3." 4
  2447. The search direction shall be from the cursor toward the beginning of
  2448. the edit buffer, and the
  2449. .BR wrapscan
  2450. edit option shall affect whether the search wraps to the end of the
  2451. edit buffer and continues.
  2452. .IP " 4." 4
  2453. The remembered search direction shall be set to backward.
  2454. .SS "Execute"
  2455. .IP "\fISynopsis\fR:" 10
  2456. .sp -1v
  2457. .RS 10
  2458. .sp
  2459. .RS 4
  2460. .nf
  2461. @\fIbuffer\fR
  2462. .fi
  2463. .P
  2464. .RE
  2465. .RE
  2466. .P
  2467. If the
  2468. .IR buffer
  2469. is specified as
  2470. .BR @ ,
  2471. the last buffer executed shall be used. If no previous buffer has been
  2472. executed, it shall be an error.
  2473. .P
  2474. Behave as if the contents of the named buffer were entered as standard
  2475. input. After each line of a line-mode buffer, and all but the last line
  2476. of a character mode buffer, behave as if a
  2477. <newline>
  2478. were entered as standard input.
  2479. .P
  2480. If an error occurs during this process, an error message shall be
  2481. written, and no more characters resulting from the execution of this
  2482. command shall be processed.
  2483. .P
  2484. If a
  2485. .IR count
  2486. is specified, behave as if that count were entered as user input before
  2487. the characters from the
  2488. .BR @
  2489. buffer were entered.
  2490. .P
  2491. .IR "Current line" :
  2492. As specified for the individual commands.
  2493. .P
  2494. .IR "Current column" :
  2495. As specified for the individual commands.
  2496. .SS "Reverse Case"
  2497. .IP "\fISynopsis\fR:" 10
  2498. .sp -1v
  2499. .RS 10
  2500. .sp
  2501. .RS 4
  2502. .nf
  2503. \fB[\fIcount\fB]\fR \(ti
  2504. .fi
  2505. .P
  2506. .RE
  2507. .RE
  2508. .P
  2509. Reverse the case of the current character and the next
  2510. .IR count
  2511. \-1 characters, such that lowercase characters that have uppercase
  2512. counterparts shall be changed to uppercase characters, and uppercase
  2513. characters that have lowercase counterparts shall be changed to
  2514. lowercase characters, as prescribed by the current locale. No other
  2515. characters shall be affected by this command.
  2516. .P
  2517. If there are less than
  2518. .IR count
  2519. \-1 characters after the cursor in the edit buffer,
  2520. .IR count
  2521. shall be adjusted to the number of characters after the cursor in the
  2522. edit buffer minus 1.
  2523. .P
  2524. For the purposes of this command, the next character after the last
  2525. non-\c
  2526. <newline>
  2527. on the line shall be the next character in the edit buffer.
  2528. .P
  2529. .IR "Current line" :
  2530. Set to the line including the (\c
  2531. .IR count \-1)th
  2532. character after the cursor.
  2533. .P
  2534. .IR "Current column" :
  2535. Set to the last column in which any portion of the (\c
  2536. .IR count \-1)th
  2537. character after the cursor is displayed.
  2538. .SS "Append"
  2539. .IP "\fISynopsis\fR:" 10
  2540. .sp -1v
  2541. .RS 10
  2542. .sp
  2543. .RS 4
  2544. .nf
  2545. \fB[\fIcount\fB]\fR a
  2546. .fi
  2547. .P
  2548. .RE
  2549. .RE
  2550. .P
  2551. Enter text input mode after the current cursor position. No characters
  2552. already in the edit buffer shall be affected by this command. A
  2553. .IR count
  2554. shall cause the input text to be appended
  2555. .IR count
  2556. \-1 more times to the end of the input.
  2557. .P
  2558. .IR "Current line/column" :
  2559. As specified for the text input commands (see
  2560. .IR "Input Mode Commands in vi").
  2561. .SS "Append at End-of-Line"
  2562. .IP "\fISynopsis\fR:" 10
  2563. .sp -1v
  2564. .RS 10
  2565. .sp
  2566. .RS 4
  2567. .nf
  2568. \fB[\fIcount\fB]\fR A
  2569. .fi
  2570. .P
  2571. .RE
  2572. .RE
  2573. .P
  2574. This command shall be equivalent to the
  2575. .IR vi
  2576. command:
  2577. .sp
  2578. .RS 4
  2579. .nf
  2580. \fR$\fB [ \fIcount \fB]\fR a
  2581. .fi
  2582. .P
  2583. .RE
  2584. .P
  2585. (see
  2586. .IR "Append").
  2587. .SS "Move Backward to Preceding Word"
  2588. .IP "\fISynopsis\fR:" 10
  2589. .sp -1v
  2590. .RS 10
  2591. .sp
  2592. .RS 4
  2593. .nf
  2594. \fB[\fIcount\fB]\fR b
  2595. .fi
  2596. .P
  2597. .RE
  2598. .RE
  2599. .P
  2600. With the exception that words are used as the delimiter instead of
  2601. bigwords, this command shall be equivalent to the
  2602. .BR B
  2603. command.
  2604. .SS "Move Backward to Preceding Bigword"
  2605. .IP "\fISynopsis\fR:" 10
  2606. .sp -1v
  2607. .RS 10
  2608. .sp
  2609. .RS 4
  2610. .nf
  2611. \fB[\fIcount\fB]\fR B
  2612. .fi
  2613. .P
  2614. .RE
  2615. .RE
  2616. .P
  2617. If the edit buffer is empty or the cursor is on the first character of
  2618. the edit buffer, it shall be an error. If less than
  2619. .IR count
  2620. bigwords begin between the cursor and the start of the edit buffer,
  2621. .IR count
  2622. shall be adjusted to the number of bigword beginnings between the
  2623. cursor and the start of the edit buffer.
  2624. .P
  2625. If used as a motion command:
  2626. .IP " 1." 4
  2627. The text region shall be from the first character of the
  2628. .IR count th
  2629. previous bigword beginning up to but not including the cursor
  2630. character.
  2631. .IP " 2." 4
  2632. Any text copied to a buffer shall be in character mode.
  2633. .P
  2634. If not used as a motion command:
  2635. .P
  2636. .IR "Current line" :
  2637. Set to the line containing the
  2638. .IR "current column" .
  2639. .P
  2640. .IR "Current column" :
  2641. Set to the last column upon which any part of the first character of
  2642. the
  2643. .IR count th
  2644. previous bigword is displayed.
  2645. .SS "Change"
  2646. .IP "\fISynopsis\fR:" 10
  2647. .sp -1v
  2648. .RS 10
  2649. .sp
  2650. .RS 4
  2651. .nf
  2652. \fB[\fIbuffer\fB][\fIcount\fB]\fR c \fImotion\fR
  2653. .fi
  2654. .P
  2655. .RE
  2656. .RE
  2657. .P
  2658. If the motion command is the
  2659. .BR c
  2660. command repeated:
  2661. .IP " 1." 4
  2662. The buffer text shall be in line mode.
  2663. .IP " 2." 4
  2664. If there are less than
  2665. .IR count
  2666. \-1 lines after the current line in the edit buffer, it shall be an
  2667. error.
  2668. .IP " 3." 4
  2669. The text region shall be from the current line up to and including the
  2670. next
  2671. .IR count
  2672. \-1 lines.
  2673. .P
  2674. Otherwise, the buffer text mode and text region shall be as specified
  2675. by the motion command.
  2676. .P
  2677. The replaced text shall be copied into
  2678. .IR buffer ,
  2679. if specified, and into the unnamed buffer. If the text to be replaced
  2680. contains characters from more than a single line, or the buffer text is
  2681. in line mode, the replaced text shall be copied into the numeric
  2682. buffers as well.
  2683. .P
  2684. If the buffer text is in line mode:
  2685. .IP " 1." 4
  2686. Any lines that contain characters in the region shall be deleted, and
  2687. the editor shall enter text input mode at the beginning of a new line
  2688. which shall replace the first line deleted.
  2689. .IP " 2." 4
  2690. If the
  2691. .BR autoindent
  2692. edit option is set,
  2693. .BR autoindent
  2694. characters equal to the
  2695. .BR autoindent
  2696. characters on the first line deleted shall be inserted as if entered by
  2697. the user.
  2698. .P
  2699. Otherwise, if characters from more than one line are in the region of
  2700. text:
  2701. .IP " 1." 4
  2702. The text shall be deleted.
  2703. .IP " 2." 4
  2704. Any text remaining in the last line in the text region shall be
  2705. appended to the first line in the region, and the last line in the
  2706. region shall be deleted.
  2707. .IP " 3." 4
  2708. The editor shall enter text input mode after the last character not
  2709. deleted from the first line in the text region, if any; otherwise, on
  2710. the first column of the first line in the region.
  2711. .br
  2712. .P
  2713. Otherwise:
  2714. .IP " 1." 4
  2715. If the glyph for
  2716. .BR '$'
  2717. is smaller than the region, the end of the region shall be marked with
  2718. a
  2719. .BR '$' .
  2720. .IP " 2." 4
  2721. The editor shall enter text input mode, overwriting the region of
  2722. text.
  2723. .P
  2724. .IR "Current line/column" :
  2725. As specified for the text input commands (see
  2726. .IR "Input Mode Commands in vi").
  2727. .SS "Change to End-of-Line"
  2728. .IP "\fISynopsis\fR:" 10
  2729. .sp -1v
  2730. .RS 10
  2731. .sp
  2732. .RS 4
  2733. .nf
  2734. \fB[\fIbuffer\fB][\fIcount\fB]\fR C
  2735. .fi
  2736. .P
  2737. .RE
  2738. .RE
  2739. .P
  2740. This command shall be equivalent to the
  2741. .IR vi
  2742. command:
  2743. .sp
  2744. .RS 4
  2745. .nf
  2746. \fB[\fIbuffer\fB][\fIcount\fB]\fR c$
  2747. .fi
  2748. .P
  2749. .RE
  2750. .P
  2751. See the
  2752. .BR c
  2753. command.
  2754. .SS "Delete"
  2755. .IP "\fISynopsis\fR:" 10
  2756. .sp -1v
  2757. .RS 10
  2758. .sp
  2759. .RS 4
  2760. .nf
  2761. \fB[\fIbuffer\fB][\fIcount\fB]\fR d \fImotion\fR
  2762. .fi
  2763. .P
  2764. .RE
  2765. .RE
  2766. .P
  2767. If the motion command is the
  2768. .BR d
  2769. command repeated:
  2770. .IP " 1." 4
  2771. The buffer text shall be in line mode.
  2772. .IP " 2." 4
  2773. If there are less than
  2774. .IR count
  2775. \-1 lines after the current line in the edit buffer, it shall be an
  2776. error.
  2777. .IP " 3." 4
  2778. The text region shall be from the current line up to and including the
  2779. next
  2780. .IR count
  2781. \-1 lines.
  2782. .P
  2783. Otherwise, the buffer text mode and text region shall be as specified
  2784. by the motion command.
  2785. .P
  2786. If in open mode, and the current line is deleted, and the line remains
  2787. on the display, an
  2788. .BR '@'
  2789. character shall be displayed as the first glyph of that line.
  2790. .P
  2791. Delete the region of text into
  2792. .IR buffer ,
  2793. if specified, and into the unnamed buffer. If the text to be deleted
  2794. contains characters from more than a single line, or the buffer text is
  2795. in line mode, the deleted text shall be copied into the numeric
  2796. buffers, as well.
  2797. .P
  2798. .IR "Current line" :
  2799. Set to the first text region line that appears in the edit buffer,
  2800. unless that line has been deleted, in which case it shall be set to the
  2801. last line in the edit buffer, or line 1 if the edit buffer is empty.
  2802. .P
  2803. .IR "Current column" :
  2804. .IP " 1." 4
  2805. If the line is empty, set to column position 1.
  2806. .IP " 2." 4
  2807. Otherwise, if the buffer text is in line mode or the motion was from
  2808. the cursor toward the end of the edit buffer:
  2809. .RS 4
  2810. .IP " a." 4
  2811. If a character from the current line is displayed in the current
  2812. column, set to the last column that displays any portion of that
  2813. character.
  2814. .IP " b." 4
  2815. Otherwise, set to the last column in which any portion of any character
  2816. in the line is displayed.
  2817. .RE
  2818. .IP " 3." 4
  2819. Otherwise, if a character is displayed in the column that began the
  2820. text region, set to the last column that displays any portion of that
  2821. character.
  2822. .IP " 4." 4
  2823. Otherwise, set to the last column in which any portion of any character
  2824. in the line is displayed.
  2825. .SS "Delete to End-of-Line"
  2826. .IP "\fISynopsis\fR:" 10
  2827. .sp -1v
  2828. .RS 10
  2829. .sp
  2830. .RS 4
  2831. .nf
  2832. \fB[\fIbuffer\fB]\fR D
  2833. .fi
  2834. .P
  2835. .RE
  2836. .RE
  2837. .P
  2838. Delete the text from the current position to the end of the current
  2839. line; equivalent to the
  2840. .IR vi
  2841. command:
  2842. .sp
  2843. .RS 4
  2844. .nf
  2845. \fB[\fIbuffer\fB]\fR d$
  2846. .fi
  2847. .P
  2848. .RE
  2849. .SS "Move to End-of-Word"
  2850. .IP "\fISynopsis\fR:" 10
  2851. .sp -1v
  2852. .RS 10
  2853. .sp
  2854. .RS 4
  2855. .nf
  2856. \fB[\fIcount\fB]\fR e
  2857. .fi
  2858. .P
  2859. .RE
  2860. .RE
  2861. .P
  2862. With the exception that words are used instead of bigwords as the
  2863. delimiter, this command shall be equivalent to the
  2864. .BR E
  2865. command.
  2866. .SS "Move to End-of-Bigword"
  2867. .IP "\fISynopsis\fR:" 10
  2868. .sp -1v
  2869. .RS 10
  2870. .sp
  2871. .RS 4
  2872. .nf
  2873. \fB[\fIcount\fB]\fR E
  2874. .fi
  2875. .P
  2876. .RE
  2877. .RE
  2878. .P
  2879. If the edit buffer is empty it shall be an error. If less than
  2880. .IR count
  2881. bigwords end between the cursor and the end of the edit buffer,
  2882. .IR count
  2883. shall be adjusted to the number of bigword endings between the cursor
  2884. and the end of the edit buffer.
  2885. .P
  2886. If used as a motion command:
  2887. .IP " 1." 4
  2888. The text region shall be from the last character of the
  2889. .IR count th
  2890. next bigword up to and including the cursor character.
  2891. .IP " 2." 4
  2892. Any text copied to a buffer shall be in character mode.
  2893. .P
  2894. If not used as a motion command:
  2895. .P
  2896. .IR "Current line" :
  2897. Set to the line containing the current column.
  2898. .P
  2899. .IR "Current column" :
  2900. Set to the last column upon which any part of the last character of the
  2901. .IR count th
  2902. next bigword is displayed.
  2903. .SS "Find Character in Current Line (Forward)"
  2904. .IP "\fISynopsis\fR:" 10
  2905. .sp -1v
  2906. .RS 10
  2907. .sp
  2908. .RS 4
  2909. .nf
  2910. \fB[\fIcount\fB]\fR f \fIcharacter\fR
  2911. .fi
  2912. .P
  2913. .RE
  2914. .RE
  2915. .P
  2916. It shall be an error if
  2917. .IR count
  2918. occurrences of the character do not occur after the cursor in the
  2919. line.
  2920. .P
  2921. If used as a motion command:
  2922. .IP " 1." 4
  2923. The text range shall be from the cursor character up to and including
  2924. the
  2925. .IR count th
  2926. occurrence of the specified character after the cursor.
  2927. .IP " 2." 4
  2928. Any text copied to a buffer shall be in character mode.
  2929. .P
  2930. If not used as a motion command:
  2931. .P
  2932. .IR "Current line" :
  2933. Unchanged.
  2934. .P
  2935. .IR "Current column" :
  2936. Set to the last column in which any portion of the
  2937. .IR count th
  2938. occurrence of the specified character after the cursor appears in the
  2939. line.
  2940. .SS "Find Character in Current Line (Reverse)"
  2941. .IP "\fISynopsis\fR:" 10
  2942. .sp -1v
  2943. .RS 10
  2944. .sp
  2945. .RS 4
  2946. .nf
  2947. \fB[\fIcount\fB]\fR F \fIcharacter\fR
  2948. .fi
  2949. .P
  2950. .RE
  2951. .RE
  2952. .P
  2953. It shall be an error if
  2954. .IR count
  2955. occurrences of the character do not occur before the cursor in the
  2956. line.
  2957. .P
  2958. If used as a motion command:
  2959. .IP " 1." 4
  2960. The text region shall be from the
  2961. .IR count th
  2962. occurrence of the specified character before the cursor, up to, but not
  2963. including the cursor character.
  2964. .IP " 2." 4
  2965. Any text copied to a buffer shall be in character mode.
  2966. .P
  2967. If not used as a motion command:
  2968. .P
  2969. .IR "Current line" :
  2970. Unchanged.
  2971. .P
  2972. .IR "Current column" :
  2973. Set to the last column in which any portion of the
  2974. .IR count th
  2975. occurrence of the specified character before the cursor appears in the
  2976. line.
  2977. .SS "Move to Line"
  2978. .IP "\fISynopsis\fR:" 10
  2979. .sp -1v
  2980. .RS 10
  2981. .sp
  2982. .RS 4
  2983. .nf
  2984. \fB[\fIcount\fB]\fR G
  2985. .fi
  2986. .P
  2987. .RE
  2988. .RE
  2989. .P
  2990. If
  2991. .IR count
  2992. is not specified, it shall default to the last line of the edit buffer.
  2993. If
  2994. .IR count
  2995. is greater than the last line of the edit buffer, it shall be an
  2996. error.
  2997. .P
  2998. If used as a motion command:
  2999. .IP " 1." 4
  3000. The text region shall be from the cursor line up to and including the
  3001. specified line.
  3002. .IP " 2." 4
  3003. Any text copied to a buffer shall be in line mode.
  3004. .P
  3005. If not used as a motion command:
  3006. .P
  3007. .IR "Current line" :
  3008. Set to
  3009. .IR count
  3010. if
  3011. .IR count
  3012. is specified; otherwise, the last line.
  3013. .P
  3014. .IR "Current column" :
  3015. Set to non-\c
  3016. <blank>.
  3017. .SS "Move to Top of Screen"
  3018. .IP "\fISynopsis\fR:" 10
  3019. .sp -1v
  3020. .RS 10
  3021. .sp
  3022. .RS 4
  3023. .nf
  3024. \fB[\fIcount\fB]\fR H
  3025. .fi
  3026. .P
  3027. .RE
  3028. .RE
  3029. .P
  3030. If the beginning of the line
  3031. .IR count
  3032. greater than the first line of which any portion appears on the display
  3033. does not exist, it shall be an error.
  3034. .P
  3035. If used as a motion command:
  3036. .IP " 1." 4
  3037. If in open mode, the text region shall be the current line.
  3038. .IP " 2." 4
  3039. Otherwise, the text region shall be from the starting line up to and
  3040. including (the first line of the display +
  3041. .IR count
  3042. \-1).
  3043. .IP " 3." 4
  3044. Any text copied to a buffer shall be in line mode.
  3045. .P
  3046. If not used as a motion command:
  3047. .P
  3048. If in open mode, this command shall set the current column to non-\c
  3049. <blank>
  3050. and do nothing else.
  3051. .P
  3052. Otherwise, it shall set the current line and current column as
  3053. follows.
  3054. .P
  3055. .IR "Current line" :
  3056. Set to (the first line of the display +
  3057. .IR count
  3058. \-1).
  3059. .P
  3060. .IR "Current column" :
  3061. Set to non-\c
  3062. <blank>.
  3063. .SS "Insert Before Cursor"
  3064. .IP "\fISynopsis\fR:" 10
  3065. .sp -1v
  3066. .RS 10
  3067. .sp
  3068. .RS 4
  3069. .nf
  3070. \fB[\fIcount\fB]\fR i
  3071. .fi
  3072. .P
  3073. .RE
  3074. .RE
  3075. .P
  3076. Enter text input mode before the current cursor position. No characters
  3077. already in the edit buffer shall be affected by this command. A
  3078. .IR count
  3079. shall cause the input text to be appended
  3080. .IR count
  3081. \-1 more times to the end of the input.
  3082. .P
  3083. .IR "Current line/column" :
  3084. As specified for the text input commands (see
  3085. .IR "Input Mode Commands in vi").
  3086. .SS "Insert at Beginning of Line"
  3087. .IP "\fISynopsis\fR:" 10
  3088. .sp -1v
  3089. .RS 10
  3090. .sp
  3091. .RS 4
  3092. .nf
  3093. \fB[\fIcount\fB]\fR I
  3094. .fi
  3095. .P
  3096. .RE
  3097. .RE
  3098. .P
  3099. This command shall be equivalent to the
  3100. .IR vi
  3101. command ^[\c
  3102. .IR count ]\c
  3103. .BR i .
  3104. .SS "Join"
  3105. .IP "\fISynopsis\fR:" 10
  3106. .sp -1v
  3107. .RS 10
  3108. .sp
  3109. .RS 4
  3110. .nf
  3111. \fB[\fIcount\fB]\fR J
  3112. .fi
  3113. .P
  3114. .RE
  3115. .RE
  3116. .P
  3117. If the current line is the last line in the edit buffer, it shall be an
  3118. error.
  3119. .P
  3120. This command shall be equivalent to the
  3121. .IR ex
  3122. .BR join
  3123. command with no addresses, and an
  3124. .IR ex
  3125. command
  3126. .IR count
  3127. value of 1 if
  3128. .IR count
  3129. was not specified or if a
  3130. .IR count
  3131. of 1 was specified, and an
  3132. .IR ex
  3133. command
  3134. .IR count
  3135. value of
  3136. .IR count
  3137. \-1 for any other value of
  3138. .IR count ,
  3139. except that the current line and column shall be set as follows.
  3140. .P
  3141. .IR "Current line" :
  3142. Unchanged.
  3143. .P
  3144. .IR "Current column" :
  3145. The last column in which any portion of the character following the
  3146. last character in the initial line is displayed, or the last non-\c
  3147. <newline>
  3148. in the line if no characters were appended.
  3149. .SS "Move to Bottom of Screen"
  3150. .IP "\fISynopsis\fR:" 10
  3151. .sp -1v
  3152. .RS 10
  3153. .sp
  3154. .RS 4
  3155. .nf
  3156. \fB[\fIcount\fB]\fR L
  3157. .fi
  3158. .P
  3159. .RE
  3160. .RE
  3161. .P
  3162. If the beginning of the line
  3163. .IR count
  3164. less than the last line of which any portion appears on the display
  3165. does not exist, it shall be an error.
  3166. .P
  3167. If used as a motion command:
  3168. .IP " 1." 4
  3169. If in open mode, the text region shall be the current line.
  3170. .IP " 2." 4
  3171. Otherwise, the text region shall include all lines from the starting
  3172. cursor line to (the last line of the display \-(\c
  3173. .IR count
  3174. \-1)).
  3175. .IP " 3." 4
  3176. Any text copied to a buffer shall be in line mode.
  3177. .P
  3178. If not used as a motion command:
  3179. .IP " 1." 4
  3180. If in open mode, this command shall set the current column to non-\c
  3181. <blank>
  3182. and do nothing else.
  3183. .IP " 2." 4
  3184. Otherwise, it shall set the current line and current column as follows.
  3185. .P
  3186. .IR "Current line" :
  3187. Set to (the last line of the display \-(\c
  3188. .IR count
  3189. \-1)).
  3190. .P
  3191. .IR "Current column" :
  3192. Set to non-\c
  3193. <blank>.
  3194. .SS "Mark Position"
  3195. .IP "\fISynopsis\fR:" 10
  3196. .sp -1v
  3197. .RS 10
  3198. .sp
  3199. .RS 4
  3200. .nf
  3201. m \fIletter\fR
  3202. .fi
  3203. .P
  3204. .RE
  3205. .RE
  3206. .P
  3207. This command shall be equivalent to the
  3208. .IR ex
  3209. .BR mark
  3210. command with the specified character as an argument.
  3211. .SS "Move to Middle of Screen"
  3212. .IP "\fISynopsis\fR:" 10
  3213. .sp -1v
  3214. .RS 10
  3215. .sp
  3216. .RS 4
  3217. .nf
  3218. M
  3219. .fi
  3220. .P
  3221. .RE
  3222. .RE
  3223. .P
  3224. The middle line of the display shall be calculated as follows:
  3225. .sp
  3226. .RS 4
  3227. .nf
  3228. (the top line of the display) + (((number of lines displayed) +1) /2) -1
  3229. .fi
  3230. .P
  3231. .RE
  3232. .P
  3233. If used as a motion command:
  3234. .IP " 1." 4
  3235. If in open mode, the text region shall be the current line.
  3236. .IP " 2." 4
  3237. Otherwise, the text region shall include all lines from the starting
  3238. cursor line up to and including the middle line of the display.
  3239. .IP " 3." 4
  3240. Any text copied to a buffer shall be in line mode.
  3241. .P
  3242. If not used as a motion command:
  3243. .P
  3244. If in open mode, this command shall set the current column to non-\c
  3245. <blank>
  3246. and do nothing else.
  3247. .P
  3248. Otherwise, it shall set the current line and current column as
  3249. follows.
  3250. .P
  3251. .IR "Current line" :
  3252. Set to the middle line of the display.
  3253. .P
  3254. .IR "Current column" :
  3255. Set to non-\c
  3256. <blank>.
  3257. .SS "Repeat Regular Expression Find (Forward)"
  3258. .IP "\fISynopsis\fR:" 10
  3259. .sp -1v
  3260. .RS 10
  3261. .sp
  3262. .RS 4
  3263. .nf
  3264. n
  3265. .fi
  3266. .P
  3267. .RE
  3268. .RE
  3269. .P
  3270. If the remembered search direction was forward, the
  3271. .BR n
  3272. command shall be equivalent to the
  3273. .IR vi
  3274. .BR /
  3275. command with no characters entered by the user. Otherwise, it shall be
  3276. equivalent to the
  3277. .IR vi
  3278. .BR ?
  3279. command with no characters entered by the user.
  3280. .P
  3281. If the
  3282. .BR n
  3283. command is used as a motion command for the
  3284. .BR !
  3285. command, the editor shall not enter text input mode on the last line on
  3286. the screen, and shall behave as if the user entered a single
  3287. .BR '!'
  3288. character as the text input.
  3289. .SS "Repeat Regular Expression Find (Reverse)"
  3290. .IP "\fISynopsis\fR:" 10
  3291. .sp -1v
  3292. .RS 10
  3293. .sp
  3294. .RS 4
  3295. .nf
  3296. N
  3297. .fi
  3298. .P
  3299. .RE
  3300. .RE
  3301. .P
  3302. Scan for the next match of the last pattern given to
  3303. .BR /
  3304. or
  3305. .BR ? ,
  3306. but in the reverse direction; this is the reverse of
  3307. .BR n .
  3308. .P
  3309. If the remembered search direction was forward, the
  3310. .BR N
  3311. command shall be equivalent to the
  3312. .IR vi
  3313. .BR ?
  3314. command with no characters entered by the user. Otherwise, it shall be
  3315. equivalent to the
  3316. .IR vi
  3317. .BR /
  3318. command with no characters entered by the user. If the
  3319. .BR N
  3320. command is used as a motion command for the
  3321. .BR !
  3322. command, the editor shall not enter text input mode on the last line on
  3323. the screen, and shall behave as if the user entered a single
  3324. .BR !
  3325. character as the text input.
  3326. .SS "Insert Empty Line Below"
  3327. .IP "\fISynopsis\fR:" 10
  3328. .sp -1v
  3329. .RS 10
  3330. .sp
  3331. .RS 4
  3332. .nf
  3333. o
  3334. .fi
  3335. .P
  3336. .RE
  3337. .RE
  3338. .P
  3339. Enter text input mode in a new line appended after the current line. A
  3340. .IR count
  3341. shall cause the input text to be appended
  3342. .IR count
  3343. \-1 more times to the end of the already added text, each time
  3344. starting on a new, appended line.
  3345. .P
  3346. .IR "Current line/column" :
  3347. As specified for the text input commands (see
  3348. .IR "Input Mode Commands in vi").
  3349. .SS "Insert Empty Line Above"
  3350. .IP "\fISynopsis\fR:" 10
  3351. .sp -1v
  3352. .RS 10
  3353. .sp
  3354. .RS 4
  3355. .nf
  3356. O
  3357. .fi
  3358. .P
  3359. .RE
  3360. .RE
  3361. .P
  3362. Enter text input mode in a new line inserted before the current line. A
  3363. .IR count
  3364. shall cause the input text to be appended
  3365. .IR count
  3366. \-1 more times to the end of the already added text, each time
  3367. starting on a new, appended line.
  3368. .P
  3369. .IR "Current line/column" :
  3370. As specified for the text input commands (see
  3371. .IR "Input Mode Commands in vi").
  3372. .SS "Put from Buffer Following"
  3373. .IP "\fISynopsis\fR:" 10
  3374. .sp -1v
  3375. .RS 10
  3376. .sp
  3377. .RS 4
  3378. .nf
  3379. \fB[\fIbuffer\fB]\fR p
  3380. .fi
  3381. .P
  3382. .RE
  3383. .RE
  3384. .P
  3385. If no
  3386. .IR buffer
  3387. is specified, the unnamed buffer shall be used.
  3388. .P
  3389. If the buffer text is in line mode, the text shall be appended below
  3390. the current line, and each line of the buffer shall become a new line
  3391. in the edit buffer. A
  3392. .IR count
  3393. shall cause the buffer text to be appended
  3394. .IR count
  3395. \-1 more times to the end of the already added text, each time
  3396. starting on a new, appended line.
  3397. .P
  3398. If the buffer text is in character mode, the text shall be appended
  3399. into the current line after the cursor, and each line of the buffer
  3400. other than the first and last shall become a new line in the edit
  3401. buffer. A
  3402. .IR count
  3403. shall cause the buffer text to be appended
  3404. .IR count
  3405. \-1 more times to the end of the already added text, each time
  3406. starting after the last added character.
  3407. .P
  3408. .IR "Current line" :
  3409. If the buffer text is in line mode, set the line to line +1; otherwise,
  3410. unchanged.
  3411. .P
  3412. .IR "Current column" :
  3413. If the buffer text is in line mode:
  3414. .IP " 1." 4
  3415. If there is a non-\c
  3416. <blank>
  3417. in the first line of the buffer, set to the last column on which any
  3418. portion of the first non-\c
  3419. <blank>
  3420. in the line is displayed.
  3421. .IP " 2." 4
  3422. If there is no non-\c
  3423. <blank>
  3424. in the first line of the buffer, set to the last column on which any
  3425. portion of the last non-\c
  3426. <newline>
  3427. in the first line of the buffer is displayed.
  3428. .P
  3429. If the buffer text is in character mode:
  3430. .IP " 1." 4
  3431. If the text in the buffer is from more than a single line, then set to
  3432. the last column on which any portion of the first character from the
  3433. buffer is displayed.
  3434. .IP " 2." 4
  3435. Otherwise, if the buffer is the unnamed buffer, set to the last column
  3436. on which any portion of the last character from the buffer is
  3437. displayed.
  3438. .IP " 3." 4
  3439. Otherwise, set to the first column on which any portion of the first
  3440. character from the buffer is displayed.
  3441. .SS "Put from Buffer Before"
  3442. .IP "\fISynopsis\fR:" 10
  3443. .sp -1v
  3444. .RS 10
  3445. .sp
  3446. .RS 4
  3447. .nf
  3448. \fB[\fIbuffer\fB]\fR P
  3449. .fi
  3450. .P
  3451. .RE
  3452. .RE
  3453. .P
  3454. If no
  3455. .IR buffer
  3456. is specified, the unnamed buffer shall be used.
  3457. .P
  3458. If the buffer text is in line mode, the text shall be inserted above
  3459. the current line, and each line of the buffer shall become a new line
  3460. in the edit buffer. A
  3461. .IR count
  3462. shall cause the buffer text to be appended
  3463. .IR count
  3464. \-1 more times to the end of the already added text, each time
  3465. starting on a new, appended line.
  3466. .P
  3467. If the buffer text is in character mode, the text shall be inserted
  3468. into the current line before the cursor, and each line of the buffer
  3469. other than the first and last shall become a new line in the edit
  3470. buffer. A
  3471. .IR count
  3472. shall cause the buffer text to be appended
  3473. .IR count
  3474. \-1 more times to the end of the already added text, each time
  3475. starting after the last added character.
  3476. .P
  3477. .IR "Current line" :
  3478. Unchanged.
  3479. .P
  3480. .IR "Current column" :
  3481. If the buffer text is in line mode:
  3482. .IP " 1." 4
  3483. If there is a non-\c
  3484. <blank>
  3485. in the first line of the buffer, set to the last column on which any
  3486. portion of that character is displayed.
  3487. .IP " 2." 4
  3488. If there is no non-\c
  3489. <blank>
  3490. in the first line of the buffer, set to the last column on which any
  3491. portion of the last non-\c
  3492. <newline>
  3493. in the first line of the buffer is displayed.
  3494. .P
  3495. If the buffer text is in character mode:
  3496. .IP " 1." 4
  3497. If the text in the buffer is from more than a single line, then set to
  3498. the last column on which any portion of the first character from the
  3499. buffer is displayed.
  3500. .IP " 2." 4
  3501. Otherwise, if the buffer is the unnamed buffer, set to the last column
  3502. on which any portion of the last character from the buffer is displayed.
  3503. .IP " 3." 4
  3504. Otherwise, set to the first column on which any portion of the first
  3505. character from the buffer is displayed.
  3506. .SS "Enter ex Mode"
  3507. .IP "\fISynopsis\fR:" 10
  3508. .sp -1v
  3509. .RS 10
  3510. .sp
  3511. .RS 4
  3512. .nf
  3513. Q
  3514. .fi
  3515. .P
  3516. .RE
  3517. .RE
  3518. .P
  3519. Leave visual or open mode and enter
  3520. .IR ex
  3521. command mode.
  3522. .P
  3523. .IR "Current line" :
  3524. Unchanged.
  3525. .P
  3526. .IR "Current column" :
  3527. Unchanged.
  3528. .SS "Replace Character"
  3529. .IP "\fISynopsis\fR:" 10
  3530. .sp -1v
  3531. .RS 10
  3532. .sp
  3533. .RS 4
  3534. .nf
  3535. \fB[\fIcount\fB]\fR r \fIcharacter\fR
  3536. .fi
  3537. .P
  3538. .RE
  3539. .RE
  3540. .P
  3541. Replace the
  3542. .IR count
  3543. characters at and after the cursor with the specified character. If
  3544. there are less than
  3545. .IR count
  3546. non-\c
  3547. <newline>
  3548. characters at and after the cursor on the line, it shall be an error.
  3549. .P
  3550. If character is
  3551. <control>\(hyV,
  3552. any next character other than the
  3553. <newline>
  3554. shall be stripped of any special meaning and used as a literal
  3555. character.
  3556. .P
  3557. If character is
  3558. <ESC>,
  3559. no replacement shall be made and the current line and current column
  3560. shall be unchanged.
  3561. .P
  3562. If character is
  3563. <carriage-return>
  3564. or
  3565. <newline>,
  3566. .IR count
  3567. new lines shall be appended to the current line. All but the last of
  3568. these lines shall be empty.
  3569. .IR count
  3570. characters at and after the cursor shall be discarded, and any
  3571. remaining characters after the cursor in the current line shall be
  3572. moved to the last of the new lines. If the
  3573. .BR autoindent
  3574. edit option is set, they shall be preceded by the same number of
  3575. .BR autoindent
  3576. characters found on the line from which the command was executed.
  3577. .P
  3578. .IR "Current line" :
  3579. Unchanged unless the replacement character is a
  3580. <carriage-return>
  3581. or
  3582. <newline>,
  3583. in which case it shall be set to line +
  3584. .IR count .
  3585. .P
  3586. .IR "Current column" :
  3587. Set to the last column position on which a portion of the last replaced
  3588. character is displayed, or if the replacement character caused new
  3589. lines to be created, set to non-\c
  3590. <blank>.
  3591. .SS "Replace Characters"
  3592. .IP "\fISynopsis\fR:" 10
  3593. .sp -1v
  3594. .RS 10
  3595. .sp
  3596. .RS 4
  3597. .nf
  3598. R
  3599. .fi
  3600. .P
  3601. .RE
  3602. .RE
  3603. .P
  3604. Enter text input mode at the current cursor position possibly
  3605. replacing text on the current line. A
  3606. .IR count
  3607. shall cause the input text to be appended
  3608. .IR count
  3609. \-1 more times to the end of the input.
  3610. .P
  3611. .IR "Current line/column" :
  3612. As specified for the text input commands (see
  3613. .IR "Input Mode Commands in vi").
  3614. .SS "Substitute Character"
  3615. .IP "\fISynopsis\fR:" 10
  3616. .sp -1v
  3617. .RS 10
  3618. .sp
  3619. .RS 4
  3620. .nf
  3621. \fB[\fIbuffer\fB][\fIcount\fB]\fR s
  3622. .fi
  3623. .P
  3624. .RE
  3625. .RE
  3626. .P
  3627. This command shall be equivalent to the
  3628. .IR vi
  3629. command:
  3630. .sp
  3631. .RS 4
  3632. .nf
  3633. \fB[\fIbuffer\fB][\fIcount\fB]\fR c<space>
  3634. .fi
  3635. .P
  3636. .RE
  3637. .SS "Substitute Lines"
  3638. .IP "\fISynopsis\fR:" 10
  3639. .sp -1v
  3640. .RS 10
  3641. .sp
  3642. .RS 4
  3643. .nf
  3644. \fB[\fIbuffer\fB][\fIcount\fB]\fR S
  3645. .fi
  3646. .P
  3647. .RE
  3648. .RE
  3649. .P
  3650. This command shall be equivalent to the
  3651. .IR vi
  3652. command:
  3653. .sp
  3654. .RS 4
  3655. .nf
  3656. \fB[\fIbuffer\fB][\fIcount\fB]\fR c_
  3657. .fi
  3658. .P
  3659. .RE
  3660. .SS "Move Cursor to Before Character (Forward)"
  3661. .IP "\fISynopsis\fR:" 10
  3662. .sp -1v
  3663. .RS 10
  3664. .sp
  3665. .RS 4
  3666. .nf
  3667. \fB[\fIcount\fB]\fR t \fIcharacter\fR
  3668. .fi
  3669. .P
  3670. .RE
  3671. .RE
  3672. .P
  3673. It shall be an error if
  3674. .IR count
  3675. occurrences of the character do not occur after the cursor in the
  3676. line.
  3677. .P
  3678. If used as a motion command:
  3679. .IP " 1." 4
  3680. The text region shall be from the cursor up to but not including the
  3681. .IR count th
  3682. occurrence of the specified character after the cursor.
  3683. .IP " 2." 4
  3684. Any text copied to a buffer shall be in character mode.
  3685. .P
  3686. If not used as a motion command:
  3687. .P
  3688. .IR "Current line" :
  3689. Unchanged.
  3690. .P
  3691. .IR "Current column" :
  3692. Set to the last column in which any portion of the character before the
  3693. .IR count th
  3694. occurrence of the specified character after the cursor appears in the
  3695. line.
  3696. .SS "Move Cursor to After Character (Reverse)"
  3697. .IP "\fISynopsis\fR:" 10
  3698. .sp -1v
  3699. .RS 10
  3700. .sp
  3701. .RS 4
  3702. .nf
  3703. \fB[\fIcount\fB]\fR T \fIcharacter\fR
  3704. .fi
  3705. .P
  3706. .RE
  3707. .RE
  3708. .P
  3709. It shall be an error if
  3710. .IR count
  3711. occurrences of the character do not occur before the cursor in the
  3712. line.
  3713. .P
  3714. If used as a motion command:
  3715. .IP " 1." 4
  3716. If the character before the cursor is the specified character, it shall
  3717. be an error.
  3718. .IP " 2." 4
  3719. The text region shall be from the character before the cursor up to but
  3720. not including the
  3721. .IR count th
  3722. occurrence of the specified character before the cursor.
  3723. .IP " 3." 4
  3724. Any text copied to a buffer shall be in character mode.
  3725. .P
  3726. If not used as a motion command:
  3727. .P
  3728. .IR "Current line" :
  3729. Unchanged.
  3730. .P
  3731. .IR "Current column" :
  3732. Set to the last column in which any portion of the character after the
  3733. .IR count th
  3734. occurrence of the specified character before the cursor appears in the
  3735. line.
  3736. .SS "Undo"
  3737. .IP "\fISynopsis\fR:" 10
  3738. .sp -1v
  3739. .RS 10
  3740. .sp
  3741. .RS 4
  3742. .nf
  3743. u
  3744. .fi
  3745. .P
  3746. .RE
  3747. .RE
  3748. .P
  3749. This command shall be equivalent to the
  3750. .IR ex
  3751. .BR undo
  3752. command except that the current line and current column shall be set as
  3753. follows:
  3754. .P
  3755. .IR "Current line" :
  3756. Set to the first line added or changed if any; otherwise, move to the
  3757. line preceding any deleted text if one exists; otherwise, move to line 1.
  3758. .P
  3759. .IR "Current column" :
  3760. If undoing an
  3761. .IR ex
  3762. command, set to the first non-\c
  3763. <blank>.
  3764. .P
  3765. Otherwise, if undoing a text input command:
  3766. .IP " 1." 4
  3767. If the command was a
  3768. .BR C ,
  3769. .BR c ,
  3770. .BR O ,
  3771. .BR o ,
  3772. .BR R ,
  3773. .BR S ,
  3774. or
  3775. .BR s
  3776. command, the current column shall be set to the value it held when the
  3777. text input command was entered.
  3778. .IP " 2." 4
  3779. Otherwise, set to the last column in which any portion of the first
  3780. character after the deleted text is displayed, or, if no non-\c
  3781. <newline>
  3782. characters follow the text deleted from this line, set to the last column
  3783. in which any portion of the last non-\c
  3784. <newline>
  3785. in the line is displayed, or 1 if the line is empty.
  3786. .P
  3787. Otherwise, if a single line was modified (that is, not added or
  3788. deleted) by the
  3789. .BR u
  3790. command:
  3791. .IP " 1." 4
  3792. If text was added or changed, set to the last column in which any
  3793. portion of the first character added or changed is displayed.
  3794. .IP " 2." 4
  3795. If text was deleted, set to the last column in which any portion of the
  3796. first character after the deleted text is displayed, or, if no non-\c
  3797. <newline>
  3798. characters follow the deleted text, set to the last column in which any
  3799. portion of the last non-\c
  3800. <newline>
  3801. in the line is displayed, or 1 if the line is empty.
  3802. .P
  3803. Otherwise, set to non-\c
  3804. <blank>.
  3805. .SS "Undo Current Line"
  3806. .IP "\fISynopsis\fR:" 10
  3807. .sp -1v
  3808. .RS 10
  3809. .sp
  3810. .RS 4
  3811. .nf
  3812. U
  3813. .fi
  3814. .P
  3815. .RE
  3816. .RE
  3817. .P
  3818. Restore the current line to its state immediately before the most
  3819. recent time that it became the current line.
  3820. .P
  3821. .IR "Current line" :
  3822. Unchanged.
  3823. .P
  3824. .IR "Current column" :
  3825. Set to the first column in the line in which any portion of the first
  3826. character in the line is displayed.
  3827. .SS "Move to Beginning of Word"
  3828. .IP "\fISynopsis\fR:" 10
  3829. .sp -1v
  3830. .RS 10
  3831. .sp
  3832. .RS 4
  3833. .nf
  3834. \fB[\fIcount\fB]\fR w
  3835. .fi
  3836. .P
  3837. .RE
  3838. .RE
  3839. .P
  3840. With the exception that words are used as the delimiter instead of
  3841. bigwords, this command shall be equivalent to the
  3842. .BR W
  3843. command.
  3844. .SS "Move to Beginning of Bigword"
  3845. .IP "\fISynopsis\fR:" 10
  3846. .sp -1v
  3847. .RS 10
  3848. .sp
  3849. .RS 4
  3850. .nf
  3851. \fB[\fIcount\fB]\fR W
  3852. .fi
  3853. .P
  3854. .RE
  3855. .RE
  3856. .P
  3857. If the edit buffer is empty, it shall be an error. If there are less
  3858. than
  3859. .IR count
  3860. bigwords between the cursor and the end of the edit buffer,
  3861. .IR count
  3862. shall be adjusted to move the cursor to the last bigword in the edit
  3863. buffer.
  3864. .P
  3865. If used as a motion command:
  3866. .IP " 1." 4
  3867. If the associated command is
  3868. .BR c ,
  3869. .IR count
  3870. is 1, and the cursor is on a
  3871. <blank>,
  3872. the region of text shall be the current character and no further action
  3873. shall be taken.
  3874. .IP " 2." 4
  3875. If there are less than
  3876. .IR count
  3877. bigwords between the cursor and the end of the edit buffer, then the
  3878. command shall succeed, and the region of text shall include the last
  3879. character of the edit buffer.
  3880. .IP " 3." 4
  3881. If there are
  3882. <blank>
  3883. characters or an end-of-line that precede the
  3884. .IR count th
  3885. bigword, and the associated command is
  3886. .BR c ,
  3887. the region of text shall be up to and including the last character
  3888. before the preceding
  3889. <blank>
  3890. characters or end-of-line.
  3891. .IP " 4." 4
  3892. If there are
  3893. <blank>
  3894. characters or an end-of-line that precede the bigword, and the associated
  3895. command is
  3896. .BR d
  3897. or
  3898. .BR y ,
  3899. the region of text shall be up to and including the last
  3900. <blank>
  3901. before the start of the bigword or end-of-line.
  3902. .IP " 5." 4
  3903. Any text copied to a buffer shall be in character mode.
  3904. .P
  3905. If not used as a motion command:
  3906. .IP " 1." 4
  3907. If the cursor is on the last character of the edit buffer, it shall be
  3908. an error.
  3909. .P
  3910. .IR "Current line" :
  3911. Set to the line containing the current column.
  3912. .P
  3913. .IR "Current column" :
  3914. Set to the last column in which any part of the first character of the
  3915. .IR count th
  3916. next bigword is displayed.
  3917. .SS "Delete Character at Cursor"
  3918. .IP "\fISynopsis\fR:" 10
  3919. .sp -1v
  3920. .RS 10
  3921. .sp
  3922. .RS 4
  3923. .nf
  3924. \fB[\fIbuffer\fB][\fIcount\fB]\fR x
  3925. .fi
  3926. .P
  3927. .RE
  3928. .RE
  3929. .P
  3930. Delete the
  3931. .IR count
  3932. characters at and after the current character into
  3933. .IR buffer ,
  3934. if specified, and into the unnamed buffer.
  3935. .P
  3936. If the line is empty, it shall be an error. If there are less than
  3937. .IR count
  3938. non-\c
  3939. <newline>
  3940. characters at and after the cursor on the current line,
  3941. .IR count
  3942. shall be adjusted to the number of non-\c
  3943. <newline>
  3944. characters at and after the cursor.
  3945. .P
  3946. .IR "Current line" :
  3947. Unchanged.
  3948. .P
  3949. .IR "Current column" :
  3950. If the line is empty, set to column position 1. Otherwise, if there
  3951. were
  3952. .IR count
  3953. or less non-\c
  3954. <newline>
  3955. characters at and after the cursor on the current line, set to the last
  3956. column that displays any part of the last non-\c
  3957. <newline>
  3958. of the line. Otherwise, unchanged.
  3959. .SS "Delete Character Before Cursor"
  3960. .IP "\fISynopsis\fR:" 10
  3961. .sp -1v
  3962. .RS 10
  3963. .sp
  3964. .RS 4
  3965. .nf
  3966. \fB[\fIbuffer\fB][\fIcount\fB]\fR X
  3967. .fi
  3968. .P
  3969. .RE
  3970. .RE
  3971. .P
  3972. Delete the
  3973. .IR count
  3974. characters before the current character into
  3975. .IR buffer ,
  3976. if specified, and into the unnamed buffer.
  3977. .P
  3978. If there are no characters before the current character on the current
  3979. line, it shall be an error. If there are less than
  3980. .IR count
  3981. previous characters on the current line,
  3982. .IR count
  3983. shall be adjusted to the number of previous characters on the line.
  3984. .P
  3985. .IR "Current line" :
  3986. Unchanged.
  3987. .P
  3988. .IR "Current column" :
  3989. Set to (current column \- the width of the deleted characters).
  3990. .SS "Yank"
  3991. .IP "\fISynopsis\fR:" 10
  3992. .sp -1v
  3993. .RS 10
  3994. .sp
  3995. .RS 4
  3996. .nf
  3997. \fB[\fIbuffer\fB][\fIcount\fB]\fR y \fImotion\fR
  3998. .fi
  3999. .P
  4000. .RE
  4001. .RE
  4002. .P
  4003. Copy (yank) the region of text into
  4004. .IR buffer ,
  4005. if specified, and into the unnamed buffer.
  4006. .P
  4007. If the motion command is the
  4008. .BR y
  4009. command repeated:
  4010. .IP " 1." 4
  4011. The buffer shall be in line mode.
  4012. .IP " 2." 4
  4013. If there are less than
  4014. .IR count
  4015. \-1 lines after the current line in the edit buffer, it shall be an
  4016. error.
  4017. .IP " 3." 4
  4018. The text region shall be from the current line up to and including the
  4019. next
  4020. .IR count
  4021. \-1 lines.
  4022. .P
  4023. Otherwise, the buffer text mode and text region shall be as specified
  4024. by the motion command.
  4025. .P
  4026. .IR "Current line" :
  4027. If the motion was from the current cursor position toward the end of
  4028. the edit buffer, unchanged. Otherwise, set to the first line in the
  4029. edit buffer that is part of the text region specified by the
  4030. motion command.
  4031. .P
  4032. .IR "Current column" :
  4033. .IP " 1." 4
  4034. If the motion was from the current cursor position toward the end of
  4035. the edit buffer, unchanged.
  4036. .IP " 2." 4
  4037. Otherwise, if the current line is empty, set to column position 1.
  4038. .IP " 3." 4
  4039. Otherwise, set to the last column that displays any part of the first
  4040. character in the file that is part of the text region specified by the
  4041. motion command.
  4042. .SS "Yank Current Line"
  4043. .IP "\fISynopsis\fR:" 10
  4044. .sp -1v
  4045. .RS 10
  4046. .sp
  4047. .RS 4
  4048. .nf
  4049. \fB[\fIbuffer\fB][\fIcount\fB]\fR Y
  4050. .fi
  4051. .P
  4052. .RE
  4053. .RE
  4054. .P
  4055. This command shall be equivalent to the
  4056. .IR vi
  4057. command:
  4058. .sp
  4059. .RS 4
  4060. .nf
  4061. \fB[\fIbuffer\fB][\fIcount\fB]\fR y_
  4062. .fi
  4063. .P
  4064. .RE
  4065. .SS "Redraw Window"
  4066. .P
  4067. If in open mode, the
  4068. .BR z
  4069. command shall have the Synopsis:
  4070. .IP "\fISynopsis\fR:" 10
  4071. .sp -1v
  4072. .RS 10
  4073. .sp
  4074. .RS 4
  4075. .nf
  4076. \fB[\fIcount\fB]\fR z
  4077. .fi
  4078. .P
  4079. .RE
  4080. .RE
  4081. .P
  4082. If
  4083. .IR count
  4084. is not specified, it shall default to the
  4085. .BR window
  4086. edit option \-1. The
  4087. .BR z
  4088. command shall be equivalent to the
  4089. .IR ex
  4090. .BR z
  4091. command, with a type character of
  4092. .BR =
  4093. and a
  4094. .IR count
  4095. of
  4096. .IR count
  4097. \-2, except that the current line and current column shall be set as
  4098. follows, and the
  4099. .BR window
  4100. edit option shall not be affected. If the calculation for the
  4101. .IR count
  4102. argument would result in a negative number, the
  4103. .IR count
  4104. argument to the
  4105. .IR ex
  4106. .BR z
  4107. command shall be zero. A blank line shall be written after the last
  4108. line is written.
  4109. .P
  4110. .IR "Current line" :
  4111. Unchanged.
  4112. .P
  4113. .IR "Current column" :
  4114. Unchanged.
  4115. .P
  4116. If not in open mode, the
  4117. .BR z
  4118. command shall have the following Synopsis:
  4119. .IP "\fISynopsis\fR:" 10
  4120. .sp -1v
  4121. .RS 10
  4122. .sp
  4123. .RS 4
  4124. .nf
  4125. \fB[\fIline\fB]\fR z \fB[\fIcount\fB] \fIcharacter\fR
  4126. .fi
  4127. .P
  4128. .RE
  4129. .RE
  4130. .P
  4131. If
  4132. .IR line
  4133. is not specified, it shall default to the current line. If
  4134. .IR line
  4135. is specified, but is greater than the number of lines in the edit
  4136. buffer, it shall default to the number of lines in the edit buffer.
  4137. .P
  4138. If
  4139. .IR count
  4140. is specified, the value of the
  4141. .BR window
  4142. edit option shall be set to
  4143. .IR count
  4144. (as described in the
  4145. .IR ex
  4146. .BR window
  4147. command), and the screen shall be redrawn.
  4148. .P
  4149. .IR line
  4150. shall be placed as specified by the following characters:
  4151. .IP "<newline>,\ <carriage-return>" 6
  4152. .br
  4153. Place the beginning of the line on the first line of the display.
  4154. .IP "\fR.\fP" 6
  4155. Place the beginning of the line in the center of the display. The
  4156. middle line of the display shall be calculated as described for the
  4157. .BR M
  4158. command.
  4159. .IP "\fR\-\fP" 6
  4160. Place an unspecified portion of the line on the last line of the
  4161. display.
  4162. .IP "\fR+\fP" 6
  4163. If
  4164. .IR line
  4165. was specified, equivalent to the
  4166. <newline>
  4167. case. If
  4168. .IR line
  4169. was not specified, display a screen where the first line of the display
  4170. shall be (current last line) +1. If there are no lines after the last
  4171. line in the display, it shall be an error.
  4172. .IP "\fR^\fP" 6
  4173. If
  4174. .IR line
  4175. was specified, display a screen where the last line of the display
  4176. shall contain an unspecified portion of the first line of a display
  4177. that had an unspecified portion of the specified line on the last line
  4178. of the display. If this calculation results in a line before the
  4179. beginning of the edit buffer, display the first screen of the edit
  4180. buffer.
  4181. .RS 6
  4182. .P
  4183. Otherwise, display a screen where the last line of the display shall
  4184. contain an unspecified portion of (current first line \-1). If this
  4185. calculation results in a line before the beginning of the edit buffer,
  4186. it shall be an error.
  4187. .RE
  4188. .br
  4189. .P
  4190. .IR "Current line" :
  4191. If
  4192. .IR line
  4193. and the
  4194. .BR '\(ha'
  4195. character were specified:
  4196. .IP " 1." 4
  4197. If the first screen was displayed as a result of the command attempting
  4198. to display lines before the beginning of the edit buffer: if the first
  4199. screen was already displayed, unchanged; otherwise, set to (current
  4200. first line \-1).
  4201. .IP " 2." 4
  4202. Otherwise, set to the last line of the display.
  4203. .P
  4204. If
  4205. .IR line
  4206. and the
  4207. .BR '\(pl'
  4208. character were specified, set to the first line of the display.
  4209. .P
  4210. Otherwise, if
  4211. .IR line
  4212. was specified, set to
  4213. .IR line .
  4214. .P
  4215. Otherwise, unchanged.
  4216. .P
  4217. .IR "Current column" :
  4218. Set to non-\c
  4219. <blank>.
  4220. .SS "Exit"
  4221. .IP "\fISynopsis\fR:" 10
  4222. .sp -1v
  4223. .RS 10
  4224. .sp
  4225. .RS 4
  4226. .nf
  4227. ZZ
  4228. .fi
  4229. .P
  4230. .RE
  4231. .RE
  4232. .P
  4233. This command shall be equivalent to the
  4234. .IR ex
  4235. .BR xit
  4236. command with no addresses, trailing
  4237. .BR ! ,
  4238. or filename (see the
  4239. .IR ex
  4240. .BR xit
  4241. command).
  4242. .SS "Input Mode Commands in vi"
  4243. .P
  4244. In text input mode, the current line shall consist of zero or more of
  4245. the following categories, plus the terminating
  4246. <newline>:
  4247. .IP " 1." 4
  4248. Characters preceding the text input entry point
  4249. .RS 4
  4250. .P
  4251. Characters in this category shall not be modified during text input
  4252. mode.
  4253. .RE
  4254. .IP " 2." 4
  4255. .BR autoindent
  4256. characters
  4257. .RS 4
  4258. .P
  4259. .BR autoindent
  4260. characters shall be automatically inserted into each line that is
  4261. created in text input mode, either as a result of entering a
  4262. <newline>
  4263. or
  4264. <carriage-return>
  4265. while in text input mode, or as an effect of the command itself; for
  4266. example,
  4267. .BR O
  4268. or
  4269. .BR o
  4270. (see the
  4271. .IR ex
  4272. .BR autoindent
  4273. command), as if entered by the user.
  4274. .P
  4275. It shall be possible to erase
  4276. .BR autoindent
  4277. characters with the
  4278. <control>\(hyD
  4279. command; it is unspecified whether they can be erased by
  4280. <control>\(hyH,
  4281. <control>\(hyU,
  4282. and
  4283. <control>\(hyW
  4284. characters. Erasing any
  4285. .BR autoindent
  4286. character turns the glyph into erase-columns and deletes the character
  4287. from the edit buffer, but does not change its representation on the
  4288. screen.
  4289. .RE
  4290. .IP " 3." 4
  4291. Text input characters
  4292. .RS 4
  4293. .P
  4294. Text input characters are the characters entered by the user. Erasing
  4295. any text input character turns the glyph into erase-columns and deletes
  4296. the character from the edit buffer, but does not change its
  4297. representation on the screen.
  4298. .P
  4299. Each text input character entered by the user (that does not have a
  4300. special meaning) shall be treated as follows:
  4301. .IP " a." 4
  4302. The text input character shall be appended to the last character in the
  4303. edit buffer from the first, second, or third categories.
  4304. .IP " b." 4
  4305. If there are no erase-columns on the screen, the text input command was
  4306. the
  4307. .BR R
  4308. command, and characters in the fifth category from the original line
  4309. follow the cursor, the next such character shall be deleted from the
  4310. edit buffer. If the
  4311. .BR slowopen
  4312. edit option is not set, the corresponding glyph on the screen shall
  4313. become erase-columns.
  4314. .IP " c." 4
  4315. If there are erase-columns on the screen, as many columns as they
  4316. occupy, or as are necessary, shall be overwritten to display the text
  4317. input character. (If only part of a multi-column glyph is overwritten,
  4318. the remainder shall be left on the screen, and continue to be treated
  4319. as erase-columns; it is unspecified whether the remainder of the glyph
  4320. is modified in any way.)
  4321. .IP " d." 4
  4322. If additional display line columns are needed to display the text input
  4323. character:
  4324. .RS 4
  4325. .IP " i." 5
  4326. If the
  4327. .BR slowopen
  4328. edit option is set, the text input characters shall be displayed on
  4329. subsequent display line columns, overwriting any characters displayed
  4330. in those columns.
  4331. .IP ii. 5
  4332. Otherwise, any characters currently displayed on or after the column on
  4333. the display line where the text input character is to be displayed
  4334. shall be pushed ahead the number of display line columns necessary to
  4335. display the rest of the text input character.
  4336. .RE
  4337. .RE
  4338. .IP " 4." 4
  4339. Erase-columns
  4340. .RS 4
  4341. .P
  4342. Erase-columns are not logically part of the edit buffer, appearing only
  4343. on the screen, and may be overwritten on the screen by subsequent text
  4344. input characters. When text input mode ends, all erase-columns shall no
  4345. longer appear on the screen.
  4346. .P
  4347. Erase-columns are initially the region of text specified by the
  4348. .BR c
  4349. command (see
  4350. .IR "Change");
  4351. however, erasing
  4352. .BR autoindent
  4353. or text input characters causes the glyphs of the erased characters to
  4354. be treated as erase-columns.
  4355. .RE
  4356. .IP " 5." 4
  4357. Characters following the text region for the
  4358. .BR c
  4359. command, or the text input entry point for all other commands
  4360. .RS 4
  4361. .P
  4362. Characters in this category shall not be modified during text input
  4363. mode, except as specified in category 3.b. for the
  4364. .BR R
  4365. text input command, or as
  4366. <blank>
  4367. characters deleted when a
  4368. <newline>
  4369. or
  4370. <carriage-return>
  4371. is entered.
  4372. .RE
  4373. .P
  4374. It is unspecified whether it is an error to attempt to erase past the
  4375. beginning of a line that was created by the entry of a
  4376. <newline>
  4377. or
  4378. <carriage-return>
  4379. during text input mode. If it is not an error, the editor shall behave
  4380. as if the erasing character was entered immediately after the last text
  4381. input character entered on the previous line, and all of the non-\c
  4382. <newline>
  4383. characters on the current line shall be treated as erase-columns.
  4384. .P
  4385. When text input mode is entered, or after a text input mode character
  4386. is entered (except as specified for the special characters below), the
  4387. cursor shall be positioned as follows:
  4388. .IP " 1." 4
  4389. On the first column that displays any part of the first erase-column,
  4390. if one exists
  4391. .IP " 2." 4
  4392. Otherwise, if the
  4393. .BR slowopen
  4394. edit option is set, on the first display line column after the last
  4395. character in the first, second, or third categories, if one exists
  4396. .IP " 3." 4
  4397. Otherwise, the first column that displays any part of the first
  4398. character in the fifth category, if one exists
  4399. .IP " 4." 4
  4400. Otherwise, the display line column after the last character in the
  4401. first, second, or third categories, if one exists
  4402. .IP " 5." 4
  4403. Otherwise, on column position 1
  4404. .P
  4405. The characters that are updated on the screen during text input mode
  4406. are unspecified, other than that the last text input character shall
  4407. always be updated, and, if the
  4408. .BR slowopen
  4409. edit option is not set, the current cursor character shall always be
  4410. updated.
  4411. .P
  4412. The following specifications are for command characters entered during
  4413. text input mode.
  4414. .SS "NUL"
  4415. .IP "\fISynopsis\fR:" 10
  4416. .sp -1v
  4417. .RS 10
  4418. .sp
  4419. .RS 4
  4420. .nf
  4421. NUL
  4422. .fi
  4423. .P
  4424. .RE
  4425. .RE
  4426. .P
  4427. If the first character of the text input is a NUL, the most recently
  4428. input text shall be input as if entered by the user, and then text
  4429. input mode shall be exited. The text shall be input literally; that is,
  4430. characters are neither macro or abbreviation expanded, nor are any
  4431. characters interpreted in any special manner. It is unspecified whether
  4432. implementations shall support more than 256 bytes of remembered input
  4433. text.
  4434. .SS "<control>-D"
  4435. .IP "\fISynopsis\fR:" 10
  4436. .sp -1v
  4437. .RS 10
  4438. .sp
  4439. .RS 4
  4440. .nf
  4441. <control>-D
  4442. .fi
  4443. .P
  4444. .RE
  4445. .RE
  4446. .P
  4447. The
  4448. <control>\(hyD
  4449. character shall have no special meaning when in text input
  4450. mode for a line-oriented command (see
  4451. .IR "Command Descriptions in vi").
  4452. .P
  4453. This command need not be supported on block-mode terminals.
  4454. .P
  4455. If the cursor does not follow an
  4456. .BR autoindent
  4457. character, or an
  4458. .BR autoindent
  4459. character and a
  4460. .BR '0'
  4461. or
  4462. .BR '\(ha'
  4463. character:
  4464. .IP " 1." 4
  4465. If the cursor is in column position 1, the
  4466. <control>\(hyD
  4467. character shall be discarded and no further action taken.
  4468. .IP " 2." 4
  4469. Otherwise, the
  4470. <control>\(hyD
  4471. character shall have no special meaning.
  4472. .P
  4473. If the last input character was a
  4474. .BR '0' ,
  4475. the cursor shall be moved to column position 1.
  4476. .P
  4477. Otherwise, if the last input character was a
  4478. .BR '\(ha' ,
  4479. the cursor shall be moved to column position 1. In addition, the
  4480. .BR autoindent
  4481. level for the next input line shall be derived from the same line from
  4482. which the
  4483. .BR autoindent
  4484. level for the current input line was derived.
  4485. .P
  4486. Otherwise, the cursor shall be moved back to the column after the
  4487. previous shiftwidth (see the
  4488. .IR ex
  4489. .BR shiftwidth
  4490. command) boundary.
  4491. .P
  4492. All of the glyphs on columns between the starting cursor position and
  4493. (inclusively) the ending cursor position shall become erase-columns as
  4494. described in
  4495. .IR "Input Mode Commands in vi".
  4496. .P
  4497. .IR "Current line" :
  4498. Unchanged.
  4499. .P
  4500. .IR "Current column" :
  4501. Set to 1 if the
  4502. <control>\(hyD
  4503. was preceded by a
  4504. .BR '\(ha'
  4505. or
  4506. .BR '0' ;
  4507. otherwise, set to (column \-1) \-((column \-2) %
  4508. .BR shiftwidth ).
  4509. .SS "<control>-H"
  4510. .IP "\fISynopsis\fR:" 10
  4511. .sp -1v
  4512. .RS 10
  4513. .sp
  4514. .RS 4
  4515. .nf
  4516. <control>-H
  4517. .fi
  4518. .P
  4519. .RE
  4520. .RE
  4521. .P
  4522. If in text input mode for a line-oriented command, and there are no
  4523. characters to erase, text input mode shall be terminated, no further
  4524. action shall be done for this command, and the current line and column
  4525. shall be unchanged.
  4526. .P
  4527. If there are characters other than
  4528. .BR autoindent
  4529. characters that have been input on the current line before the cursor,
  4530. the cursor shall move back one character.
  4531. .P
  4532. Otherwise, if there are
  4533. .BR autoindent
  4534. characters on the current line before the cursor, it is
  4535. implementation-defined whether the
  4536. <control>\(hyH
  4537. command is an error or if the cursor moves back one
  4538. .BR autoindent
  4539. character.
  4540. .P
  4541. Otherwise, if the cursor is in column position 1 and there are previous
  4542. lines that have been input, it is implementation-defined whether the
  4543. <control>\(hyH
  4544. command is an error or if it is equivalent to entering
  4545. <control>\(hyH
  4546. after the last input character on the previous input line.
  4547. .P
  4548. Otherwise, it shall be an error.
  4549. .P
  4550. All of the glyphs on columns between the starting cursor position and
  4551. (inclusively) the ending cursor position shall become erase-columns as
  4552. described in
  4553. .IR "Input Mode Commands in vi".
  4554. .P
  4555. The current erase character (see
  4556. .IR stty )
  4557. shall cause an equivalent action to the
  4558. <control>\(hyH
  4559. command, unless the previously inserted character was a
  4560. <backslash>,
  4561. in which case it shall be as if the literal current erase character had
  4562. been inserted instead of the
  4563. <backslash>.
  4564. .P
  4565. .IR "Current line" :
  4566. Unchanged, unless previously input lines are erased, in which case it
  4567. shall be set to line \-1.
  4568. .P
  4569. .IR "Current column" :
  4570. Set to the first column that displays any portion of the character
  4571. backed up over.
  4572. .SS "<newline>"
  4573. .IP "\fISynopsis\fR:" 10
  4574. .sp -1v
  4575. .RS 10
  4576. .sp
  4577. .RS 4
  4578. .nf
  4579. <newline>
  4580. .br
  4581. <carriage-return>
  4582. .br
  4583. <control>-J
  4584. .br
  4585. <control>-M
  4586. .fi
  4587. .P
  4588. .RE
  4589. .RE
  4590. .P
  4591. If input was part of a line-oriented command, text input mode shall be
  4592. terminated and the command shall continue execution with the input
  4593. provided.
  4594. .P
  4595. Otherwise, terminate the current line. If there are no characters other
  4596. than
  4597. .BR autoindent
  4598. characters on the line, all characters on the line shall be discarded.
  4599. Otherwise, it is unspecified whether the
  4600. .BR autoindent
  4601. characters in the line are modified by entering these characters.
  4602. .P
  4603. Continue text input mode on a new line appended after the current line.
  4604. If the
  4605. .BR slowopen
  4606. edit option is set, the lines on the screen below the current line
  4607. shall not be pushed down, but the first of them shall be cleared and
  4608. shall appear to be overwritten. Otherwise, the lines of the screen
  4609. below the current line shall be pushed down.
  4610. .P
  4611. If the
  4612. .BR autoindent
  4613. edit option is set, an appropriate number of
  4614. .BR autoindent
  4615. characters shall be added as a prefix to the line as described by the
  4616. .IR ex
  4617. .BR autoindent
  4618. edit option.
  4619. .P
  4620. All columns after the cursor that are erase-columns (as described in
  4621. .IR "Input Mode Commands in vi")
  4622. shall be discarded.
  4623. .P
  4624. If the
  4625. .BR autoindent
  4626. edit option is set, all
  4627. <blank>
  4628. characters immediately following the cursor shall be discarded.
  4629. .P
  4630. All remaining characters after the cursor shall be transferred to the
  4631. new line, positioned after any
  4632. .BR autoindent
  4633. characters.
  4634. .P
  4635. .IR "Current line" :
  4636. Set to current line +1.
  4637. .P
  4638. .IR "Current column" :
  4639. Set to the first column that displays any portion of the first
  4640. character after the
  4641. .BR autoindent
  4642. characters on the new line, if any, or the first column position after
  4643. the last
  4644. .BR autoindent
  4645. character, if any, or column position 1.
  4646. .SS "<control>-T"
  4647. .IP "\fISynopsis\fR:" 10
  4648. .sp -1v
  4649. .RS 10
  4650. .sp
  4651. .RS 4
  4652. .nf
  4653. <control>-T
  4654. .fi
  4655. .P
  4656. .RE
  4657. .RE
  4658. .P
  4659. The
  4660. <control>\(hyT
  4661. character shall have no special meaning when in text input mode for a
  4662. line-oriented command (see
  4663. .IR "Command Descriptions in vi").
  4664. .P
  4665. This command need not be supported on block-mode terminals.
  4666. .P
  4667. Behave as if the user entered the minimum number of
  4668. <blank>
  4669. characters necessary to move the cursor forward to the column position
  4670. after the next
  4671. .BR shiftwidth
  4672. (see the
  4673. .IR ex
  4674. .BR shiftwidth
  4675. command) boundary.
  4676. .P
  4677. .IR "Current line" :
  4678. Unchanged.
  4679. .P
  4680. .IR "Current column" :
  4681. Set to
  4682. .IR column
  4683. +
  4684. .BR shiftwidth
  4685. \- ((column \-1) %
  4686. .BR shiftwidth ).
  4687. .SS "<control>-U"
  4688. .IP "\fISynopsis\fR:" 10
  4689. .sp -1v
  4690. .RS 10
  4691. .sp
  4692. .RS 4
  4693. .nf
  4694. <control>-U
  4695. .fi
  4696. .P
  4697. .RE
  4698. .RE
  4699. .P
  4700. If there are characters other than
  4701. .BR autoindent
  4702. characters that have been input on the current line before the cursor,
  4703. the cursor shall move to the first character input after the
  4704. .BR autoindent
  4705. characters.
  4706. .P
  4707. Otherwise, if there are
  4708. .BR autoindent
  4709. characters on the current line before the cursor, it is
  4710. implementation-defined whether the
  4711. <control>\(hyU
  4712. command is an error or if the cursor moves to the first column position
  4713. on the line.
  4714. .P
  4715. Otherwise, if the cursor is in column position 1 and there are previous
  4716. lines that have been input, it is implementation-defined whether the
  4717. <control>\(hyU
  4718. command is an error or if it is equivalent to entering
  4719. <control>\(hyU
  4720. after the last input character on the previous input line.
  4721. .P
  4722. Otherwise, it shall be an error.
  4723. .P
  4724. All of the glyphs on columns between the starting cursor position and
  4725. (inclusively) the ending cursor position shall become erase-columns as
  4726. described in
  4727. .IR "Input Mode Commands in vi".
  4728. .P
  4729. The current
  4730. .IR kill
  4731. character (see
  4732. .IR stty )
  4733. shall cause an equivalent action to the
  4734. <control>\(hyU
  4735. command, unless the previously inserted character was a
  4736. <backslash>,
  4737. in which case it shall be as if the literal current
  4738. .IR kill
  4739. character had been inserted instead of the
  4740. <backslash>.
  4741. .P
  4742. .IR "Current line" :
  4743. Unchanged, unless previously input lines are erased, in which case it
  4744. shall be set to line \-1.
  4745. .P
  4746. .IR "Current column" :
  4747. Set to the first column that displays any portion of the last character
  4748. backed up over.
  4749. .SS "<control>-V"
  4750. .IP "\fISynopsis\fR:" 10
  4751. .sp -1v
  4752. .RS 10
  4753. .sp
  4754. .RS 4
  4755. .nf
  4756. <control>-V
  4757. .br
  4758. <control>-Q
  4759. .fi
  4760. .P
  4761. .RE
  4762. .RE
  4763. .P
  4764. Allow the entry of any subsequent character, other than
  4765. <control>\(hyJ
  4766. or the
  4767. <newline>,
  4768. as a literal character, removing any special meaning that it may have
  4769. to the editor in text input mode. If a
  4770. <control>\(hyV
  4771. or
  4772. <control>\(hyQ
  4773. is entered before a
  4774. <control>\(hyJ
  4775. or
  4776. <newline>,
  4777. the
  4778. <control>\(hyV
  4779. or
  4780. <control>\(hyQ
  4781. character shall be discarded, and the
  4782. <control>\(hyJ
  4783. or
  4784. <newline>
  4785. shall behave as described in the
  4786. <newline>
  4787. command character during input mode.
  4788. .P
  4789. For purposes of the display only, the editor shall behave as if a
  4790. .BR '\(ha'
  4791. character was entered, and the cursor shall be positioned as if
  4792. overwriting the
  4793. .BR '\(ha'
  4794. character. When a subsequent character is entered, the editor shall
  4795. behave as if that character was entered instead of the original
  4796. <control>\(hyV
  4797. or
  4798. <control>\(hyQ
  4799. character.
  4800. .P
  4801. .IR "Current line" :
  4802. Unchanged.
  4803. .P
  4804. .IR "Current column" :
  4805. Unchanged.
  4806. .SS "<control>-W"
  4807. .IP "\fISynopsis\fR:" 10
  4808. .sp -1v
  4809. .RS 10
  4810. .sp
  4811. .RS 4
  4812. .nf
  4813. <control>-W
  4814. .fi
  4815. .P
  4816. .RE
  4817. .RE
  4818. .P
  4819. If there are characters other than
  4820. .BR autoindent
  4821. characters that have been input on the current line before the cursor,
  4822. the cursor shall move back over the last word preceding the cursor
  4823. (including any
  4824. <blank>
  4825. characters between the end of the last word and the current cursor); the
  4826. cursor shall not move to before the first character after the end of any
  4827. .BR autoindent
  4828. characters.
  4829. .P
  4830. Otherwise, if there are
  4831. .BR autoindent
  4832. characters on the current line before the cursor, it is
  4833. implementation-defined whether the
  4834. <control>\(hyW
  4835. command is an error or if the cursor moves to the first column position
  4836. on the line.
  4837. .P
  4838. Otherwise, if the cursor is in column position 1 and there are previous
  4839. lines that have been input, it is implementation-defined whether the
  4840. <control>\(hyW
  4841. command is an error or if it is equivalent to entering
  4842. <control>\(hyW
  4843. after the last input character on the previous input line.
  4844. .P
  4845. Otherwise, it shall be an error.
  4846. .P
  4847. All of the glyphs on columns between the starting cursor position and
  4848. (inclusively) the ending cursor position shall become erase-columns as
  4849. described in
  4850. .IR "Input Mode Commands in vi".
  4851. .P
  4852. .IR "Current line" :
  4853. Unchanged, unless previously input lines are erased, in which case it
  4854. shall be set to line \-1.
  4855. .P
  4856. .IR "Current column" :
  4857. Set to the first column that displays any portion of the last character
  4858. backed up over.
  4859. .SS "<ESC>"
  4860. .IP "\fISynopsis\fR:" 10
  4861. .sp -1v
  4862. .RS 10
  4863. .sp
  4864. .RS 4
  4865. .nf
  4866. <ESC>
  4867. .fi
  4868. .P
  4869. .RE
  4870. .RE
  4871. .P
  4872. If input was part of a line-oriented command:
  4873. .IP " 1." 4
  4874. If
  4875. .IR interrupt
  4876. was entered, text input mode shall be terminated and the editor shall
  4877. return to command mode. The terminal shall be alerted.
  4878. .IP " 2." 4
  4879. If
  4880. <ESC>
  4881. was entered, text input mode shall be terminated and the command shall
  4882. continue execution with the input provided.
  4883. .P
  4884. Otherwise, terminate text input mode and return to command mode.
  4885. .P
  4886. Any
  4887. .BR autoindent
  4888. characters entered on newly created lines that have no other non-\c
  4889. <newline>
  4890. characters shall be deleted.
  4891. .P
  4892. Any leading
  4893. .BR autoindent
  4894. and
  4895. <blank>
  4896. characters on newly created lines shall be rewritten to be the minimum
  4897. number of
  4898. <blank>
  4899. characters possible.
  4900. .P
  4901. The screen shall be redisplayed as necessary to match the contents of
  4902. the edit buffer.
  4903. .P
  4904. .IR "Current line" :
  4905. Unchanged.
  4906. .br
  4907. .P
  4908. .IR "Current column" :
  4909. .IP " 1." 4
  4910. If there are text input characters on the current line, the column
  4911. shall be set to the last column where any portion of the last text
  4912. input character is displayed.
  4913. .IP " 2." 4
  4914. Otherwise, if a character is displayed in the current column,
  4915. unchanged.
  4916. .IP " 3." 4
  4917. Otherwise, set to column position 1.
  4918. .SH "EXIT STATUS"
  4919. The following exit values shall be returned:
  4920. .IP "\00" 6
  4921. Successful completion.
  4922. .IP >0 6
  4923. An error occurred.
  4924. .SH "CONSEQUENCES OF ERRORS"
  4925. When any error is encountered and the standard input is not a terminal
  4926. device file,
  4927. .IR vi
  4928. shall not write the file or return to command or text input mode, and
  4929. shall terminate with a non-zero exit status.
  4930. .P
  4931. Otherwise, when an unrecoverable error is encountered it shall be
  4932. equivalent to a SIGHUP asynchronous event.
  4933. .P
  4934. Otherwise, when an error is encountered, the editor shall behave as
  4935. specified in
  4936. .IR "Command Descriptions in vi".
  4937. .LP
  4938. .IR "The following sections are informative."
  4939. .SH "APPLICATION USAGE"
  4940. None.
  4941. .SH EXAMPLES
  4942. None.
  4943. .SH RATIONALE
  4944. See the RATIONALE for
  4945. .IR "\fIex\fR\^"
  4946. for more information on
  4947. .IR vi .
  4948. Major portions of the
  4949. .IR vi
  4950. utility specification point to
  4951. .IR ex
  4952. to avoid inadvertent divergence. While
  4953. .IR ex
  4954. and
  4955. .IR vi
  4956. have historically been implemented as a single utility, this is not
  4957. required by POSIX.1\(hy2008.
  4958. .P
  4959. It is recognized that portions of
  4960. .IR vi
  4961. would be difficult, if not impossible, to implement satisfactorily on a
  4962. block-mode terminal, or a terminal without any form of cursor
  4963. addressing, thus it is not a mandatory requirement that such features
  4964. should work on all terminals. It is the intention, however, that a
  4965. .IR vi
  4966. implementation should provide the full set of capabilities on all
  4967. terminals capable of supporting them.
  4968. .P
  4969. Historically,
  4970. .IR vi
  4971. exited immediately if the standard input was not a terminal. POSIX.1\(hy2008
  4972. permits, but does not require, this behavior. An end-of-file condition
  4973. is not equivalent to an end-of-file character. A common end-of-file
  4974. character,
  4975. <control>\(hyD,
  4976. is historically a
  4977. .IR vi
  4978. command.
  4979. .P
  4980. The text in the STDOUT section reflects the usage of the verb
  4981. .IR display
  4982. in this section; some implementations of
  4983. .IR vi
  4984. use standard output to write to the terminal, but POSIX.1\(hy2008 does not
  4985. require that to be the case.
  4986. .P
  4987. Historically, implementations reverted to open mode if the terminal was
  4988. incapable of supporting full visual mode. POSIX.1\(hy2008 requires this
  4989. behavior. Historically, the open mode of
  4990. .IR vi
  4991. behaved roughly equivalently to the visual mode, with the exception
  4992. that only a single line from the edit buffer (one ``buffer line'') was
  4993. kept current at any time. This line was normally displayed on the
  4994. next-to-last line of a terminal with cursor addressing (and the last
  4995. line performed its normal visual functions for line-oriented commands
  4996. and messages). In addition, some few commands behaved differently in
  4997. open mode than in visual mode. POSIX.1\(hy2008 requires conformance to historical
  4998. practice.
  4999. .P
  5000. Historically,
  5001. .IR ex
  5002. and
  5003. .IR vi
  5004. implementations have expected text to proceed in the usual
  5005. European/Latin order of left to right, top to bottom. There is no
  5006. requirement in POSIX.1\(hy2008 that this be the case. The specification was
  5007. deliberately written using words like ``before'', ``after'', ``first'',
  5008. and ``last'' in order to permit implementations to support the natural
  5009. text order of the language.
  5010. .P
  5011. Historically, lines past the end of the edit buffer were marked with
  5012. single
  5013. <tilde>
  5014. (\c
  5015. .BR '\(ti' )
  5016. characters; that is, if the one-based display was 20 lines in length,
  5017. and the last line of the file was on line one, then lines 2-20 would
  5018. contain only a single
  5019. .BR '\(ti'
  5020. character.
  5021. .P
  5022. Historically, the
  5023. .IR vi
  5024. editor attempted to display only complete lines at the bottom of the
  5025. screen (it did display partial lines at the top of the screen). If a
  5026. line was too long to fit in its entirety at the bottom of the screen,
  5027. the screen lines where the line would have been displayed were
  5028. displayed as single
  5029. .BR '@'
  5030. characters, instead of displaying part of the line. POSIX.1\(hy2008 permits, but
  5031. does not require, this behavior. Implementations are encouraged to
  5032. attempt always to display a complete line at the bottom of the screen
  5033. when doing scrolling or screen positioning by buffer lines.
  5034. .P
  5035. Historically, lines marked with
  5036. .BR '@'
  5037. were also used to minimize output to dumb terminals over slow lines;
  5038. that is, changes local to the cursor were updated, but changes to lines
  5039. on the screen that were not close to the cursor were simply marked with
  5040. an
  5041. .BR '@'
  5042. sign instead of being updated to match the current text. POSIX.1\(hy2008 permits,
  5043. but does not require this feature because it is used ever less
  5044. frequently as terminals become smarter and connections are faster.
  5045. .SS "Initialization in ex and vi"
  5046. .P
  5047. Historically,
  5048. .IR vi
  5049. always had a line in the edit buffer, even if the edit buffer was
  5050. ``empty''. For example:
  5051. .IP " 1." 4
  5052. The
  5053. .IR ex
  5054. command
  5055. .BR =
  5056. executed from visual mode wrote ``1'' when the buffer was empty.
  5057. .IP " 2." 4
  5058. Writes from visual mode of an empty edit buffer wrote files of a single
  5059. character (a
  5060. <newline>),
  5061. while writes from
  5062. .IR ex
  5063. mode of an empty edit buffer wrote empty files.
  5064. .IP " 3." 4
  5065. Put and read commands into an empty edit buffer left an empty line at
  5066. the top of the edit buffer.
  5067. .P
  5068. For consistency, POSIX.1\(hy2008 does not permit any of these behaviors.
  5069. .P
  5070. Historically,
  5071. .IR vi
  5072. did not always return the terminal to its original modes; for example,
  5073. ICRNL was modified if it was not originally set. POSIX.1\(hy2008 does not permit
  5074. this behavior.
  5075. .SS "Command Descriptions in vi"
  5076. .P
  5077. Motion commands are among the most complicated aspects of
  5078. .IR vi
  5079. to describe. With some exceptions, the text region and buffer type
  5080. effect of a motion command on a
  5081. .IR vi
  5082. command are described on a case-by-case basis. The descriptions of text
  5083. regions in POSIX.1\(hy2008 are not intended to imply direction; that is, an
  5084. inclusive region from line
  5085. .IR n
  5086. to line
  5087. .IR n +5
  5088. is identical to a region from line
  5089. .IR n +5
  5090. to line
  5091. .IR n .
  5092. This is of more than academic interest\(emmovements to marks can be in
  5093. either direction, and, if the
  5094. .BR wrapscan
  5095. option is set, so can movements to search points. Historically, lines
  5096. are always stored into buffers in text order; that is, from the start
  5097. of the edit buffer to the end. POSIX.1\(hy2008 requires conformance to historical
  5098. practice.
  5099. .P
  5100. Historically, command counts were applied to any associated motion, and
  5101. were multiplicative to any supplied motion count. For example,
  5102. .BR 2cw
  5103. is the same as
  5104. .BR c2w ,
  5105. and
  5106. .BR 2c3w
  5107. is the same as
  5108. .BR c6w .
  5109. POSIX.1\(hy2008 requires this behavior. Historically,
  5110. .IR vi
  5111. commands that used bigwords, words, paragraphs, and sentences as
  5112. objects treated groups of empty lines, or lines that contained only
  5113. <blank>
  5114. characters, inconsistently. Some commands treated them as a single entity,
  5115. while others treated each line separately. For example, the
  5116. .BR w ,
  5117. .BR W ,
  5118. and
  5119. .BR B
  5120. commands treated groups of empty lines as individual words; that is,
  5121. the command would move the cursor to each new empty line. The
  5122. .BR e
  5123. and
  5124. .BR E
  5125. commands treated groups of empty lines as a single word; that is, the
  5126. first use would move past the group of lines. The
  5127. .BR b
  5128. command would just beep at the user, or if done from the start of the
  5129. line as a motion command, fail in unexpected ways. If the lines
  5130. contained only (or ended with)
  5131. <blank>
  5132. characters, the
  5133. .BR w
  5134. and
  5135. .BR W
  5136. commands would just beep at the user, the
  5137. .BR E
  5138. and
  5139. .BR e
  5140. commands would treat the group as a single word, and the
  5141. .BR B
  5142. and
  5143. .BR b
  5144. commands would treat the lines as individual words. For consistency and
  5145. simplicity of specification, POSIX.1\(hy2008 requires that all
  5146. .IR vi
  5147. commands treat groups of empty or blank lines as a single entity, and
  5148. that movement through lines ending with
  5149. <blank>
  5150. characters be consistent with other movements.
  5151. .P
  5152. Historically,
  5153. .IR vi
  5154. documentation indicated that any number of double-quotes were skipped
  5155. after punctuation marks at sentence boundaries; however,
  5156. implementations only skipped single-quotes. POSIX.1\(hy2008 requires both to be
  5157. skipped.
  5158. .P
  5159. Historically, the first and last characters in the edit buffer were
  5160. word boundaries. This historical practice is required by POSIX.1\(hy2008.
  5161. .P
  5162. Historically,
  5163. .IR vi
  5164. attempted to update the minimum number of columns on the screen
  5165. possible, which could lead to misleading information being displayed.
  5166. POSIX.1\(hy2008 makes no requirements other than that the current character being
  5167. entered is displayed correctly, leaving all other decisions in this
  5168. area up to the implementation.
  5169. .P
  5170. Historically, lines were arbitrarily folded between columns of any
  5171. characters that required multiple column positions on the screen, with
  5172. the exception of tabs, which terminated at the right-hand margin. POSIX.1\(hy2008
  5173. permits the former and requires the latter. Implementations that do not
  5174. arbitrarily break lines between columns of characters that occupy
  5175. multiple column positions should not permit the cursor to rest on a
  5176. column that does not contain any part of a character.
  5177. .P
  5178. The historical
  5179. .IR vi
  5180. had a problem in that all movements were by buffer lines, not by
  5181. display or screen lines. This is often the right thing to do; for
  5182. example, single line movements, such as
  5183. .BR j
  5184. or
  5185. .BR k ,
  5186. should work on buffer lines. Commands like
  5187. .BR dj ,
  5188. or
  5189. .BR j. ,
  5190. where
  5191. .BR .
  5192. is a change command, only make sense for buffer lines. It is not,
  5193. however, the right thing to do for screen motion or scrolling commands
  5194. like
  5195. <control>\(hyD,
  5196. <control>\(hyF,
  5197. and
  5198. .BR H .
  5199. If the window is fairly small, using buffer lines in these cases can
  5200. result in completely random motion; for example,
  5201. .BR 1 \c
  5202. <control>\c
  5203. .BR \(hyD
  5204. can result in a completely changed screen, without any overlap. This is
  5205. clearly not what the user wanted. The problem is even worse in the case
  5206. of the
  5207. .BR H ,
  5208. .BR L ,
  5209. and
  5210. .BR M
  5211. commands\(emas they position the cursor at the first non-\c
  5212. <blank>
  5213. of the line, they may all refer to the same location in large lines,
  5214. and will result in no movement at all.
  5215. .P
  5216. In addition, if the line is larger than the screen, using buffer
  5217. lines can make it impossible to display parts of the line\(emthere are
  5218. not any commands that do not display the beginning of the line in
  5219. historical
  5220. .IR vi ,
  5221. and if both the beginning and end of the line cannot be on the screen
  5222. at the same time, the user suffers. Finally, the page and half-page
  5223. scrolling commands historically moved to the first non-\c
  5224. <blank>
  5225. in the new line. If the line is approximately the same size as the
  5226. screen, this is inadequate because the cursor before and after a
  5227. <control>\(hyD
  5228. command will refer to the same location on the screen.
  5229. .P
  5230. Implementations of
  5231. .IR ex
  5232. and
  5233. .IR vi
  5234. exist that do not have these problems because the relevant commands (\c
  5235. <control>\(hyB,
  5236. <control>\(hyD,
  5237. <control>\(hyF,
  5238. <control>\(hyU,
  5239. <control>\(hyY,
  5240. <control>\(hyE,
  5241. .BR H ,
  5242. .BR L ,
  5243. and
  5244. .BR M)
  5245. operate on display (screen) lines, not (edit) buffer lines.
  5246. .P
  5247. POSIX.1\(hy2008 does not permit this behavior by default because the standard
  5248. developers believed that users would find it too confusing. However,
  5249. historical practice has been relaxed. For example,
  5250. .IR ex
  5251. and
  5252. .IR vi
  5253. historically attempted, albeit sometimes unsuccessfully, to never put
  5254. part of a line on the last lines of a screen; for example, if a line
  5255. would not fit in its entirety, no part of the line was displayed, and
  5256. the screen lines corresponding to the line contained single
  5257. .BR '@'
  5258. characters. This behavior is permitted, but not required by POSIX.1\(hy2008, so
  5259. that it is possible for implementations to support long lines in small
  5260. screens more reasonably without changing the commands to be oriented to
  5261. the display (instead of oriented to the buffer). POSIX.1\(hy2008 also permits
  5262. implementations to refuse to edit any edit buffer containing a line
  5263. that will not fit on the screen in its entirety.
  5264. .P
  5265. The display area (for example, the value of the
  5266. .BR window
  5267. edit option) has historically been ``grown'', or expanded, to display
  5268. new text when local movements are done in displays where the number of
  5269. lines displayed is less than the maximum possible. Expansion has
  5270. historically been the first choice, when the target line is less than
  5271. the maximum possible expansion value away. Scrolling has historically
  5272. been the next choice, done when the target line is less than half a
  5273. display away, and otherwise, the screen was redrawn. There were
  5274. exceptions, however, in that
  5275. .IR ex
  5276. commands generally always caused the screen to be redrawn. POSIX.1\(hy2008 does
  5277. not specify a standard behavior because there may be external issues,
  5278. such as connection speed, the number of characters necessary to redraw
  5279. as opposed to scroll, or terminal capabilities that implementations
  5280. will have to accommodate.
  5281. .P
  5282. The current line in POSIX.1\(hy2008 maps one-to-one to a buffer line in the
  5283. file. The current column does not. There are two different column
  5284. values that are described by POSIX.1\(hy2008. The first is the current column
  5285. value as set by many of the
  5286. .IR vi
  5287. commands. This value is remembered for the lifetime of the editor. The
  5288. second column value is the actual position on the screen where the
  5289. cursor rests. The two are not always the same. For example, when the
  5290. cursor is backed by a multi-column character, the actual cursor
  5291. position on the screen has historically been the last column of the
  5292. character in command mode, and the first column of the character in
  5293. input mode.
  5294. .P
  5295. Commands that set the current line, but that do not set the current
  5296. cursor value (for example,
  5297. .BR j
  5298. and
  5299. .BR k )
  5300. attempt to get as close as possible to the remembered column position,
  5301. so that the cursor tends to restrict itself to a vertical column as the
  5302. user moves around in the edit buffer. POSIX.1\(hy2008 requires conformance to
  5303. historical practice, requiring that the display location of the cursor
  5304. on the display line be adjusted from the current column value as
  5305. necessary to support this historical behavior.
  5306. .P
  5307. Historically, only a single line (and for some terminals, a single line
  5308. minus 1 column) of characters could be entered by the user for the
  5309. line-oriented commands; that is,
  5310. .BR : ,
  5311. .BR ! ,
  5312. .BR / ,
  5313. or
  5314. .BR ? .
  5315. POSIX.1\(hy2008 permits, but does not require, this limitation.
  5316. .P
  5317. Historically, ``soft'' errors in
  5318. .IR vi
  5319. caused the terminal to be alerted, but no error message was displayed.
  5320. As a general rule, no error message was displayed for errors in command
  5321. execution in
  5322. .IR vi ,
  5323. when the error resulted from the user attempting an invalid or
  5324. impossible action, or when a searched-for object was not found.
  5325. Examples of soft errors included
  5326. .BR h
  5327. at the left margin,
  5328. <control>\(hyB
  5329. or
  5330. .BR [[
  5331. at the beginning of the file,
  5332. .BR 2G
  5333. at the end of the file, and so on. In addition, errors such as
  5334. .BR % ,
  5335. .BR ]] ,
  5336. .BR } ,
  5337. .BR ) ,
  5338. .BR N ,
  5339. .BR n ,
  5340. .BR f ,
  5341. .BR F ,
  5342. .BR t ,
  5343. and
  5344. .BR T
  5345. failing to find the searched-for object were soft as well. Less
  5346. consistently,
  5347. .BR /
  5348. and
  5349. .BR ?
  5350. displayed an error message if the pattern was not found,
  5351. .BR / ,
  5352. .BR ? ,
  5353. .BR N ,
  5354. and
  5355. .BR n
  5356. displayed an error message if no previous regular expression had been
  5357. specified, and
  5358. .BR ;
  5359. did not display an error message if no previous
  5360. .BR f ,
  5361. .BR F ,
  5362. .BR t ,
  5363. or
  5364. .BR T
  5365. command had occurred. Also, behavior in this area might reasonably be
  5366. based on a runtime evaluation of the speed of a network connection.
  5367. Finally, some implementations have provided error messages for soft
  5368. errors in order to assist naive users, based on the value of a verbose
  5369. edit option. POSIX.1\(hy2008 does not list specific errors for which an error
  5370. message shall be displayed. Implementations should conform to
  5371. historical practice in the absence of any strong reason to diverge.
  5372. .SS "Page Backwards"
  5373. .P
  5374. The
  5375. <control>\(hyB
  5376. and
  5377. <control>\(hyF
  5378. commands historically considered it an error to attempt to page past
  5379. the beginning or end of the file, whereas the
  5380. <control>\(hyD
  5381. and
  5382. <control>\(hyU
  5383. commands simply moved to the beginning or end of the file. For
  5384. consistency, POSIX.1\(hy2008 requires the latter behavior for all four commands.
  5385. All four commands still consider it an error if the current line is at
  5386. the beginning (\c
  5387. <control>\(hyB,
  5388. <control>\(hyU)
  5389. or end (\c
  5390. <control>\(hyF,
  5391. <control>\(hyD)
  5392. of the file. Historically, the
  5393. <control>\(hyB
  5394. and
  5395. <control>\(hyF
  5396. commands skip two lines in order to include overlapping lines when a
  5397. single command is entered. This makes less sense in the presence of a
  5398. .IR count ,
  5399. as there will be, by definition, no overlapping lines. The actual
  5400. calculation used by historical implementations of the
  5401. .IR vi
  5402. editor for
  5403. <control>\(hyB
  5404. was:
  5405. .sp
  5406. .RS 4
  5407. .nf
  5408. ((current first line) - count x (window edit option)) +2
  5409. .fi
  5410. .P
  5411. .RE
  5412. .P
  5413. and for
  5414. <control>\(hyF
  5415. was:
  5416. .sp
  5417. .RS 4
  5418. .nf
  5419. ((current first line) + count x (window edit option)) -2
  5420. .fi
  5421. .P
  5422. .RE
  5423. .P
  5424. This calculation does not work well when intermixing commands with and
  5425. without counts; for example,
  5426. .BR 3\c
  5427. <control>\(hyF
  5428. is not equivalent to entering the
  5429. <control>\(hyF
  5430. command three times, and is not reversible by entering the
  5431. <control>\(hyB
  5432. command three times. For consistency with other
  5433. .IR vi
  5434. commands that take counts, POSIX.1\(hy2008 requires a different calculation.
  5435. .SS "Scroll Forward"
  5436. .P
  5437. The 4BSD and System V implementations of
  5438. .IR vi
  5439. differed on the initial value used by the
  5440. .BR scroll
  5441. command. 4BSD used:
  5442. .sp
  5443. .RS 4
  5444. .nf
  5445. ((window edit option) +1) /2
  5446. .fi
  5447. .P
  5448. .RE
  5449. .P
  5450. while System V used the value of the
  5451. .BR scroll
  5452. edit option. The System V version is specified by POSIX.1\(hy2008 because the
  5453. standard developers believed that it was more intuitive and permitted
  5454. the user a method of setting the scroll value initially without also
  5455. setting the number of lines that are displayed.
  5456. .SS "Scroll Forward by Line"
  5457. .P
  5458. Historically, the
  5459. <control>\(hyE
  5460. and
  5461. <control>\(hyY
  5462. commands considered it an error if the last and first lines,
  5463. respectively, were already on the screen. POSIX.1\(hy2008 requires conformance to
  5464. historical practice. Historically, the
  5465. <control>\(hyE
  5466. and
  5467. <control>\(hyY
  5468. commands had no effect in open mode. For simplicity and consistency of
  5469. specification, POSIX.1\(hy2008 requires that they behave as usual, albeit with a
  5470. single line screen.
  5471. .SS "Clear and Redisplay"
  5472. .P
  5473. The historical
  5474. <control>\(hyL
  5475. command refreshed the screen exactly as it was supposed to be currently
  5476. displayed, replacing any
  5477. .BR '@'
  5478. characters for lines that had been deleted but not updated on the
  5479. screen with refreshed
  5480. .BR '@'
  5481. characters. The intent of the
  5482. <control>\(hyL
  5483. command is to refresh when the screen has been accidentally
  5484. overwritten; for example, by a
  5485. .BR write
  5486. command from another user, or modem noise.
  5487. .SS "Redraw Screen"
  5488. .P
  5489. The historical
  5490. <control>\(hyR
  5491. command redisplayed only when necessary to update lines that had been
  5492. deleted but not updated on the screen and that were flagged with
  5493. .BR '@'
  5494. characters. There is no requirement that the screen be in any way
  5495. refreshed if no lines of this form are currently displayed. POSIX.1\(hy2008
  5496. permits implementations to extend this command to refresh lines on the
  5497. screen flagged with
  5498. .BR '@'
  5499. characters because they are too long to be displayed in the current
  5500. framework; however, the current line and column need not be modified.
  5501. .SS "Search for tagstring"
  5502. .P
  5503. Historically, the first non-\c
  5504. <blank>
  5505. at or after the cursor was the first character, and all subsequent
  5506. characters that were word characters, up to the end of the line, were
  5507. included. For example, with the cursor on the leading
  5508. <space>
  5509. or on the
  5510. .BR '#'
  5511. character in the text
  5512. .BR \(dq#bar@\(dq ,
  5513. the tag was
  5514. .BR \(dq#bar\(dq .
  5515. On the character
  5516. .BR 'b'
  5517. it was
  5518. .BR \(dqbar\(dq ,
  5519. and on the
  5520. .BR 'a'
  5521. it was
  5522. .BR \(dqar\(dq .
  5523. POSIX.1\(hy2008 requires this behavior.
  5524. .SS "Replace Text with Results from Shell Command"
  5525. .P
  5526. Historically, the
  5527. .BR < ,
  5528. .BR > ,
  5529. and
  5530. .BR !
  5531. commands considered most cursor motions other than line-oriented
  5532. motions an error; for example, the command
  5533. .BR ">/foo<CR>"
  5534. succeeded, while the command
  5535. .BR ">l"
  5536. failed, even though the text region described by the two commands might
  5537. be identical. For consistency, all three commands only consider entire
  5538. lines and not partial lines, and the region is defined as any line that
  5539. contains a character that was specified by the motion.
  5540. .SS "Move to Matching Character"
  5541. .P
  5542. Other matching characters have been left implementation-defined in
  5543. order to allow extensions such as matching
  5544. .BR '<'
  5545. and
  5546. .BR '>'
  5547. for searching HTML, or
  5548. .BR #ifdef ,
  5549. .BR #else ,
  5550. and
  5551. .BR #endif
  5552. for searching C source.
  5553. .SS "Repeat Substitution"
  5554. .P
  5555. POSIX.1\(hy2008 requires that any
  5556. .BR c
  5557. and
  5558. .BR g
  5559. flags specified to the previous substitute command be ignored; however,
  5560. the
  5561. .BR r
  5562. flag may still apply, if supported by the implementation.
  5563. .SS "Return to Previous (Context or Section)"
  5564. .P
  5565. The
  5566. .BR [[ ,
  5567. .BR ]] ,
  5568. .BR ( ,
  5569. .BR ) ,
  5570. .BR { ,
  5571. and
  5572. .BR }
  5573. commands are all affected by ``section boundaries'', but in some
  5574. historical implementations not all of the commands recognize the same
  5575. section boundaries. This is a bug, not a feature, and a unique
  5576. section-boundary algorithm was not described for each command. One
  5577. special case that is preserved is that the sentence command moves to
  5578. the end of the last line of the edit buffer while the other commands go
  5579. to the beginning, in order to preserve the traditional character cut
  5580. semantics of the sentence command. Historically,
  5581. .IR vi
  5582. section boundaries at the beginning and end of the edit buffer were the
  5583. first non-\c
  5584. <blank>
  5585. on the first and last lines of the edit buffer if one exists;
  5586. otherwise, the last character of the first and last lines of the edit
  5587. buffer if one exists. To increase consistency with other section
  5588. locations, this has been simplified by POSIX.1\(hy2008 to the first character of
  5589. the first and last lines of the edit buffer, or the first and the last
  5590. lines of the edit buffer if they are empty.
  5591. .P
  5592. Sentence boundaries were problematic in the historical
  5593. .IR vi .
  5594. They were not only the boundaries as defined for the section and
  5595. paragraph commands, but they were the first non-\c
  5596. <blank>
  5597. that occurred after those boundaries, as well. Historically, the
  5598. .IR vi
  5599. section commands were documented as taking an optional window size as a
  5600. .IR count
  5601. preceding the command. This was not implemented in historical versions,
  5602. so POSIX.1\(hy2008 requires that the
  5603. .IR count
  5604. repeat the command, for consistency with other
  5605. .IR vi
  5606. commands.
  5607. .SS "Repeat"
  5608. .P
  5609. Historically, mapped commands other than text input commands could not
  5610. be repeated using the
  5611. .BR period
  5612. command. POSIX.1\(hy2008 requires conformance to historical practice.
  5613. .P
  5614. The restrictions on the interpretation of special characters (for
  5615. example,
  5616. <control>\(hyH)
  5617. in the repetition of text input mode commands is intended to match
  5618. historical practice. For example, given the input sequence:
  5619. .sp
  5620. .RS 4
  5621. .nf
  5622. iab<control>-H<control>-H<control>-Hdef<escape>
  5623. .fi
  5624. .P
  5625. .RE
  5626. .P
  5627. the user should be informed of an error when the sequence is first
  5628. entered, but not during a command repetition. The character
  5629. <control>\(hyT
  5630. is specifically exempted from this restriction. Historical
  5631. implementations of
  5632. .IR vi
  5633. ignored
  5634. <control>\(hyT
  5635. characters that were input in the original command during command
  5636. repetition. POSIX.1\(hy2008 prohibits this behavior.
  5637. .SS "Find Regular Expression"
  5638. .P
  5639. Historically, commands did not affect the line searched to or from if
  5640. the motion command was a search (\c
  5641. .BR / ,
  5642. .BR ? ,
  5643. .BR N ,
  5644. .BR n )
  5645. and the final position was the start/end of the line. There were some
  5646. special cases and
  5647. .IR vi
  5648. was not consistent. POSIX.1\(hy2008 does not permit this behavior, for
  5649. consistency. Historical implementations permitted but were unable to
  5650. handle searches as motion commands that wrapped (that is, due to the
  5651. edit option
  5652. .BR wrapscan )
  5653. to the original location. POSIX.1\(hy2008 requires that this behavior be treated
  5654. as an error.
  5655. .P
  5656. Historically, the syntax
  5657. .BR \(dq/RE/0\(dq
  5658. was used to force the command to cut text in line mode. POSIX.1\(hy2008 requires
  5659. conformance to historical practice.
  5660. .P
  5661. Historically, in open mode, a
  5662. .BR z
  5663. specified to a search command redisplayed the current line instead of
  5664. displaying the current screen with the current line highlighted. For
  5665. consistency and simplicity of specification, POSIX.1\(hy2008 does not permit this
  5666. behavior.
  5667. .P
  5668. Historically, trailing
  5669. .BR z
  5670. commands were permitted and ignored if entered as part of a search used
  5671. as a motion command. For consistency and simplicity of specification,
  5672. POSIX.1\(hy2008 does not permit this behavior.
  5673. .SS "Execute an ex Command"
  5674. .P
  5675. Historically,
  5676. .IR vi
  5677. implementations restricted the commands that could be entered on the
  5678. colon command line (for example,
  5679. .BR append
  5680. and
  5681. .BR change ),
  5682. and some other commands were known to cause them to fail
  5683. catastrophically. For consistency, POSIX.1\(hy2008 does not permit these
  5684. restrictions. When executing an
  5685. .IR ex
  5686. command by entering
  5687. .BR : ,
  5688. it is not possible to enter a
  5689. <newline>
  5690. as part of the command because it is considered the end of the command.
  5691. A different approach is to enter
  5692. .IR ex
  5693. command mode by using the
  5694. .IR vi
  5695. .BR Q
  5696. command (and later resuming visual mode with the
  5697. .IR ex
  5698. .BR vi
  5699. command). In
  5700. .IR ex
  5701. command mode, the single-line limitation does not exist. So, for
  5702. example, the following is valid:
  5703. .sp
  5704. .RS 4
  5705. .nf
  5706. Q
  5707. s/break here/break\e
  5708. here/
  5709. vi
  5710. .fi
  5711. .P
  5712. .RE
  5713. .P
  5714. POSIX.1\(hy2008 requires that, if the
  5715. .IR ex
  5716. command overwrites any part of the screen that would be erased by a
  5717. refresh,
  5718. .IR vi
  5719. pauses for a character from the user. Historically, this character
  5720. could be any character; for example, a character input by the user
  5721. before the message appeared, or even a mapped character. This is
  5722. probably a bug, but implementations that have tried to be more rigorous
  5723. by requiring that the user enter a specific character, or that the user
  5724. enter a character after the message was displayed, have been forced by
  5725. user indignation back into historical behavior. POSIX.1\(hy2008 requires
  5726. conformance to historical practice.
  5727. .SS "Shift Left (Right)"
  5728. .P
  5729. Refer to the Rationale for the
  5730. .BR !
  5731. and
  5732. .BR /
  5733. commands. Historically, the
  5734. .BR <
  5735. and
  5736. .BR >
  5737. commands sometimes moved the cursor to the first non-\c
  5738. <blank>
  5739. (for example if the command was repeated or with
  5740. .BR _
  5741. as the motion command), and sometimes left it unchanged. POSIX.1\(hy2008 does not
  5742. permit this inconsistency, requiring instead that the cursor always
  5743. move to the first non-\c
  5744. <blank>.
  5745. Historically, the
  5746. .BR <
  5747. and
  5748. .BR >
  5749. commands did not support buffer arguments, although some
  5750. implementations allow the specification of an optional buffer. This
  5751. behavior is neither required nor disallowed by POSIX.1\(hy2008.
  5752. .SS "Execute"
  5753. .P
  5754. Historically, buffers could execute other buffers, and loops, infinite
  5755. and otherwise, were possible. POSIX.1\(hy2008 requires conformance to historical
  5756. practice. The *\c
  5757. .IR buffer
  5758. syntax of
  5759. .IR ex
  5760. is not required in
  5761. .IR vi ,
  5762. because it is not historical practice and has been used in some
  5763. .IR vi
  5764. implementations to support additional scripting languages.
  5765. .SS "Reverse Case"
  5766. .P
  5767. Historically, the
  5768. .BR ~
  5769. command ignored any associated
  5770. .IR count ,
  5771. and acted only on the characters in the current line. For consistency
  5772. with other
  5773. .IR vi
  5774. commands, POSIX.1\(hy2008 requires that an associated
  5775. .IR count
  5776. act on the next
  5777. .IR count
  5778. characters, and that the command move to subsequent lines if warranted
  5779. by
  5780. .IR count ,
  5781. to make it possible to modify large pieces of text in a reasonably
  5782. efficient manner. There exist
  5783. .IR vi
  5784. implementations that optionally require an associated motion command
  5785. for the
  5786. .BR ~
  5787. command. Implementations supporting this functionality are encouraged
  5788. to base it on the
  5789. .BR tildedop
  5790. edit option and handle the text regions and cursor positioning
  5791. identically to the
  5792. .BR yank
  5793. command.
  5794. .SS "Append"
  5795. .P
  5796. Historically,
  5797. .IR count s
  5798. specified to the
  5799. .BR A ,
  5800. .BR a ,
  5801. .BR I ,
  5802. and
  5803. .BR i
  5804. commands repeated the input of the first line
  5805. .IR count
  5806. times, and did not repeat the subsequent lines of the input text. POSIX.1\(hy2008
  5807. requires that the entire text input be repeated
  5808. .IR count
  5809. times.
  5810. .SS "Move Backward to Preceding Word"
  5811. .P
  5812. Historically,
  5813. .IR vi
  5814. became confused if word commands were used as motion commands in empty
  5815. files. POSIX.1\(hy2008 requires that this be an error. Historical implementations
  5816. of
  5817. .IR vi
  5818. had a large number of bugs in the word movement commands, and they
  5819. varied greatly in behavior in the presence of empty lines, ``words''
  5820. made up of a single character, and lines containing only
  5821. <blank>
  5822. characters. For consistency and simplicity of specification, POSIX.1\(hy2008 does
  5823. not permit this behavior.
  5824. .SS "Change to End-of-Line"
  5825. .P
  5826. Some historical implementations of the
  5827. .BR C
  5828. command did not behave as described by POSIX.1\(hy2008 when the
  5829. .BR $
  5830. key was remapped because they were implemented by pushing the
  5831. .BR $
  5832. key onto the input queue and reprocessing it. POSIX.1\(hy2008 does not permit
  5833. this behavior. Historically, the
  5834. .BR C ,
  5835. .BR S ,
  5836. and
  5837. .BR s
  5838. commands did not copy replaced text into the numeric buffers. For
  5839. consistency and simplicity of specification, POSIX.1\(hy2008 requires that they
  5840. behave like their respective
  5841. .BR c
  5842. commands in all respects.
  5843. .SS "Delete"
  5844. .P
  5845. Historically, lines in open mode that were deleted were scrolled up,
  5846. and an
  5847. .BR @
  5848. glyph written over the beginning of the line. In the case of terminals
  5849. that are incapable of the necessary cursor motions, the editor erased
  5850. the deleted line from the screen. POSIX.1\(hy2008 requires conformance to
  5851. historical practice; that is, if the terminal cannot display the
  5852. .BR '@'
  5853. character, the line cannot remain on the screen.
  5854. .SS "Delete to End-of-Line"
  5855. .P
  5856. Some historical implementations of the
  5857. .BR D
  5858. command did not behave as described by POSIX.1\(hy2008 when the
  5859. .BR $
  5860. key was remapped because they were implemented by pushing the
  5861. .BR $
  5862. key onto the input queue and reprocessing it. POSIX.1\(hy2008 does not permit
  5863. this behavior.
  5864. .SS "Join"
  5865. .P
  5866. An historical oddity of
  5867. .IR vi
  5868. is that the commands
  5869. .BR J ,
  5870. .BR 1J ,
  5871. and
  5872. .BR 2J
  5873. are all equivalent. POSIX.1\(hy2008 requires conformance to historical practice.
  5874. The
  5875. .IR vi
  5876. .BR J
  5877. command is specified in terms of the
  5878. .IR ex
  5879. .BR join
  5880. command with an
  5881. .IR ex
  5882. command
  5883. .IR count
  5884. value. The address correction for a
  5885. .IR count
  5886. that is past the end of the edit buffer is necessary for historical
  5887. compatibility for both
  5888. .IR ex
  5889. and
  5890. .IR vi .
  5891. .SS "Mark Position"
  5892. .P
  5893. Historical practice is that only lowercase letters, plus backquote and
  5894. single-quote, could be used to mark a cursor position. POSIX.1\(hy2008 requires
  5895. conformance to historical practice, but encourages implementations to
  5896. support other characters as marks as well.
  5897. .SS "Repeat Regular Expression Find (Forward and Reverse)"
  5898. .P
  5899. Historically, the
  5900. .BR N
  5901. and
  5902. .BR n
  5903. commands could not be used as motion components for the
  5904. .BR c
  5905. command. With the exception of the
  5906. .BR cN
  5907. command, which worked if the search crossed a line boundary, the text
  5908. region would be discarded, and the user would not be in text input
  5909. mode. For consistency and simplicity of specification, POSIX.1\(hy2008 does not
  5910. permit this behavior.
  5911. .SS "Insert Empty Line (Below and Above)"
  5912. .P
  5913. Historically, counts to the
  5914. .BR O
  5915. and
  5916. .BR o
  5917. commands were used as the number of physical lines to open, if the
  5918. terminal was dumb and the
  5919. .BR slowopen
  5920. option was not set. This was intended to minimize traffic over slow
  5921. connections and repainting for dumb terminals. POSIX.1\(hy2008 does not permit
  5922. this behavior, requiring that a
  5923. .IR count
  5924. to the open command behave as for other text input commands. This
  5925. change to historical practice was made for consistency, and because a
  5926. superset of the functionality is provided by the
  5927. .BR slowopen
  5928. edit option.
  5929. .SS "Put from Buffer (Following and Before)"
  5930. .P
  5931. Historically,
  5932. .IR count s
  5933. to the
  5934. .BR p
  5935. and
  5936. .BR P
  5937. commands were ignored if the buffer was a line mode buffer, but were
  5938. (mostly) implemented as described in POSIX.1\(hy2008 if the buffer was a
  5939. character mode buffer. Because implementations exist that do not have
  5940. this limitation, and because pasting lines multiple times is generally
  5941. useful, POSIX.1\(hy2008 requires that
  5942. .IR count
  5943. be supported for all
  5944. .BR p
  5945. and
  5946. .BR P
  5947. commands.
  5948. .P
  5949. Historical implementations of
  5950. .IR vi
  5951. were widely known to have major problems in the
  5952. .BR p
  5953. and
  5954. .BR P
  5955. commands, particularly when unusual regions of text were copied into
  5956. the edit buffer. The standard developers viewed these as bugs, and they
  5957. are not permitted for consistency and simplicity of specification.
  5958. .P
  5959. Historically, a
  5960. .BR P
  5961. or
  5962. .BR p
  5963. command (or an
  5964. .IR ex
  5965. .BR put
  5966. command executed from open or visual mode) executed in an empty file,
  5967. left an empty line as the first line of the file. For consistency and
  5968. simplicity of specification, POSIX.1\(hy2008 does not permit this behavior.
  5969. .SS "Replace Character"
  5970. .P
  5971. Historically, the
  5972. .BR r
  5973. command did not correctly handle the
  5974. .IR erase
  5975. and
  5976. .IR "word erase"
  5977. characters as arguments, nor did it handle an associated
  5978. .IR count
  5979. greater than 1 with a
  5980. <carriage-return>
  5981. argument, for which it replaced
  5982. .IR count
  5983. characters with a single
  5984. <newline>.
  5985. POSIX.1\(hy2008 does not permit these inconsistencies.
  5986. .P
  5987. Historically, the
  5988. .BR r
  5989. command permitted the
  5990. <control>\(hyV
  5991. escaping of entered characters, such as
  5992. <ESC>
  5993. and the
  5994. <carriage-return>;
  5995. however, it required two leading
  5996. <control>\(hyV
  5997. characters instead of one. POSIX.1\(hy2008 requires that this be changed for
  5998. consistency with the other text input commands of
  5999. .IR vi .
  6000. .P
  6001. Historically, it is an error to enter the
  6002. .BR r
  6003. command if there are less than
  6004. .IR count
  6005. characters at or after the cursor in the line. While a reasonable and
  6006. unambiguous extension would be to permit the
  6007. .BR r
  6008. command on empty lines, it would require that too large a
  6009. .IR count
  6010. be adjusted to match the number of characters at or after the cursor
  6011. for consistency, which is sufficiently different from historical
  6012. practice to be avoided. POSIX.1\(hy2008 requires conformance to historical
  6013. practice.
  6014. .SS "Replace Characters"
  6015. .P
  6016. Historically, if there were
  6017. .BR autoindent
  6018. characters in the line on which the
  6019. .BR R
  6020. command was run, and
  6021. .BR autoindent
  6022. was set, the first
  6023. <newline>
  6024. would be properly indented and no characters would be replaced by the
  6025. <newline>.
  6026. Each additional
  6027. <newline>
  6028. would replace
  6029. .IR n
  6030. characters, where
  6031. .IR n
  6032. was the number of characters that were needed to indent the rest of the
  6033. line to the proper indentation level. This behavior is a bug and is not
  6034. permitted by POSIX.1\(hy2008.
  6035. .SS "Undo"
  6036. .P
  6037. Historical practice for cursor positioning after undoing commands was
  6038. mixed. In most cases, when undoing commands that affected a single
  6039. line, the cursor was moved to the start of added or changed text, or
  6040. immediately after deleted text. However, if the user had moved from the
  6041. line being changed, the column was either set to the first non-\c
  6042. <blank>,
  6043. returned to the origin of the command, or remained unchanged. When
  6044. undoing commands that affected multiple lines or entire lines, the
  6045. cursor was moved to the first character in the first line restored. As
  6046. an example of how inconsistent this was, a search, followed by an
  6047. .BR o
  6048. text input command, followed by an
  6049. .BR undo
  6050. would return the cursor to the location where the
  6051. .BR o
  6052. command was entered, but a
  6053. .BR cw
  6054. command followed by an
  6055. .BR o
  6056. command followed by an
  6057. .BR undo
  6058. would return the cursor to the first non-\c
  6059. <blank>
  6060. of the line. POSIX.1\(hy2008 requires the most useful of these behaviors, and
  6061. discards the least useful, in the interest of consistency and
  6062. simplicity of specification.
  6063. .SS "Yank"
  6064. .P
  6065. Historically, the
  6066. .BR yank
  6067. command did not move to the end of the motion if the motion was in the
  6068. forward direction. It moved to the end of the motion if the motion was
  6069. in the backward direction, except for the
  6070. .BR _
  6071. command, or for the
  6072. .BR G
  6073. and
  6074. .BR \(aq
  6075. commands when the end of the motion was on the current line. This was
  6076. further complicated by the fact that for a number of motion commands,
  6077. the
  6078. .BR yank
  6079. command moved the cursor but did not update the screen; for example, a
  6080. subsequent command would move the cursor from the end of the motion,
  6081. even though the cursor on the screen had not reflected the cursor
  6082. movement for the
  6083. .BR yank
  6084. command. POSIX.1\(hy2008 requires that all
  6085. .BR yank
  6086. commands associated with backward motions move the cursor to the end of
  6087. the motion for consistency, and specifically, to make
  6088. .BR \(aq
  6089. commands as motions consistent with search patterns as motions.
  6090. .SS "Yank Current Line"
  6091. .P
  6092. Some historical implementations of the
  6093. .BR Y
  6094. command did not behave as described by POSIX.1\(hy2008 when the
  6095. .BR '_'
  6096. key was remapped because they were implemented by pushing the
  6097. .BR '_'
  6098. key onto the input queue and reprocessing it. POSIX.1\(hy2008 does not permit
  6099. this behavior.
  6100. .SS "Redraw Window"
  6101. .P
  6102. Historically, the
  6103. .BR z
  6104. command always redrew the screen. This is permitted but not required by
  6105. POSIX.1\(hy2008, because of the frequent use of the
  6106. .BR z
  6107. command in macros such as
  6108. .BR "map n nz."
  6109. for screen positioning, instead of its use to change the screen size.
  6110. The standard developers believed that expanding or scrolling the screen
  6111. offered a better interface for users. The ability to redraw the screen
  6112. is preserved if the optional new window size is specified, and in the
  6113. <control>\(hyL
  6114. and
  6115. <control>\(hyR
  6116. commands.
  6117. .P
  6118. The semantics of
  6119. .BR z^
  6120. are confusing at best. Historical practice is that the screen before
  6121. the screen that ended with the specified line is displayed. POSIX.1\(hy2008
  6122. requires conformance to historical practice.
  6123. .P
  6124. Historically, the
  6125. .BR z
  6126. command would not display a partial line at the top or bottom of the
  6127. screen. If the partial line would normally have been displayed at the
  6128. bottom of the screen, the command worked, but the partial line was
  6129. replaced with
  6130. .BR '@'
  6131. characters. If the partial line would normally have been displayed at
  6132. the top of the screen, the command would fail. For consistency and
  6133. simplicity of specification, POSIX.1\(hy2008 does not permit this behavior.
  6134. .P
  6135. Historically, the
  6136. .BR z
  6137. command with a line specification of 1 ignored the command. For
  6138. consistency and simplicity of specification, POSIX.1\(hy2008 does not permit this
  6139. behavior.
  6140. .P
  6141. Historically, the
  6142. .BR z
  6143. command did not set the cursor column to the first non-\c
  6144. <blank>
  6145. for the character if the first screen was to be displayed, and was
  6146. already displayed. For consistency and simplicity of specification,
  6147. POSIX.1\(hy2008 does not permit this behavior.
  6148. .SS "Input Mode Commands in vi"
  6149. .P
  6150. Historical implementations of
  6151. .IR vi
  6152. did not permit the user to erase more than a single line of input,
  6153. or to use normal erase characters such as
  6154. .IR "line erase" ,
  6155. .IR worderase ,
  6156. and
  6157. .IR erase
  6158. to erase
  6159. .BR autoindent
  6160. characters. As there exist implementations of
  6161. .IR vi
  6162. that do not have these limitations, both behaviors are permitted, but
  6163. only historical practice is required. In the case of these extensions,
  6164. .IR vi
  6165. is required to pause at the
  6166. .BR autoindent
  6167. and previous line boundaries.
  6168. .P
  6169. Historical implementations of
  6170. .IR vi
  6171. updated only the portion of the screen where the current cursor
  6172. character was displayed. For example, consider the
  6173. .IR vi
  6174. input keystrokes:
  6175. .sp
  6176. .RS 4
  6177. .nf
  6178. iabcd<escape>0C<tab>
  6179. .fi
  6180. .P
  6181. .RE
  6182. .P
  6183. Historically, the
  6184. <tab>
  6185. would overwrite the characters
  6186. .BR \(dqabcd\(dq
  6187. when it was displayed. Other implementations replace only the
  6188. .BR 'a'
  6189. character with the
  6190. <tab>,
  6191. and then push the rest of the characters ahead of the cursor. Both
  6192. implementations have problems. The historical implementation is
  6193. probably visually nicer for the above example; however, for the
  6194. keystrokes:
  6195. .sp
  6196. .RS 4
  6197. .nf
  6198. iabcd<ESC>0R<tab><ESC>
  6199. .fi
  6200. .P
  6201. .RE
  6202. .P
  6203. the historical implementation results in the string
  6204. .BR \(dqbcd\(dq
  6205. disappearing and then magically reappearing when the
  6206. <ESC>
  6207. character is entered. POSIX.1\(hy2008 requires the former behavior when
  6208. overwriting erase-columns\(emthat is, overwriting characters that are no
  6209. longer logically part of the edit buffer\(emand the latter behavior
  6210. otherwise.
  6211. .P
  6212. Historical implementations of
  6213. .IR vi
  6214. discarded the
  6215. <control>\(hyD
  6216. and
  6217. <control>\(hyT
  6218. characters when they were entered at places where their command
  6219. functionality was not appropriate. POSIX.1\(hy2008 requires that the
  6220. <control>\(hyT
  6221. functionality always be available, and that
  6222. <control>\(hyD
  6223. be treated as any other key when not operating on
  6224. .BR autoindent
  6225. characters.
  6226. .SS "NUL"
  6227. .P
  6228. Some historical implementations of
  6229. .IR vi
  6230. limited the number of characters entered using the NUL input character
  6231. to 256 bytes. POSIX.1\(hy2008 permits this limitation; however, implementations
  6232. are encouraged to remove this limit.
  6233. .SS "<control>\(hyD"
  6234. .P
  6235. See also Rationale for the input mode command
  6236. <newline>.
  6237. The hidden assumptions in the
  6238. <control>\(hyD
  6239. command (and in the
  6240. .IR vi
  6241. .BR autoindent
  6242. specification in general) is that
  6243. <space>
  6244. characters take up a single column on the screen and that
  6245. <tab>
  6246. characters are comprised of an integral number of
  6247. <space>
  6248. characters.
  6249. .SS "<newline>"
  6250. .P
  6251. Implementations are permitted to rewrite
  6252. .BR autoindent
  6253. characters in the line when
  6254. <newline>,
  6255. <carriage-return>,
  6256. <control>\(hyD,
  6257. and
  6258. <control>\(hyT
  6259. are entered, or when the
  6260. .BR shift
  6261. commands are used, because historical implementations have both done so
  6262. and found it necessary to do so. For example, a
  6263. <control>\(hyD
  6264. when the cursor is preceded by a single
  6265. <tab>,
  6266. with
  6267. .BR tabstop
  6268. set to 8, and
  6269. .BR shiftwidth
  6270. set to 3, will result in the
  6271. <tab>
  6272. being replaced by several
  6273. <space>
  6274. characters.
  6275. .SS "<control>\(hyT"
  6276. .P
  6277. See also the Rationale for the input mode command
  6278. <newline>.
  6279. Historically,
  6280. <control>\(hyT
  6281. only worked if no non-\c
  6282. <blank>
  6283. characters had yet been input in the current input line. In addition,
  6284. the characters inserted by
  6285. <control>\(hyT
  6286. were treated as
  6287. .BR autoindent
  6288. characters, and could not be erased using normal user erase characters.
  6289. Because implementations exist that do not have these limitations, and
  6290. as moving to a column boundary is generally useful, POSIX.1\(hy2008 requires that
  6291. both limitations be removed.
  6292. .SS "<control>\(hyV"
  6293. .P
  6294. Historically,
  6295. .IR vi
  6296. used
  6297. .BR ^V ,
  6298. regardless of the value of the literal-next character of the terminal.
  6299. POSIX.1\(hy2008 requires conformance to historical practice.
  6300. .P
  6301. The uses described for
  6302. <control>\(hyV
  6303. can also be accomplished with
  6304. <control>\(hyQ,
  6305. which is useful on terminals that use
  6306. <control>\(hyV
  6307. for the down-arrow function. However, most historical implementations
  6308. use
  6309. <control>\(hyQ
  6310. for the
  6311. .IR termios
  6312. START character, so the editor will generally not receive the
  6313. <control>\(hyQ
  6314. unless
  6315. .BR "stty ixon"
  6316. mode is set to off. (In addition, some historical implementations of
  6317. .IR vi
  6318. explicitly set
  6319. .BR ixon
  6320. mode to on, so it was difficult for the user to set it to off.) Any of
  6321. the command characters described in POSIX.1\(hy2008 can be made ineffective by
  6322. their selection as
  6323. .IR termios
  6324. control characters, using the
  6325. .IR stty
  6326. utility or other methods described in the System Interfaces volume of POSIX.1\(hy2017.
  6327. .SS "<ESC>"
  6328. .P
  6329. Historically, SIGINT alerted the terminal when used to end input
  6330. mode. This behavior is permitted, but not required, by POSIX.1\(hy2008.
  6331. .SH "FUTURE DIRECTIONS"
  6332. None.
  6333. .SH "SEE ALSO"
  6334. .IR "\fIed\fR\^",
  6335. .IR "\fIex\fR\^",
  6336. .IR "\fIstty\fR\^"
  6337. .P
  6338. The Base Definitions volume of POSIX.1\(hy2017,
  6339. .IR "Section 12.2" ", " "Utility Syntax Guidelines"
  6340. .\"
  6341. .SH COPYRIGHT
  6342. Portions of this text are reprinted and reproduced in electronic form
  6343. from IEEE Std 1003.1-2017, Standard for Information Technology
  6344. -- Portable Operating System Interface (POSIX), The Open Group Base
  6345. Specifications Issue 7, 2018 Edition,
  6346. Copyright (C) 2018 by the Institute of
  6347. Electrical and Electronics Engineers, Inc and The Open Group.
  6348. In the event of any discrepancy between this version and the original IEEE and
  6349. The Open Group Standard, the original IEEE and The Open Group Standard
  6350. is the referee document. The original Standard can be obtained online at
  6351. http://www.opengroup.org/unix/online.html .
  6352. .PP
  6353. Any typographical or formatting errors that appear
  6354. in this page are most likely
  6355. to have been introduced during the conversion of the source files to
  6356. man page format. To report such errors, see
  6357. https://www.kernel.org/doc/man-pages/reporting_bugs.html .