isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

vi.html (183806B)


      1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved -->
      2 <!DOCTYPE HTML>
      3 <html lang="en">
      4 <head>
      5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0">
      6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 -->
      8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved -->
      9 <title>vi</title>
     10 </head>
     11 <body bgcolor="white">
     12 <div class="NAVHEADER">
     13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
     14 <tr class="nav">
     15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/val.html" accesskey="P">&lt;&lt;&lt;
     16 Previous</a></td>
     17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
     18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/wait.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
     19 </tr>
     20 </table>
     21 <hr align="left" width="100%"></div>
     22 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     23 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     24 IEEE Std 1003.1-2024<br>
     25 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     26 <hr size="2" noshade>
     27 <a name="top" id="top"></a> <a name="vi" id="vi"></a> <a name="tag_20_146" id="tag_20_146"></a><!-- vi -->
     28 <h4 class="mansect"><a name="tag_20_146_01" id="tag_20_146_01"></a>NAME</h4>
     29 <blockquote>vi — screen-oriented (visual) display editor</blockquote>
     30 <h4 class="mansect"><a name="tag_20_146_02" id="tag_20_146_02"></a>SYNOPSIS</h4>
     31 <blockquote class="synopsis">
     32 <div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt=
     33 "[Option Start]" border="0"> vi</tt> <b>[</b><tt>-rR</tt><b>] [</b><tt>-c</tt> <i>command</i><b>] [</b><tt>-t</tt>
     34 <i>tagstring</i><b>] [</b><tt>-w</tt> <i>size</i><b>] [</b><i>file</i><tt>...</tt><b>]</b> <tt><img src="../images/opt-end.gif"
     35 alt="[Option End]" border="0"></tt></code></div>
     36 </blockquote>
     37 <h4 class="mansect"><a name="tag_20_146_03" id="tag_20_146_03"></a>DESCRIPTION</h4>
     38 <blockquote>
     39 <p>This utility shall be provided on systems that both support the User Portability Utilities option and define the
     40 POSIX2_CHAR_TERM symbol. On other systems it is optional.</p>
     41 <p>The <i>vi</i> (visual) utility is a screen-oriented text editor. Only the open and visual modes of the editor are described in
     42 POSIX.1-2024; see the line editor <a href="../utilities/ex.html"><i>ex</i></a> for additional editing capabilities used in
     43 <i>vi</i>. The user can switch back and forth between <i>vi</i> and <a href="../utilities/ex.html"><i>ex</i></a> and execute
     44 <a href="../utilities/ex.html"><i>ex</i></a> commands from within <i>vi</i>.</p>
     45 <p>This reference page uses the term <i>edit buffer</i> to describe the current working text. No specific implementation is implied
     46 by this term. All editing changes are performed on the edit buffer, and no changes to it shall affect any file until an editor
     47 command writes the file.</p>
     48 <p>When using <i>vi</i>, the terminal screen acts as a window into the editing buffer. Changes made to the editing buffer shall be
     49 reflected in the screen display; the position of the cursor on the screen shall indicate the position within the editing
     50 buffer.</p>
     51 <p>Certain terminals do not have all the capabilities necessary to support the complete <i>vi</i> definition. When these commands
     52 cannot be supported on such terminals, this condition shall not produce an error message such as &quot;not an editor command&quot; or
     53 report a syntax error. The implementation may either accept the commands and produce results on the screen that are the result of
     54 an unsuccessful attempt to meet the requirements of this volume of POSIX.1-2024 or report an error describing the terminal-related
     55 deficiency.</p>
     56 </blockquote>
     57 <h4 class="mansect"><a name="tag_20_146_04" id="tag_20_146_04"></a>OPTIONS</h4>
     58 <blockquote>
     59 <p>The <i>vi</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     60 Guidelines</i></a> , except that <tt>'+'</tt> may be recognized as an option delimiter as well as <tt>'-'</tt>.</p>
     61 <p>The following options shall be supported:</p>
     62 <dl compact>
     63 <dd></dd>
     64 <dt><b>-c&nbsp;</b><i>command</i></dt>
     65 <dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-c</b> option.</dd>
     66 <dt><b>-r</b></dt>
     67 <dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-r</b> option.</dd>
     68 <dt><b>-R</b></dt>
     69 <dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-R</b> option.</dd>
     70 <dt><b>-t&nbsp;</b><i>tagstring</i></dt>
     71 <dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-t</b> option.</dd>
     72 <dt><b>-w&nbsp;</b><i>size</i></dt>
     73 <dd>See the <a href="../utilities/ex.html"><i>ex</i></a> command description of the <b>-w</b> option.</dd>
     74 </dl>
     75 </blockquote>
     76 <h4 class="mansect"><a name="tag_20_146_05" id="tag_20_146_05"></a>OPERANDS</h4>
     77 <blockquote>
     78 <p>See the OPERANDS section of the <a href="../utilities/ex.html"><i>ex</i></a> command for a description of the operands supported
     79 by the <i>vi</i> command.</p>
     80 </blockquote>
     81 <h4 class="mansect"><a name="tag_20_146_06" id="tag_20_146_06"></a>STDIN</h4>
     82 <blockquote>
     83 <p>If standard input is not a terminal device, the results are undefined. The standard input consists of a series of commands and
     84 input text, as described in the EXTENDED DESCRIPTION section.</p>
     85 <p>If a read from the standard input returns an error, or if the editor detects an end-of-file condition from the standard input,
     86 it shall be equivalent to a SIGHUP asynchronous event.</p>
     87 </blockquote>
     88 <h4 class="mansect"><a name="tag_20_146_07" id="tag_20_146_07"></a>INPUT FILES</h4>
     89 <blockquote>
     90 <p>See the INPUT FILES section of the <a href="../utilities/ex.html"><i>ex</i></a> command for a description of the input files
     91 supported by the <i>vi</i> command.</p>
     92 </blockquote>
     93 <h4 class="mansect"><a name="tag_20_146_08" id="tag_20_146_08"></a>ENVIRONMENT VARIABLES</h4>
     94 <blockquote>
     95 <p>See the ENVIRONMENT VARIABLES section of the <a href="../utilities/ex.html"><i>ex</i></a> command for the environment variables
     96 that affect the execution of the <i>vi</i> command.</p>
     97 </blockquote>
     98 <h4 class="mansect"><a name="tag_20_146_09" id="tag_20_146_09"></a>ASYNCHRONOUS EVENTS</h4>
     99 <blockquote>
    100 <p>See the ASYNCHRONOUS EVENTS section of the <a href="../utilities/ex.html"><i>ex</i></a> for the asynchronous events that affect
    101 the execution of the <i>vi</i> command.</p>
    102 </blockquote>
    103 <h4 class="mansect"><a name="tag_20_146_10" id="tag_20_146_10"></a>STDOUT</h4>
    104 <blockquote>
    105 <p>If standard output is not a terminal device, undefined results occur.</p>
    106 <p>Standard output may be used for writing prompts to the user, for informational messages, and for writing lines from the
    107 file.</p>
    108 </blockquote>
    109 <h4 class="mansect"><a name="tag_20_146_11" id="tag_20_146_11"></a>STDERR</h4>
    110 <blockquote>
    111 <p>If standard output is not a terminal device, undefined results occur.</p>
    112 <p>The standard error shall be used only for diagnostic messages.</p>
    113 </blockquote>
    114 <h4 class="mansect"><a name="tag_20_146_12" id="tag_20_146_12"></a>OUTPUT FILES</h4>
    115 <blockquote>
    116 <p>See the OUTPUT FILES section of the <a href="../utilities/ex.html"><i>ex</i></a> command for a description of the output files
    117 supported by the <i>vi</i> command.</p>
    118 </blockquote>
    119 <h4 class="mansect"><a name="tag_20_146_13" id="tag_20_146_13"></a>EXTENDED DESCRIPTION</h4>
    120 <blockquote>
    121 <p>If the terminal does not have the capabilities necessary to support an unspecified portion of the <i>vi</i> definition,
    122 implementations shall start initially in <a href="../utilities/ex.html"><i>ex</i></a> mode or open mode. Otherwise, after
    123 initialization, <i>vi</i> shall be in command mode; text input mode can be entered by one of several commands used to insert or
    124 change text. In text input mode, &lt;ESC&gt; can be used to return to command mode; other uses of &lt;ESC&gt; are described later
    125 in this section; see <a href="#tag_20_146_13_16">Terminate Command or Input Mode</a> .</p>
    126 <h5><a name="tag_20_146_13_01" id="tag_20_146_13_01"></a>Initialization in ex and vi</h5>
    127 <p>See <a href="../utilities/ex.html#tag_20_40_13_01"><i>Initialization in ex and vi</i></a> for a description of <a href=
    128 "../utilities/ex.html"><i>ex</i></a> and <i>vi</i> initialization for the <i>vi</i> utility.</p>
    129 <h5><a name="tag_20_146_13_02" id="tag_20_146_13_02"></a>Command Descriptions in vi</h5>
    130 <p>The following symbols are used in this reference page to represent arguments to commands.</p>
    131 <dl compact>
    132 <dd></dd>
    133 <dt><i>buffer</i></dt>
    134 <dd>See the description of <i>buffer</i> in the EXTENDED DESCRIPTION section of the <a href="../utilities/ex.html"><i>ex</i></a>
    135 utility; see <a href="../utilities/ex.html#tag_20_40_13_10"><i>Command Descriptions in ex</i></a> .
    136 <p>In open and visual mode, when a command synopsis shows both [<i>buffer</i>] and [<i>count</i>] preceding the command name, they
    137 can be specified in either order.</p>
    138 </dd>
    139 <dt><i>count</i></dt>
    140 <dd>A positive integer used as an optional argument to most commands, either to give a repeat count or as a size. This argument is
    141 optional and shall default to 1 unless otherwise specified.
    142 <p>The Synopsis lines for the <i>vi</i> commands &lt;control&gt;-G, &lt;control&gt;-L, &lt;control&gt;-R, &lt;control&gt;-],
    143 <b>%</b>, <b>&</b>, <b>^</b>, <b>D</b>, <b>m</b>, <b>M</b>, <b>Q</b>, <b>u</b>, <b>U</b>, and <b>ZZ</b> do not have <i>count</i> as
    144 an optional argument. Regardless, it shall not be an error to specify a <i>count</i> to these commands, and any specified
    145 <i>count</i> shall be ignored.</p>
    146 </dd>
    147 <dt><i>motion</i></dt>
    148 <dd>An optional trailing argument used by the <b>!</b>, <b>&lt;</b>, <b>&gt;</b>, <b>c</b>, <b>d</b>, and <b>y</b> commands, which
    149 is used to indicate the region of text that shall be affected by the command. The motion can be either one of the command
    150 characters repeated or one of several other <i>vi</i> commands (listed in the following table). Each of the applicable commands
    151 specifies the region of text matched by repeating the command; each command that can be used as a motion command specifies the
    152 region of text it affects.
    153 <p>Commands that take <i>motion</i> arguments operate on either lines or characters, depending on the circumstances. When operating
    154 on lines, all lines that fall partially or wholly within the text region specified for the command shall be affected. When
    155 operating on characters, only the exact characters in the specified text region shall be affected. Each motion command specifies
    156 this individually.</p>
    157 <p>When commands that may be motion commands are not used as motion commands, they shall set the current position to the current
    158 line and column as specified.</p>
    159 <p>The following commands shall be valid cursor motion commands:</p>
    160 <pre>
    161 <tt>&lt;apostrophe&gt;       (    -    j    H
    162 &lt;carriage-return&gt;  )    $    k    L
    163 &lt;comma&gt;            [[   %    l    M
    164 &lt;control&gt;-H        ]]   _    n    N
    165 &lt;control&gt;-N        {    ;    t    T
    166 &lt;control&gt;-P        }    ?    w    W
    167 &lt;grave-accent&gt;     ^    b    B
    168 &lt;newline&gt;          +    e    E
    169 &lt;space&gt;            |    f    F
    170 &lt;zero&gt;             /    h    G
    171 </tt></pre>
    172 <p>Any <i>count</i> that is specified to a command that has an associated motion command shall be applied to the motion command. If
    173 a <i>count</i> is applied to both the command and its associated motion command, the effect shall be multiplicative.</p>
    174 </dd>
    175 </dl>
    176 <p>The following symbols are used in this section to specify locations in the edit buffer:</p>
    177 <dl compact>
    178 <dd></dd>
    179 <dt><i>current&nbsp;character</i></dt>
    180 <dd><br>
    181 The character that is currently indicated by the cursor.</dd>
    182 <dt><i>end&nbsp;of&nbsp;a&nbsp;line</i></dt>
    183 <dd><br>
    184 The point located between the last non-&lt;newline&gt; (if any) and the terminating &lt;newline&gt; of a line. For an empty line,
    185 this location coincides with the beginning of the line.</dd>
    186 <dt><i>end&nbsp;of&nbsp;the&nbsp;edit&nbsp;buffer</i></dt>
    187 <dd><br>
    188 The location corresponding to the end of the last line in the edit buffer.</dd>
    189 </dl>
    190 <p>The following symbols are used in this section to specify command actions:</p>
    191 <dl compact>
    192 <dd></dd>
    193 <dt><i>bigword</i></dt>
    194 <dd>In the POSIX locale, <i>vi</i> shall recognize four kinds of <i>bigwords</i>:
    195 <ol>
    196 <li>
    197 <p>A maximal sequence of non-&lt;blank&gt; characters preceded and followed by &lt;blank&gt; characters or the beginning or end of
    198 a line or the edit buffer</p>
    199 </li>
    200 <li>
    201 <p>One or more sequential blank lines</p>
    202 </li>
    203 <li>
    204 <p>The first character in the edit buffer</p>
    205 </li>
    206 <li>
    207 <p>The last non-&lt;newline&gt; in the edit buffer</p>
    208 </li>
    209 </ol>
    210 </dd>
    211 <dt><i>word</i></dt>
    212 <dd>In the POSIX locale, <i>vi</i> shall recognize five kinds of words:
    213 <ol>
    214 <li>
    215 <p>A maximal sequence of letters, digits, and underscores, delimited at both ends by:</p>
    216 <ul>
    217 <li>
    218 <p>Characters other than letters, digits, or underscores</p>
    219 </li>
    220 <li>
    221 <p>The beginning or end of a line</p>
    222 </li>
    223 <li>
    224 <p>The beginning or end of the edit buffer</p>
    225 </li>
    226 </ul>
    227 </li>
    228 <li>
    229 <p>A maximal sequence of characters other than letters, digits, underscores, or &lt;blank&gt; characters, delimited at both ends
    230 by:</p>
    231 <ul>
    232 <li>
    233 <p>A letter, digit, underscore</p>
    234 </li>
    235 <li>
    236 <p>&lt;blank&gt; characters</p>
    237 </li>
    238 <li>
    239 <p>The beginning or end of a line</p>
    240 </li>
    241 <li>
    242 <p>The beginning or end of the edit buffer</p>
    243 </li>
    244 </ul>
    245 </li>
    246 <li>
    247 <p>One or more sequential blank lines</p>
    248 </li>
    249 <li>
    250 <p>The first character in the edit buffer</p>
    251 </li>
    252 <li>
    253 <p>The last non-&lt;newline&gt; in the edit buffer</p>
    254 </li>
    255 </ol>
    256 </dd>
    257 <dt><i>section&nbsp;boundary</i></dt>
    258 <dd><br>
    259 A <i>section boundary</i> is one of the following:
    260 <ol>
    261 <li>
    262 <p>A line whose first character is a &lt;form-feed&gt;</p>
    263 </li>
    264 <li>
    265 <p>A line whose first character is an open curly brace (<tt>'{'</tt>)</p>
    266 </li>
    267 <li>
    268 <p>A line whose first character is a &lt;period&gt; and whose second and third characters match a two-character pair in the
    269 <b>sections</b> edit option (see <a href="../utilities/ex.html"><i>ex</i></a>)</p>
    270 </li>
    271 <li>
    272 <p>A line whose first character is a &lt;period&gt; and whose only other character matches the first character of a two-character
    273 pair in the <b>sections</b> edit option, where the second character of the two-character pair is a &lt;space&gt;</p>
    274 </li>
    275 <li>
    276 <p>The first line of the edit buffer</p>
    277 </li>
    278 <li>
    279 <p>The last line of the edit buffer if the last line of the edit buffer is empty or if it is a <b>]]</b> or <b>}</b> command;
    280 otherwise, the last non-&lt;newline&gt; of the last line of the edit buffer</p>
    281 </li>
    282 </ol>
    283 </dd>
    284 <dt><i>paragraph&nbsp;boundary</i></dt>
    285 <dd><br>
    286 A <i>paragraph boundary</i> is one of the following:
    287 <ol>
    288 <li>
    289 <p>A section boundary</p>
    290 </li>
    291 <li>
    292 <p>A line whose first character is a &lt;period&gt; and whose second and third characters match a two-character pair in the
    293 <b>paragraphs</b> edit option (see <a href="../utilities/ex.html"><i>ex</i></a>)</p>
    294 </li>
    295 <li>
    296 <p>A line whose first character is a &lt;period&gt; and whose only other character matches the first character of a two-character
    297 pair in the <i>paragraphs</i> edit option, where the second character of the two-character pair is a &lt;space&gt;</p>
    298 </li>
    299 <li>
    300 <p>One or more sequential blank lines</p>
    301 </li>
    302 </ol>
    303 </dd>
    304 <dt><i>remembered&nbsp;search&nbsp;direction</i></dt>
    305 <dd><br>
    306 See the description of <i>remembered search direction</i> in <a href="../utilities/ex.html"><i>ex</i></a>.</dd>
    307 <dt><i>sentence&nbsp;boundary</i></dt>
    308 <dd><br>
    309 A <i>sentence boundary</i> is one of the following:
    310 <ol>
    311 <li>
    312 <p>A paragraph boundary</p>
    313 </li>
    314 <li>
    315 <p>The first non-&lt;blank&gt; that occurs after a paragraph boundary</p>
    316 </li>
    317 <li>
    318 <p>The first non-&lt;blank&gt; that occurs after a &lt;period&gt; (<tt>'.'</tt>), &lt;exclamation-mark&gt; (<tt>'!'</tt>), or
    319 &lt;question-mark&gt; (<tt>'?'</tt>), followed by two &lt;space&gt; characters or the end of a line; any number of closing
    320 parenthesis (<tt>')'</tt>), closing brackets (<tt>']'</tt>), double-quote (<tt>'"'</tt> ), or single-quote (&lt;apostrophe&gt;)
    321 characters can appear between the punctuation mark and the two &lt;space&gt; characters or end-of-line</p>
    322 </li>
    323 </ol>
    324 </dd>
    325 </dl>
    326 <p>In the remainder of the description of the <i>vi</i> utility, the term &quot;buffer line&quot; refers to a line in the edit buffer and
    327 the term &quot;display line&quot; refers to the line or lines on the display screen used to display one buffer line. The term &quot;current
    328 line&quot; refers to a specific &quot;buffer line&quot;.</p>
    329 <p>If there are display lines on the screen for which there are no corresponding buffer lines because they correspond to lines that
    330 would be after the end of the file, they shall be displayed as a single &lt;tilde&gt; (<tt>'~'</tt>) character, plus the
    331 terminating &lt;newline&gt;.</p>
    332 <p>The last line of the screen shall be used to report errors or display informational messages. It shall also be used to display
    333 the input for &quot;line-oriented commands&quot; (<b>/</b>, <b>?</b>, <b>:</b>, and <b>!</b>). When a line-oriented command is executed,
    334 the editor shall enter text input mode on the last line on the screen, using the respective command characters as prompt
    335 characters. (In the case of the <b>!</b> command, the associated motion shall be entered by the user before the editor enters text
    336 input mode.) The line entered by the user shall be terminated by a &lt;newline&gt;, a non-&lt;control&gt;-V-escaped
    337 &lt;carriage-return&gt;, or unescaped &lt;ESC&gt;. It is unspecified if more characters than require a display width minus one
    338 column number of screen columns can be entered.</p>
    339 <p>If any command is executed that overwrites a portion of the screen other than the last line of the screen (for example, the
    340 <a href="../utilities/ex.html"><i>ex</i></a> <b>suspend</b> or <b>!</b> commands), other than the <a href=
    341 "../utilities/ex.html"><i>ex</i></a> <b>shell</b> command, the user shall be prompted for a character before the screen is
    342 refreshed and the edit session continued.</p>
    343 <p>&lt;tab&gt; characters shall take up the number of columns on the screen set by the <b>tabstop</b> edit option (see <a href=
    344 "../utilities/ex.html"><i>ex</i></a>), unless there are less than that number of columns before the display margin that will cause
    345 the displayed line to be folded; in this case, they shall only take up the number of columns up to that boundary.</p>
    346 <p>The cursor shall be placed on the current line and relative to the current column as specified by each command described in the
    347 following sections.</p>
    348 <p>In open mode, if the current line is not already displayed, then it shall be displayed.</p>
    349 <p>In visual mode, if the current line is not displayed, then the lines that are displayed shall be expanded, scrolled, or redrawn
    350 to cause an unspecified portion of the current line to be displayed. If the screen is redrawn, no more than the number of display
    351 lines specified by the value of the <b>window</b> edit option shall be displayed (unless the current line cannot be completely
    352 displayed in the number of display lines specified by the <b>window</b> edit option) and the current line shall be positioned as
    353 close to the center of the displayed lines as possible (within the constraints imposed by the distance of the line from the
    354 beginning or end of the edit buffer). If the current line is before the first line in the display and the screen is scrolled, an
    355 unspecified portion of the current line shall be placed on the first line of the display. If the current line is after the last
    356 line in the display and the screen is scrolled, an unspecified portion of the current line shall be placed on the last line of the
    357 display.</p>
    358 <p>In visual mode, if a line from the edit buffer (other than the current line) does not entirely fit into the lines at the bottom
    359 of the display that are available for its presentation, the editor may choose not to display any portion of the line. The lines of
    360 the display that do not contain text from the edit buffer for this reason shall each consist of a single <tt>'@'</tt>
    361 character.</p>
    362 <p>In visual mode, the editor may choose for unspecified reasons to not update lines in the display to correspond to the underlying
    363 edit buffer text. The lines of the display that do not correctly correspond to text from the edit buffer for this reason shall
    364 consist of a single <tt>'@'</tt> character (plus the terminating &lt;newline&gt;), and the &lt;control&gt;-R command shall cause
    365 the editor to update the screen to correctly represent the edit buffer.</p>
    366 <p>Open and visual mode commands that set the current column set it to a column position in the display, and not a character
    367 position in the line. In this case, however, the column position in the display shall be calculated for an infinite width display;
    368 for example, the column related to a character that is part of a line that has been folded onto additional screen lines is offset
    369 from the display line column where the buffer line begins, not from the beginning of a particular display line.</p>
    370 <p>The display cursor column in the display is based on the value of the current column, as follows, with each rule applied in
    371 turn:</p>
    372 <ol>
    373 <li>
    374 <p>If the current column is after the last display line column used by the displayed line, the display cursor column shall be set
    375 to the last display line column occupied by the last non-&lt;newline&gt; in the current line; otherwise, the display cursor column
    376 shall be set to the current column.</p>
    377 </li>
    378 <li>
    379 <p>If the character of which some portion is displayed in the display line column specified by the display cursor column requires
    380 more than a single display line column:</p>
    381 <ol type="a">
    382 <li>
    383 <p>If in text input mode, the display cursor column shall be adjusted to the first display line column in which any portion of that
    384 character is displayed.</p>
    385 </li>
    386 <li>
    387 <p>Otherwise, the display cursor column shall be adjusted to the last display line column in which any portion of that character is
    388 displayed.</p>
    389 </li>
    390 </ol>
    391 </li>
    392 </ol>
    393 <p>The current column shall not be changed by these adjustments to the display cursor column.</p>
    394 <p>If an error occurs during the parsing or execution of a <i>vi</i> command:</p>
    395 <ul>
    396 <li>
    397 <p>The terminal shall be alerted. Execution of the <i>vi</i> command shall stop, and the cursor (for example, the current line and
    398 column) shall not be further modified.</p>
    399 </li>
    400 <li>
    401 <p>Unless otherwise specified by the following command sections, it is unspecified whether an informational message shall be
    402 displayed.</p>
    403 </li>
    404 <li>
    405 <p>Any partially entered <i>vi</i> command shall be discarded.</p>
    406 </li>
    407 <li>
    408 <p>If the <i>vi</i> command resulted from a <b>map</b> expansion, all characters from that <b>map</b> expansion shall be discarded,
    409 except as otherwise specified by the <b>map</b> command (see <a href="../utilities/ex.html"><i>ex</i></a>).</p>
    410 </li>
    411 <li>
    412 <p>If the <i>vi</i> command resulted from the execution of a buffer, no further commands caused by the execution of the buffer
    413 shall be executed.</p>
    414 </li>
    415 </ul>
    416 <h5><a name="tag_20_146_13_03" id="tag_20_146_13_03"></a>Page Backwards</h5>
    417 <dl compact>
    418 <dd></dd>
    419 <dt><i>Synopsis</i>:</dt>
    420 <dd>
    421 <pre>
    422 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-B
    423 </tt></pre></dd>
    424 </dl>
    425 <p>If in open mode, the &lt;control&gt;-B command shall behave identically to the <b>z</b> command. Otherwise, if the current line
    426 is the first line of the edit buffer, it shall be an error.</p>
    427 <p>If the <b>window</b> edit option is less than 3, display a screen where the last line of the display shall be some portion
    428 of:</p>
    429 <pre>
    430 <tt>(</tt><i>current first line</i><tt>) -1
    431 </tt></pre>
    432 <p>otherwise, display a screen where the first line of the display shall be some portion of:</p>
    433 <pre>
    434 <tt>(</tt><i>current first line</i><tt>) - </tt><i>count</i><tt> x ((window edit option) -2)
    435 </tt></pre>
    436 <p>If this calculation would result in a line that is before the first line of the edit buffer, the first line of the display shall
    437 display some portion of the first line of the edit buffer.</p>
    438 <p><i>Current line</i>: If no lines from the previous display remain on the screen, set to the last line of the display; otherwise,
    439 set to (<i>line</i> - the number of new lines displayed on this screen).</p>
    440 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
    441 <h5><a name="tag_20_146_13_04" id="tag_20_146_13_04"></a>Scroll Forward</h5>
    442 <dl compact>
    443 <dd></dd>
    444 <dt><i>Synopsis</i>:</dt>
    445 <dd>
    446 <pre>
    447 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-D
    448 </tt></pre></dd>
    449 </dl>
    450 <p>If the current line is the last line of the edit buffer, it shall be an error.</p>
    451 <p>If no <i>count</i> is specified, <i>count</i> shall default to the <i>count</i> associated with the previous &lt;control&gt;-D
    452 or &lt;control&gt;-U command. If there was no previous &lt;control&gt;-D or &lt;control&gt;-U command, <i>count</i> shall default
    453 to the value of the <b>scroll</b> edit option.</p>
    454 <p>If in open mode, write lines starting with the line after the current line, until <i>count</i> lines or the last line of the
    455 file have been written.</p>
    456 <p><i>Current line</i>: If the current line + <i>count</i> is past the last line of the edit buffer, set to the last line of the
    457 edit buffer; otherwise, set to the current line + <i>count</i>.</p>
    458 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
    459 <h5><a name="tag_20_146_13_05" id="tag_20_146_13_05"></a>Scroll Forward by Line</h5>
    460 <dl compact>
    461 <dd></dd>
    462 <dt><i>Synopsis</i>:</dt>
    463 <dd>
    464 <pre>
    465 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-E
    466 </tt></pre></dd>
    467 </dl>
    468 <p>Display the line count lines after the last line currently displayed.</p>
    469 <p>If the last line of the edit buffer is displayed, it shall be an error. If there is no line <i>count</i> lines after the last
    470 line currently displayed, the last line of the display shall display some portion of the last line of the edit buffer.</p>
    471 <p><i>Current line</i>: Unchanged if the previous current character is displayed; otherwise, set to the first line displayed.</p>
    472 <p><i>Current column</i>: Unchanged.</p>
    473 <h5><a name="tag_20_146_13_06" id="tag_20_146_13_06"></a>Page Forward</h5>
    474 <dl compact>
    475 <dd></dd>
    476 <dt><i>Synopsis</i>:</dt>
    477 <dd>
    478 <pre>
    479 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-F
    480 </tt></pre></dd>
    481 </dl>
    482 <p>If in open mode, the &lt;control&gt;-F command shall behave identically to the <b>z</b> command. Otherwise, if the current line
    483 is the last line of the edit buffer, it shall be an error.</p>
    484 <p>If the <b>window</b> edit option is less than 3, display a screen where the first line of the display shall be some portion
    485 of:</p>
    486 <pre>
    487 <tt>(</tt><i>current last line</i><tt>) +1
    488 </tt></pre>
    489 <p>otherwise, display a screen where the first line of the display shall be some portion of:</p>
    490 <pre>
    491 <tt>(</tt><i>current first line</i><tt>) + </tt><i>count</i><tt> x ((window edit option) -2)
    492 </tt></pre>
    493 <p>If this calculation would result in a line that is after the last line of the edit buffer, the last line of the display shall
    494 display some portion of the last line of the edit buffer.</p>
    495 <p><i>Current line</i>: If no lines from the previous display remain on the screen, set to the first line of the display;
    496 otherwise, set to (<i>line</i> + the number of new lines displayed on this screen).</p>
    497 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
    498 <h5><a name="tag_20_146_13_07" id="tag_20_146_13_07"></a>Display Information</h5>
    499 <dl compact>
    500 <dd></dd>
    501 <dt><i>Synopsis</i>:</dt>
    502 <dd>
    503 <pre>
    504 <tt>&lt;control&gt;-G
    505 </tt></pre></dd>
    506 </dl>
    507 <p>This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>file</b> command.</p>
    508 <h5><a name="tag_20_146_13_08" id="tag_20_146_13_08"></a>Move Cursor Backwards</h5>
    509 <dl compact>
    510 <dd></dd>
    511 <dt><i>Synopsis</i>:</dt>
    512 <dd>
    513 <pre>
    514 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-H
    515 <br>
    516 </tt><b>[</b><i>count</i><b>]</b><tt> h
    517 <br>
    518 the current </tt><i>erase</i><tt> character (see stty)
    519 </tt></pre></dd>
    520 </dl>
    521 <p>If there are no characters before the current character on the current line, it shall be an error. If there are less than
    522 <i>count</i> previous characters on the current line, <i>count</i> shall be adjusted to the number of previous characters on the
    523 line.</p>
    524 <p>If used as a motion command:</p>
    525 <ol>
    526 <li>
    527 <p>The text region shall be from the character before the starting cursor up to and including the <i>count</i>th character before
    528 the starting cursor.</p>
    529 </li>
    530 <li>
    531 <p>Any text copied to a buffer shall be in character mode.</p>
    532 </li>
    533 </ol>
    534 <p>If not used as a motion command:</p>
    535 <p><i>Current line</i>: Unchanged.</p>
    536 <p><i>Current column</i>: Set to (<i>column</i> - the number of columns occupied by <i>count</i> characters ending with the
    537 previous current column).</p>
    538 <h5><a name="tag_20_146_13_09" id="tag_20_146_13_09"></a>Move Down</h5>
    539 <dl compact>
    540 <dd></dd>
    541 <dt><i>Synopsis</i>:</dt>
    542 <dd>
    543 <pre>
    544 <b>[</b><i>count</i><b>]</b><tt> &lt;newline&gt;
    545 <br>
    546 </tt><b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-J
    547 <br>
    548 </tt><b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-M
    549 <br>
    550 </tt><b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-N
    551 <br>
    552 </tt><b>[</b><i>count</i><b>]</b><tt> j
    553 <br>
    554 </tt><b>[</b><i>count</i><b>]</b><tt> &lt;carriage-return&gt;
    555 <br>
    556 </tt><b>[</b><i>count</i><b>]</b><tt> +
    557 </tt></pre></dd>
    558 </dl>
    559 <p>If there are less than <i>count</i> lines after the current line in the edit buffer, it shall be an error.</p>
    560 <p>If used as a motion command:</p>
    561 <ol>
    562 <li>
    563 <p>The text region shall include the starting line and the next <i>count</i> - 1 lines.</p>
    564 </li>
    565 <li>
    566 <p>Any text copied to a buffer shall be in line mode.</p>
    567 </li>
    568 </ol>
    569 <p>If not used as a motion command:</p>
    570 <p><i>Current line</i>: Set to <i>current line</i>+ <i>count</i>.</p>
    571 <p><i>Current column</i>: Set to non-&lt;blank&gt; for the &lt;carriage-return&gt;, &lt;control&gt;-M, and <b>+</b> commands;
    572 otherwise, unchanged.</p>
    573 <h5><a name="tag_20_146_13_10" id="tag_20_146_13_10"></a>Clear and Redisplay</h5>
    574 <dl compact>
    575 <dd></dd>
    576 <dt><i>Synopsis</i>:</dt>
    577 <dd>
    578 <pre>
    579 <tt>&lt;control&gt;-L
    580 </tt></pre></dd>
    581 </dl>
    582 <p>If in open mode, clear the screen and redisplay the current line. Otherwise, clear and redisplay the screen.</p>
    583 <p><i>Current line</i>: Unchanged.</p>
    584 <p><i>Current column</i>: Unchanged.</p>
    585 <h5><a name="tag_20_146_13_11" id="tag_20_146_13_11"></a>Move Up</h5>
    586 <dl compact>
    587 <dd></dd>
    588 <dt><i>Synopsis</i>:</dt>
    589 <dd>
    590 <pre>
    591 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-P
    592 <br>
    593 </tt><b>[</b><i>count</i><b>]</b><tt> k
    594 <br>
    595 </tt><b>[</b><i>count</i><b>]</b><tt> -
    596 </tt></pre></dd>
    597 </dl>
    598 <p>If there are less than <i>count</i> lines before the current line in the edit buffer, it shall be an error.</p>
    599 <p>If used as a motion command:</p>
    600 <ol>
    601 <li>
    602 <p>The text region shall include the starting line and the previous <i>count</i> lines.</p>
    603 </li>
    604 <li>
    605 <p>Any text copied to a buffer shall be in line mode.</p>
    606 </li>
    607 </ol>
    608 <p>If not used as a motion command:</p>
    609 <p><i>Current line</i>: Set to <i>current line</i> - <i>count</i>.</p>
    610 <p><i>Current column</i>: Set to non-&lt;blank&gt; for the <b>-</b> command; otherwise, unchanged.</p>
    611 <h5><a name="tag_20_146_13_12" id="tag_20_146_13_12"></a>Redraw Screen</h5>
    612 <dl compact>
    613 <dd></dd>
    614 <dt><i>Synopsis</i>:</dt>
    615 <dd>
    616 <pre>
    617 <tt>&lt;control&gt;-R
    618 </tt></pre></dd>
    619 </dl>
    620 <p>If any lines have been deleted from the display screen and flagged as deleted on the terminal using the <b>@</b> convention (see
    621 the beginning of the EXTENDED DESCRIPTION section), they shall be redisplayed to match the contents of the edit buffer.</p>
    622 <p>It is unspecified whether lines flagged with <b>@</b> because they do not fit on the terminal display shall be affected.</p>
    623 <p><i>Current line</i>: Unchanged.</p>
    624 <p><i>Current column</i>: Unchanged.</p>
    625 <h5><a name="tag_20_146_13_13" id="tag_20_146_13_13"></a>Scroll Backward</h5>
    626 <dl compact>
    627 <dd></dd>
    628 <dt><i>Synopsis</i>:</dt>
    629 <dd>
    630 <pre>
    631 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-U
    632 </tt></pre></dd>
    633 </dl>
    634 <p>If the current line is the first line of the edit buffer, it shall be an error.</p>
    635 <p>If no <i>count</i> is specified, <i>count</i> shall default to the <i>count</i> associated with the previous &lt;control&gt;-D
    636 or &lt;control&gt;-U command. If there was no previous &lt;control&gt;-D or &lt;control&gt;-U command, <i>count</i> shall default
    637 to the value of the <b>scroll</b> edit option.</p>
    638 <p><i>Current line</i>: If <i>count</i> is greater than the current line, set to 1; otherwise, set to the current line -
    639 <i>count</i>.</p>
    640 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
    641 <h5><a name="tag_20_146_13_14" id="tag_20_146_13_14"></a>Scroll Backward by Line</h5>
    642 <dl compact>
    643 <dd></dd>
    644 <dt><i>Synopsis</i>:</dt>
    645 <dd>
    646 <pre>
    647 <b>[</b><i>count</i><b>]</b><tt> &lt;control&gt;-Y
    648 </tt></pre></dd>
    649 </dl>
    650 <p>Display the line <i>count</i> lines before the first line currently displayed.</p>
    651 <p>If the current line is the first line of the edit buffer, it shall be an error. If this calculation would result in a line that
    652 is before the first line of the edit buffer, the first line of the display shall display some portion of the first line of the edit
    653 buffer.</p>
    654 <p><i>Current line</i>: Unchanged if the previous current character is displayed; otherwise, set to the first line displayed.</p>
    655 <p><i>Current column</i>: Unchanged.</p>
    656 <h5><a name="tag_20_146_13_15" id="tag_20_146_13_15"></a>Edit the Alternate File</h5>
    657 <dl compact>
    658 <dd></dd>
    659 <dt><i>Synopsis</i>:</dt>
    660 <dd>
    661 <pre>
    662 <tt>&lt;control&gt;-^
    663 </tt></pre></dd>
    664 </dl>
    665 This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>edit</b> command, with the alternate
    666 pathname as its argument.
    667 <h5><a name="tag_20_146_13_16" id="tag_20_146_13_16"></a>Terminate Command or Input Mode</h5>
    668 <dl compact>
    669 <dd></dd>
    670 <dt><i>Synopsis</i>:</dt>
    671 <dd>
    672 <pre>
    673 <tt>&lt;ESC&gt;
    674 </tt></pre></dd>
    675 </dl>
    676 <p>If a partial <i>vi</i> command (as defined by at least one, non-<i>count</i> character) has been entered, discard the
    677 <i>count</i> and the command character(s).</p>
    678 <p>Otherwise, if no command characters have been entered, and the &lt;ESC&gt; was the result of a map expansion, the terminal shall
    679 be alerted and the &lt;ESC&gt; character shall be discarded, but it shall not be an error.</p>
    680 <p>Otherwise, it shall be an error.</p>
    681 <p><i>Current line</i>: Unchanged.</p>
    682 <p><i>Current column</i>: Unchanged.</p>
    683 <h5><a name="tag_20_146_13_17" id="tag_20_146_13_17"></a>Search for tagstring</h5>
    684 <dl compact>
    685 <dd></dd>
    686 <dt><i>Synopsis</i>:</dt>
    687 <dd>
    688 <pre>
    689 <tt>&lt;control&gt;-]
    690 </tt></pre></dd>
    691 </dl>
    692 <p>If the current character is not a word or &lt;blank&gt;, it shall be an error.</p>
    693 <p>This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>tag</b> command, with the argument to
    694 that command defined as follows.</p>
    695 <p>If the current character is a &lt;blank&gt;:</p>
    696 <ol>
    697 <li>
    698 <p>Skip all &lt;blank&gt; characters after the cursor up to the end of the line.</p>
    699 </li>
    700 <li>
    701 <p>If the end of the line is reached, it shall be an error.</p>
    702 </li>
    703 </ol>
    704 <p>Then, the argument to the <a href="../utilities/ex.html"><i>ex</i></a> <b>tag</b> command shall be the current character and all
    705 subsequent characters, up to the first non-word character or the end of the line.</p>
    706 <h5><a name="tag_20_146_13_18" id="tag_20_146_13_18"></a>Move Cursor Forward</h5>
    707 <dl compact>
    708 <dd></dd>
    709 <dt><i>Synopsis</i>:</dt>
    710 <dd>
    711 <pre>
    712 <b>[</b><i>count</i><b>]</b><tt> &lt;space&gt;
    713 <br>
    714 </tt><b>[</b><i>count</i><b>]</b><tt> l</tt>  (ell)<tt>
    715 </tt></pre></dd>
    716 </dl>
    717 <p>If there are less than <i>count</i> non-&lt;newline&gt; characters after the cursor on the current line, <i>count</i> shall be
    718 adjusted to the number of non-&lt;newline&gt; characters after the cursor on the line.</p>
    719 <p>If used as a motion command:</p>
    720 <ol>
    721 <li>
    722 <p>If the current or <i>count</i>th character after the cursor is the last non-&lt;newline&gt; in the line, the text region shall
    723 be comprised of the current character up to and including the last non-&lt;newline&gt; in the line. Otherwise, the text region
    724 shall be from the current character up to, but not including, the <i>count</i>th character after the cursor.</p>
    725 </li>
    726 <li>
    727 <p>Any text copied to a buffer shall be in character mode.</p>
    728 </li>
    729 </ol>
    730 <p>If not used as a motion command:</p>
    731 <p>If there are no non-&lt;newline&gt; characters after the current character on the current line, it shall be an error.</p>
    732 <p><i>Current line</i>: Unchanged.</p>
    733 <p><i>Current column</i>: Set to the last column that displays any portion of the <i>count</i>th character after the current
    734 character.</p>
    735 <h5><a name="tag_20_146_13_19" id="tag_20_146_13_19"></a>Replace Text with Results from Shell Command</h5>
    736 <dl compact>
    737 <dd></dd>
    738 <dt><i>Synopsis</i>:</dt>
    739 <dd>
    740 <pre>
    741 <b>[</b><i>count</i><b>]</b><tt> ! </tt><i>motion shell-commands</i><tt> &lt;newline&gt;
    742 </tt></pre></dd>
    743 </dl>
    744 <p>If the motion command is the <b>!</b> command repeated:</p>
    745 <ol>
    746 <li>
    747 <p>If the edit buffer is empty and no <i>count</i> was supplied, the command shall be the equivalent of the <a href=
    748 "../utilities/ex.html"><i>ex</i></a> <b>:read</b> <b>!</b> command, with the text input, and no text shall be copied to any
    749 buffer.</p>
    750 </li>
    751 <li>
    752 <p>Otherwise:</p>
    753 <ol type="a">
    754 <li>
    755 <p>If there are less than <i>count</i> -1 lines after the current line in the edit buffer, it shall be an error.</p>
    756 </li>
    757 <li>
    758 <p>The text region shall be from the current line up to and including the next <i>count</i> -1 lines.</p>
    759 </li>
    760 </ol>
    761 </li>
    762 </ol>
    763 <p>Otherwise, the text region shall be the lines in which any character of the text region specified by the motion command
    764 appear.</p>
    765 <p>Any text copied to a buffer shall be in line mode.</p>
    766 <p>This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>!</b> command for the specified
    767 lines.</p>
    768 <h5><a name="tag_20_146_13_20" id="tag_20_146_13_20"></a>Move Cursor to End-of-Line</h5>
    769 <dl compact>
    770 <dd></dd>
    771 <dt><i>Synopsis</i>:</dt>
    772 <dd>
    773 <pre>
    774 <b>[</b><i>count</i><b>]</b><tt> $
    775 </tt></pre></dd>
    776 </dl>
    777 <p>It shall be an error if there are less than (<i>count</i> -1) lines after the current line in the edit buffer.</p>
    778 <p>If used as a motion command:</p>
    779 <ol>
    780 <li>
    781 <p>If <i>count</i> is 1:</p>
    782 <ol type="a">
    783 <li>
    784 <p>It shall be an error if the line is empty.</p>
    785 </li>
    786 <li>
    787 <p>Otherwise, the text region shall consist of all characters from the starting cursor to the last non-&lt;newline&gt; in the line,
    788 inclusive, and any text copied to a buffer shall be in character mode.</p>
    789 </li>
    790 </ol>
    791 </li>
    792 <li>
    793 <p>Otherwise, if the starting cursor position is at or before the first non-&lt;blank&gt; in the line, the text region shall
    794 consist of the current and the next <i>count</i> -1 lines, and any text saved to a buffer shall be in line mode.</p>
    795 </li>
    796 <li>
    797 <p>Otherwise, the text region shall consist of all characters from the starting cursor to the last non-&lt;newline&gt; in the line
    798 that is <i>count</i> -1 lines forward from the current line, and any text copied to a buffer shall be in character mode.</p>
    799 </li>
    800 </ol>
    801 <p>If not used as a motion command:</p>
    802 <p><i>Current line</i>: Set to the <i>current line</i> + <i>count</i>-1.</p>
    803 <p><i>Current column</i>: The current column is set to the last display line column of the last non-&lt;newline&gt; in the line, or
    804 column position 1 if the line is empty.</p>
    805 <p>The current column shall be adjusted to be on the last display line column of the last non-&lt;newline&gt; of the current line
    806 as subsequent commands change the current line, until a command changes the current column.</p>
    807 <h5><a name="tag_20_146_13_21" id="tag_20_146_13_21"></a>Move to Matching Character</h5>
    808 <dl compact>
    809 <dd></dd>
    810 <dt><i>Synopsis</i>:</dt>
    811 <dd>
    812 <pre>
    813 <tt>%
    814 </tt></pre></dd>
    815 </dl>
    816 <p>If the character at the current position is not a parenthesis, bracket, or curly brace, search forward in the line to the first
    817 one of those characters. If no such character is found, it shall be an error.</p>
    818 <p>The matching character shall be the parenthesis, bracket, or curly brace matching the parenthesis, bracket, or curly brace,
    819 respectively, that was at the current position or that was found on the current line.</p>
    820 <p>Matching shall be determined as follows, for an open parenthesis:</p>
    821 <ol>
    822 <li>
    823 <p>Set a counter to 1.</p>
    824 </li>
    825 <li>
    826 <p>Search forwards until a parenthesis is found or the end of the edit buffer is reached.</p>
    827 </li>
    828 <li>
    829 <p>If the end of the edit buffer is reached, it shall be an error.</p>
    830 </li>
    831 <li>
    832 <p>If an open parenthesis is found, increment the counter by 1.</p>
    833 </li>
    834 <li>
    835 <p>If a close parenthesis is found, decrement the counter by 1.</p>
    836 </li>
    837 <li>
    838 <p>If the counter is zero, the current character is the matching character.</p>
    839 </li>
    840 </ol>
    841 <p>Matching for a close parenthesis shall be equivalent, except that the search shall be backwards, from the starting character to
    842 the beginning of the buffer, a close parenthesis shall increment the counter by 1, and an open parenthesis shall decrement the
    843 counter by 1.</p>
    844 <p>Matching for brackets and curly braces shall be equivalent, except that searching shall be done for open and close brackets or
    845 open and close curly braces. It is implementation-defined whether other characters are searched for and matched as well.</p>
    846 <p>If used as a motion command:</p>
    847 <ol>
    848 <li>
    849 <p>If the matching cursor was after the starting cursor in the edit buffer, and the starting cursor position was at or before the
    850 first non-&lt;blank&gt; non-&lt;newline&gt; in the starting line, and the matching cursor position was at or after the last
    851 non-&lt;blank&gt; non-&lt;newline&gt; in the matching line, the text region shall consist of the current line to the matching line,
    852 inclusive, and any text copied to a buffer shall be in line mode.</p>
    853 </li>
    854 <li>
    855 <p>If the matching cursor was before the starting cursor in the edit buffer, and the starting cursor position was at or after the
    856 last non-&lt;blank&gt; non-&lt;newline&gt; in the starting line, and the matching cursor position was at or before the first
    857 non-&lt;blank&gt; non-&lt;newline&gt; in the matching line, the text region shall consist of the current line to the matching line,
    858 inclusive, and any text copied to a buffer shall be in line mode.</p>
    859 </li>
    860 <li>
    861 <p>Otherwise, the text region shall consist of the starting character to the matching character, inclusive, and any text copied to
    862 a buffer shall be in character mode.</p>
    863 </li>
    864 </ol>
    865 <p>If not used as a motion command:</p>
    866 <p><i>Current line</i>: Set to the line where the matching character is located.</p>
    867 <p><i>Current column</i>: Set to the last column where any portion of the matching character is displayed.</p>
    868 <h5><a name="tag_20_146_13_22" id="tag_20_146_13_22"></a>Repeat Substitution</h5>
    869 <dl compact>
    870 <dd></dd>
    871 <dt><i>Synopsis</i>:</dt>
    872 <dd>
    873 <pre>
    874 <tt>&
    875 </tt></pre></dd>
    876 </dl>
    877 <p>Repeat the previous substitution command. This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a>
    878 <b>&</b> command with the current line as its addresses, and without <i>options</i>, <i>count</i>, or <i>flags</i>.</p>
    879 <h5><a name="tag_20_146_13_23" id="tag_20_146_13_23"></a>Return to Previous Context at Beginning of Line</h5>
    880 <dl compact>
    881 <dd></dd>
    882 <dt><i>Synopsis</i>:</dt>
    883 <dd>
    884 <pre>
    885 <tt>' </tt><i>character</i><tt>
    886 </tt></pre></dd>
    887 </dl>
    888 <p>It shall be an error if there is no line in the edit buffer marked by <i>character</i>.</p>
    889 <p>If used as a motion command:</p>
    890 <ol>
    891 <li>
    892 <p>If the starting cursor is after the marked cursor, then the locations of the starting cursor and the marked cursor in the edit
    893 buffer shall be logically swapped.</p>
    894 </li>
    895 <li>
    896 <p>The text region shall consist of the starting line up to and including the marked line, and any text copied to a buffer shall be
    897 in line mode.</p>
    898 </li>
    899 </ol>
    900 <p>If not used as a motion command:</p>
    901 <p><i>Current line</i>: Set to the line referenced by the mark.</p>
    902 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
    903 <h5><a name="tag_20_146_13_24" id="tag_20_146_13_24"></a>Return to Previous Context</h5>
    904 <dl compact>
    905 <dd></dd>
    906 <dt><i>Synopsis</i>:</dt>
    907 <dd>
    908 <pre>
    909 <tt>` </tt><i>character</i><tt>
    910 </tt></pre></dd>
    911 </dl>
    912 <p>It shall be an error if the marked line is no longer in the edit buffer. If the marked line no longer contains a character in
    913 the saved numbered character position, it shall be as if the marked position is the first non-&lt;blank&gt;.</p>
    914 <p>If used as a motion command:</p>
    915 <ol>
    916 <li>
    917 <p>It shall be an error if the marked cursor references the same character in the edit buffer as the starting cursor.</p>
    918 </li>
    919 <li>
    920 <p>If the starting cursor is after the marked cursor, then the locations of the starting cursor and the marked cursor in the edit
    921 buffer shall be logically swapped.</p>
    922 </li>
    923 <li>
    924 <p>If the starting line is empty or the starting cursor is at or before the first non-&lt;blank&gt; non-&lt;newline&gt; of the
    925 starting line, and the marked cursor line is empty or the marked cursor references the first character of the marked cursor line,
    926 the text region shall consist of all lines containing characters from the starting cursor to the line before the marked cursor
    927 line, inclusive, and any text copied to a buffer shall be in line mode.</p>
    928 </li>
    929 <li>
    930 <p>Otherwise, if the marked cursor line is empty or the marked cursor references a character at or before the first
    931 non-&lt;blank&gt; non-&lt;newline&gt; of the marked cursor line, the region of text shall be from the starting cursor to the last
    932 non-&lt;newline&gt; of the line before the marked cursor line, inclusive, and any text copied to a buffer shall be in character
    933 mode.</p>
    934 </li>
    935 <li>
    936 <p>Otherwise, the region of text shall be from the starting cursor (inclusive), to the marked cursor (exclusive), and any text
    937 copied to a buffer shall be in character mode.</p>
    938 </li>
    939 </ol>
    940 <p>If not used as a motion command:</p>
    941 <p><i>Current line</i>: Set to the line referenced by the mark.</p>
    942 <p><i>Current column</i>: Set to the last column in which any portion of the character referenced by the mark is displayed.</p>
    943 <h5><a name="tag_20_146_13_25" id="tag_20_146_13_25"></a>Return to Previous Section</h5>
    944 <dl compact>
    945 <dd></dd>
    946 <dt><i>Synopsis</i>:</dt>
    947 <dd>
    948 <pre>
    949 <b>[</b><i>count</i><b>]</b><tt> [[
    950 </tt></pre></dd>
    951 </dl>
    952 <p>Move the cursor backward through the edit buffer to the first character of the previous section boundary, <i>count</i>
    953 times.</p>
    954 <p>If used as a motion command:</p>
    955 <ol>
    956 <li>
    957 <p>If the starting cursor was at the first character of the starting line or the starting line was empty, and the first character
    958 of the boundary was the first character of the boundary line, the text region shall consist of the current line up to and including
    959 the line where the <i>count</i>th next boundary starts, and any text copied to a buffer shall be in line mode.</p>
    960 </li>
    961 <li>
    962 <p>If the boundary was the last line of the edit buffer or the last non-&lt;newline&gt; of the last line of the edit buffer, the
    963 text region shall consist of the last character in the edit buffer up to and including the starting character, and any text saved
    964 to a buffer shall be in character mode.</p>
    965 </li>
    966 <li>
    967 <p>Otherwise, the text region shall consist of the starting character up to but not including the first character in the
    968 <i>count</i>th next boundary, and any text copied to a buffer shall be in character mode.</p>
    969 </li>
    970 </ol>
    971 <p>If not used as a motion command:</p>
    972 <p><i>Current line</i>: Set to the line where the <i>count</i>th next boundary in the edit buffer starts.</p>
    973 <p><i>Current column</i>: Set to the last column in which any portion of the first character of the <i>count</i>th next boundary is
    974 displayed, or column position 1 if the line is empty.</p>
    975 <h5><a name="tag_20_146_13_26" id="tag_20_146_13_26"></a>Move to Next Section</h5>
    976 <dl compact>
    977 <dd></dd>
    978 <dt><i>Synopsis</i>:</dt>
    979 <dd>
    980 <pre>
    981 <b>[</b><i>count</i><b>]</b><tt> ]]
    982 </tt></pre></dd>
    983 </dl>
    984 <p>Move the cursor forward through the edit buffer to the first character of the next section boundary, <i>count</i> times.</p>
    985 <p>If used as a motion command:</p>
    986 <ol>
    987 <li>
    988 <p>If the starting cursor was at the first character of the starting line or the starting line was empty, and the first character
    989 of the boundary was the first character of the boundary line, the text region shall consist of the current line up to and including
    990 the line where the <i>count</i>th previous boundary starts, and any text copied to a buffer shall be in line mode.</p>
    991 </li>
    992 <li>
    993 <p>If the boundary was the first line of the edit buffer, the text region shall consist of the first character in the edit buffer
    994 up to but not including the starting character, and any text copied to a buffer shall be in character mode.</p>
    995 </li>
    996 <li>
    997 <p>Otherwise, the text region shall consist of the first character in the <i>count</i>th previous section boundary up to but not
    998 including the starting character, and any text copied to a buffer shall be in character mode.</p>
    999 </li>
   1000 </ol>
   1001 <p>If not used as a motion command:</p>
   1002 <p><i>Current line</i>: Set to the line where the <i>count</i>th previous boundary in the edit buffer starts.</p>
   1003 <p><i>Current column</i>: Set to the last column in which any portion of the first character of the <i>count</i>th previous
   1004 boundary is displayed, or column position 1 if the line is empty.</p>
   1005 <h5><a name="tag_20_146_13_27" id="tag_20_146_13_27"></a>Move to First Non-&lt;blank&gt; Position on Current Line</h5>
   1006 <dl compact>
   1007 <dd></dd>
   1008 <dt><i>Synopsis</i>:</dt>
   1009 <dd>
   1010 <pre>
   1011 <tt>^
   1012 </tt></pre></dd>
   1013 </dl>
   1014 If used as a motion command:
   1015 <ol>
   1016 <li>
   1017 <p>If the line has no non-&lt;blank&gt; non-&lt;newline&gt; characters, or if the cursor is at the first non-&lt;blank&gt;
   1018 non-&lt;newline&gt; of the line, it shall be an error.</p>
   1019 </li>
   1020 <li>
   1021 <p>If the cursor is before the first non-&lt;blank&gt; non-&lt;newline&gt; of the line, the text region shall be comprised of the
   1022 current character, up to, but not including, the first non-&lt;blank&gt; non-&lt;newline&gt; of the line.</p>
   1023 </li>
   1024 <li>
   1025 <p>If the cursor is after the first non-&lt;blank&gt; non-&lt;newline&gt; of the line, the text region shall be from the character
   1026 before the starting cursor up to and including the first non-&lt;blank&gt; non-&lt;newline&gt; of the line.</p>
   1027 </li>
   1028 <li>
   1029 <p>Any text copied to a buffer shall be in character mode.</p>
   1030 </li>
   1031 </ol>
   1032 <p>If not used as a motion command:</p>
   1033 <p><i>Current line</i>: Unchanged.</p>
   1034 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1035 <h5><a name="tag_20_146_13_28" id="tag_20_146_13_28"></a>Current and Line Above</h5>
   1036 <dl compact>
   1037 <dd></dd>
   1038 <dt><i>Synopsis</i>:</dt>
   1039 <dd>
   1040 <pre>
   1041 <b>[</b><i>count</i><b>]</b><tt> _
   1042 </tt></pre></dd>
   1043 </dl>
   1044 <p>If there are less than <i>count</i> -1 lines after the current line in the edit buffer, it shall be an error.</p>
   1045 <p>If used as a motion command:</p>
   1046 <ol>
   1047 <li>
   1048 <p>If <i>count</i> is less than 2, the text region shall be the current line.</p>
   1049 </li>
   1050 <li>
   1051 <p>Otherwise, the text region shall include the starting line and the next <i>count</i> -1 lines.</p>
   1052 </li>
   1053 <li>
   1054 <p>Any text copied to a buffer shall be in line mode.</p>
   1055 </li>
   1056 </ol>
   1057 <p>If not used as a motion command:</p>
   1058 <p><i>Current line</i>: Set to current line + <i>count</i> -1.</p>
   1059 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1060 <h5><a name="tag_20_146_13_29" id="tag_20_146_13_29"></a>Move Back to Beginning of Sentence</h5>
   1061 <dl compact>
   1062 <dd></dd>
   1063 <dt><i>Synopsis</i>:</dt>
   1064 <dd>
   1065 <pre>
   1066 <b>[</b><i>count</i><b>]</b><tt> (
   1067 </tt></pre></dd>
   1068 </dl>
   1069 <p>Move backward to the beginning of a sentence. This command shall be equivalent to the <b>[[</b> command, with the exception that
   1070 sentence boundaries shall be used instead of section boundaries.</p>
   1071 <h5><a name="tag_20_146_13_30" id="tag_20_146_13_30"></a>Move Forward to Beginning of Sentence</h5>
   1072 <dl compact>
   1073 <dd></dd>
   1074 <dt><i>Synopsis</i>:</dt>
   1075 <dd>
   1076 <pre>
   1077 <b>[</b><i>count</i><b>]</b><tt> )
   1078 </tt></pre></dd>
   1079 </dl>
   1080 <p>Move forward to the beginning of a sentence. This command shall be equivalent to the <b>]]</b> command, with the exception that
   1081 sentence boundaries shall be used instead of section boundaries.</p>
   1082 <h5><a name="tag_20_146_13_31" id="tag_20_146_13_31"></a>Move Back to Preceding Paragraph</h5>
   1083 <dl compact>
   1084 <dd></dd>
   1085 <dt><i>Synopsis</i>:</dt>
   1086 <dd>
   1087 <pre>
   1088 <b>[</b><i>count</i><b>]</b><tt> {
   1089 </tt></pre></dd>
   1090 </dl>
   1091 <p>Move back to the beginning of the preceding paragraph. This command shall be equivalent to the <b>[[</b> command, with the
   1092 exception that paragraph boundaries shall be used instead of section boundaries.</p>
   1093 <h5><a name="tag_20_146_13_32" id="tag_20_146_13_32"></a>Move Forward to Next Paragraph</h5>
   1094 <dl compact>
   1095 <dd></dd>
   1096 <dt><i>Synopsis</i>:</dt>
   1097 <dd>
   1098 <pre>
   1099 <b>[</b><i>count</i><b>]</b><tt> }
   1100 </tt></pre></dd>
   1101 </dl>
   1102 <p>Move forward to the beginning of the next paragraph. This command shall be equivalent to the <b>]]</b> command, with the
   1103 exception that paragraph boundaries shall be used instead of section boundaries.</p>
   1104 <h5><a name="tag_20_146_13_33" id="tag_20_146_13_33"></a>Move to Specific Column Position</h5>
   1105 <dl compact>
   1106 <dd></dd>
   1107 <dt><i>Synopsis</i>:</dt>
   1108 <dd>
   1109 <pre>
   1110 <b>[</b><i>count</i><b>]</b><tt> |
   1111 </tt></pre></dd>
   1112 </dl>
   1113 <p>For the purposes of this command, lines that are too long for the current display and that have been folded shall be treated as
   1114 having a single, 1-based, number of columns.</p>
   1115 <p>If there are less than <i>count</i> columns in which characters from the current line are displayed on the screen, <i>count</i>
   1116 shall be adjusted to be the last column in which any portion of the line is displayed on the screen.</p>
   1117 <p>If used as a motion command:</p>
   1118 <ol>
   1119 <li>
   1120 <p>If the line is empty, or the cursor character is the same as the character on the <i>count</i>th column of the line, it shall be
   1121 an error.</p>
   1122 </li>
   1123 <li>
   1124 <p>If the cursor is before the <i>count</i>th column of the line, the text region shall be comprised of the current character, up
   1125 to but not including the character on the <i>count</i>th column of the line.</p>
   1126 </li>
   1127 <li>
   1128 <p>If the cursor is after the <i>count</i>th column of the line, the text region shall be from the character before the starting
   1129 cursor up to and including the character on the <i>count</i>th column of the line.</p>
   1130 </li>
   1131 <li>
   1132 <p>Any text copied to a buffer shall be in character mode.</p>
   1133 </li>
   1134 </ol>
   1135 <p>If not used as a motion command:</p>
   1136 <p><i>Current line</i>: Unchanged.</p>
   1137 <p><i>Current column</i>: Set to the last column in which any portion of the character that is displayed in the <i>count</i> column
   1138 of the line is displayed.</p>
   1139 <h5><a name="tag_20_146_13_34" id="tag_20_146_13_34"></a>Reverse Find Character</h5>
   1140 <dl compact>
   1141 <dd></dd>
   1142 <dt><i>Synopsis</i>:</dt>
   1143 <dd>
   1144 <pre>
   1145 <b>[</b><i>count</i><b>]</b><tt> ,
   1146 </tt></pre></dd>
   1147 </dl>
   1148 <p>If the last <b>F</b>, <b>f</b>, <b>T</b>, or <b>t</b> command was <b>F</b>, <b>f</b>, <b>T</b>, or <b>t</b>, this command shall
   1149 be equivalent to an <b>f</b>, <b>F</b>, <b>t</b>, or <b>T</b> command, respectively, with the specified <i>count</i> and the same
   1150 search character.</p>
   1151 <p>If there was no previous <b>F</b>, <b>f</b>, <b>T</b>, or <b>t</b> command, it shall be an error.</p>
   1152 <h5><a name="tag_20_146_13_35" id="tag_20_146_13_35"></a>Repeat</h5>
   1153 <dl compact>
   1154 <dd></dd>
   1155 <dt><i>Synopsis</i>:</dt>
   1156 <dd>
   1157 <pre>
   1158 <b>[</b><i>count</i><b>]</b><tt> .
   1159 </tt></pre></dd>
   1160 </dl>
   1161 <p>Repeat the last <b>!</b>, <b>&lt;</b>, <b>&gt;</b>, <b>A</b>, <b>C</b>, <b>D</b>, <b>I</b>, <b>J</b>, <b>O</b>, <b>P</b>,
   1162 <b>R</b>, <b>S</b>, <b>X</b>, <b>Y</b>, <b>a</b>, <b>c</b>, <b>d</b>, <b>i</b>, <b>o</b>, <b>p</b>, <b>r</b>, <b>s</b>, <b>x</b>,
   1163 <b>y</b>, or <b>~</b> command. It shall be an error if none of these commands have been executed. Commands (other than commands
   1164 that enter text input mode) executed as a result of map expansions, shall not change the value of the last repeatable command.</p>
   1165 <p>Repeated commands with associated motion commands shall repeat the motion command as well; however, any specified <i>count</i>
   1166 shall replace the <i>count</i>(s) that were originally specified to the repeated command or its associated motion command.</p>
   1167 <p>If the motion component of the repeated command is <b>f</b>, <b>F</b>, <b>t</b>, or <b>T</b>, the repeated command shall not set
   1168 the remembered search character for the <b>;</b> and <b>,</b> commands.</p>
   1169 <p>If the repeated command is <b>p</b> or <b>P</b>, and the buffer associated with that command was a numeric buffer named with a
   1170 number less than 9, the buffer associated with the repeated command shall be set to be the buffer named by the name of the previous
   1171 buffer logically incremented by 1.</p>
   1172 <p>If the repeated character is a text input command, the input text associated with that command is repeated literally:</p>
   1173 <ul>
   1174 <li>
   1175 <p>Input characters are neither macro or abbreviation-expanded.</p>
   1176 </li>
   1177 <li>
   1178 <p>Input characters are not interpreted in any special way with the exception that &lt;newline&gt;, &lt;carriage-return&gt;, and
   1179 &lt;control&gt;-T behave as described in <a href="#tag_20_146_13_88">Input Mode Commands in vi</a> .</p>
   1180 </li>
   1181 </ul>
   1182 <p><i>Current line</i>: Set as described for the repeated command.</p>
   1183 <p><i>Current column</i>: Set as described for the repeated command.</p>
   1184 <h5><a name="tag_20_146_13_36" id="tag_20_146_13_36"></a>Find Regular Expression</h5>
   1185 <dl compact>
   1186 <dd></dd>
   1187 <dt><i>Synopsis</i>:</dt>
   1188 <dd>
   1189 <pre>
   1190 <tt>/
   1191 </tt></pre></dd>
   1192 </dl>
   1193 <p>If the input line contains no non-&lt;newline&gt; characters, it shall be equivalent to a line containing only the last regular
   1194 expression encountered. The enhanced regular expressions supported by <i>vi</i> are described in <a href=
   1195 "../utilities/ex.html#tag_20_40_13_58"><i>Regular Expressions in ex</i></a> .</p>
   1196 <p>Otherwise, the line shall be interpreted as one or more regular expressions, optionally followed by an address offset or a
   1197 <i>vi</i> <b>z</b> command.</p>
   1198 <p>If the regular expression is not the last regular expression on the line, or if a line offset or <b>z</b> command is specified,
   1199 the regular expression shall be terminated by an unescaped <tt>'/'</tt> character, which shall not be used as part of the regular
   1200 expression. If the regular expression is not the first regular expression on the line, it shall be preceded by zero or more
   1201 &lt;blank&gt; characters, a &lt;semicolon&gt;, zero or more &lt;blank&gt; characters, and a leading <tt>'/'</tt> character, which
   1202 shall not be interpreted as part of the regular expression. It shall be an error to precede any regular expression with any
   1203 characters other than these.</p>
   1204 <p>Each search shall begin from the character after the first character of the last match (or, if it is the first search, after the
   1205 cursor). If the <b>wrapscan</b> edit option is set, the search shall continue to the character before the starting cursor
   1206 character; otherwise, to the end of the edit buffer. It shall be an error if any search fails to find a match, and an informational
   1207 message to this effect shall be displayed.</p>
   1208 <p>An optional address offset (see <a href="../utilities/ex.html#tag_20_40_13_02"><i>Addressing in ex</i></a> ) can be specified
   1209 after the last regular expression by including a trailing <tt>'/'</tt> character after the regular expression and specifying the
   1210 address offset. This offset shall be from the line containing the match for the last regular expression specified. It shall be an
   1211 error if the line offset would indicate a line address less than 1 or greater than the last line in the edit buffer. An address
   1212 offset of zero shall be supported. It shall be an error to follow the address offset with any other characters than &lt;blank&gt;
   1213 characters.</p>
   1214 <p>If not used as a motion command, an optional <b>z</b> command (see <a href="#tag_20_146_13_86">Redraw Window</a> ) can be
   1215 specified after the last regular expression by including a trailing <tt>'/'</tt> character after the regular expression, zero or
   1216 more &lt;blank&gt; characters, a <tt>'z'</tt>, zero or more &lt;blank&gt; characters, an optional new <b>window</b> edit option
   1217 value, zero or more &lt;blank&gt; characters, and a location character. The effect shall be as if the <b>z</b> command was executed
   1218 after the <b>/</b> command. It shall be an error to follow the <b>z</b> command with any other characters than &lt;blank&gt;
   1219 characters.</p>
   1220 <p>The remembered search direction shall be set to forward.</p>
   1221 <p>If used as a motion command:</p>
   1222 <ol>
   1223 <li>
   1224 <p>It shall be an error if the last match references the same character in the edit buffer as the starting cursor.</p>
   1225 </li>
   1226 <li>
   1227 <p>If any address offset is specified, the last match shall be adjusted by the specified offset as described previously.</p>
   1228 </li>
   1229 <li>
   1230 <p>If the starting cursor is after the last match, then the locations of the starting cursor and the last match in the edit buffer
   1231 shall be logically swapped.</p>
   1232 </li>
   1233 <li>
   1234 <p>If any address offset is specified, the text region shall consist of all lines containing characters from the starting cursor to
   1235 the last match line, inclusive, and any text copied to a buffer shall be in line mode.</p>
   1236 </li>
   1237 <li>
   1238 <p>Otherwise, if the starting line is empty or the starting cursor is at or before the first non-&lt;blank&gt; non-&lt;newline&gt;
   1239 of the starting line, and the last match line is empty or the last match starts at the first character of the last match line, the
   1240 text region shall consist of all lines containing characters from the starting cursor to the line before the last match line,
   1241 inclusive, and any text copied to a buffer shall be in line mode.</p>
   1242 </li>
   1243 <li>
   1244 <p>Otherwise, if the last match line is empty or the last match begins at a character at or before the first non-&lt;blank&gt;
   1245 non-&lt;newline&gt; of the last match line, the region of text shall be from the current cursor to the last non-&lt;newline&gt; of
   1246 the line before the last match line, inclusive, and any text copied to a buffer shall be in character mode.</p>
   1247 </li>
   1248 <li>
   1249 <p>Otherwise, the region of text shall be from the current cursor (inclusive), to the first character of the last match
   1250 (exclusive), and any text copied to a buffer shall be in character mode.</p>
   1251 </li>
   1252 </ol>
   1253 <p>If not used as a motion command:</p>
   1254 <p><i>Current line</i>: If a match is found, set to the last matched line plus the address offset, if any; otherwise,
   1255 unchanged.</p>
   1256 <p><i>Current column</i>: Set to the last column on which any portion of the first character in the last matched string is
   1257 displayed, if a match is found; otherwise, unchanged.</p>
   1258 <h5><a name="tag_20_146_13_37" id="tag_20_146_13_37"></a>Move to First Character in Line</h5>
   1259 <dl compact>
   1260 <dd></dd>
   1261 <dt><i>Synopsis</i>:</dt>
   1262 <dd>
   1263 <pre>
   1264 <tt>0  </tt>(zero)<tt>
   1265 </tt></pre></dd>
   1266 </dl>
   1267 <p>Move to the first character on the current line. The character <tt>'0'</tt> shall not be interpreted as a command if it is
   1268 immediately preceded by a digit.</p>
   1269 <p>If used as a motion command:</p>
   1270 <ol>
   1271 <li>
   1272 <p>If the cursor character is the first character in the line, it shall be an error.</p>
   1273 </li>
   1274 <li>
   1275 <p>The text region shall be from the character before the cursor character up to and including the first character in the line.</p>
   1276 </li>
   1277 <li>
   1278 <p>Any text copied to a buffer shall be in character mode.</p>
   1279 </li>
   1280 </ol>
   1281 <p>If not used as a motion command:</p>
   1282 <p><i>Current line</i>: Unchanged.</p>
   1283 <p><i>Current column</i>: The last column in which any portion of the first character in the line is displayed, or if the line is
   1284 empty, unchanged.</p>
   1285 <h5><a name="tag_20_146_13_38" id="tag_20_146_13_38"></a>Execute an ex Command</h5>
   1286 <dl compact>
   1287 <dd></dd>
   1288 <dt><i>Synopsis</i>:</dt>
   1289 <dd>
   1290 <pre>
   1291 <tt>:
   1292 </tt></pre></dd>
   1293 </dl>
   1294 <p>Execute one or more <a href="../utilities/ex.html"><i>ex</i></a> commands.</p>
   1295 <p>If any portion of the screen other than the last line of the screen was overwritten by any <a href=
   1296 "../utilities/ex.html"><i>ex</i></a> command (except <b>shell</b>), <i>vi</i> shall display a message indicating that it is waiting
   1297 for an input from the user, and shall then read a character. This action may also be taken for other, unspecified reasons.</p>
   1298 <p>If the next character entered is a <tt>':'</tt>, another <a href="../utilities/ex.html"><i>ex</i></a> command shall be accepted
   1299 and executed. Any other character shall cause the screen to be refreshed and <i>vi</i> shall return to command mode.</p>
   1300 <p><i>Current line</i>: As specified for the <a href="../utilities/ex.html"><i>ex</i></a> command.</p>
   1301 <p><i>Current column</i>: As specified for the <a href="../utilities/ex.html"><i>ex</i></a> command.</p>
   1302 <h5><a name="tag_20_146_13_39" id="tag_20_146_13_39"></a>Repeat Find</h5>
   1303 <dl compact>
   1304 <dd></dd>
   1305 <dt><i>Synopsis</i>:</dt>
   1306 <dd>
   1307 <pre>
   1308 <b>[</b><i>count</i><b>]</b><tt> ;
   1309 </tt></pre></dd>
   1310 </dl>
   1311 <p>This command shall be equivalent to the last <b>F</b>, <b>f</b>, <b>T</b>, or <b>t</b> command, with the specified <i>count</i>,
   1312 and with the same search character used for the last <b>F</b>, <b>f</b>, <b>T</b>, or <b>t</b> command. If there was no previous
   1313 <b>F</b>, <b>f</b>, <b>T</b>, or <b>t</b> command, it shall be an error.</p>
   1314 <h5><a name="tag_20_146_13_40" id="tag_20_146_13_40"></a>Shift Left</h5>
   1315 <dl compact>
   1316 <dd></dd>
   1317 <dt><i>Synopsis</i>:</dt>
   1318 <dd>
   1319 <pre>
   1320 <b>[</b><i>count</i><b>]</b><tt> &lt; </tt><i>motion</i><tt>
   1321 </tt></pre></dd>
   1322 </dl>
   1323 <p>If the motion command is the <b>&lt;</b> command repeated:</p>
   1324 <ol>
   1325 <li>
   1326 <p>If there are less than <i>count</i> -1 lines after the current line in the edit buffer, it shall be an error.</p>
   1327 </li>
   1328 <li>
   1329 <p>The text region shall be from the current line, up to and including the next <i>count</i> -1 lines.</p>
   1330 </li>
   1331 </ol>
   1332 <p>Shift any line in the text region specified by the <i>count</i> and motion command one shiftwidth (see the <a href=
   1333 "../utilities/ex.html"><i>ex</i></a> <b>shiftwidth</b> option) toward the start of the line, as described by the <a href=
   1334 "../utilities/ex.html"><i>ex</i></a> <b>&lt;</b> command. The unshifted lines shall be copied to the unnamed buffer in line
   1335 mode.</p>
   1336 <p><i>Current line</i>: If the motion was from the current cursor position toward the end of the edit buffer, unchanged. Otherwise,
   1337 set to the first line in the edit buffer that is part of the text region specified by the motion command.</p>
   1338 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1339 <h5><a name="tag_20_146_13_41" id="tag_20_146_13_41"></a>Shift Right</h5>
   1340 <dl compact>
   1341 <dd></dd>
   1342 <dt><i>Synopsis</i>:</dt>
   1343 <dd>
   1344 <pre>
   1345 <b>[</b><i>count</i><b>]</b><tt> &gt; </tt><i>motion</i><tt>
   1346 </tt></pre></dd>
   1347 </dl>
   1348 <p>If the motion command is the <b>&gt;</b> command repeated:</p>
   1349 <ol>
   1350 <li>
   1351 <p>If there are less than <i>count</i> -1 lines after the current line in the edit buffer, it shall be an error.</p>
   1352 </li>
   1353 <li>
   1354 <p>The text region shall be from the current line, up to and including the next <i>count</i> -1 lines.</p>
   1355 </li>
   1356 </ol>
   1357 <p>Shift any line with characters in the text region specified by the <i>count</i> and motion command one shiftwidth (see the
   1358 <a href="../utilities/ex.html"><i>ex</i></a> <b>shiftwidth</b> option) away from the start of the line, as described by the
   1359 <a href="../utilities/ex.html"><i>ex</i></a> <b>&gt;</b> command. The unshifted lines shall be copied into the unnamed buffer in
   1360 line mode.</p>
   1361 <p><i>Current line</i>: If the motion was from the current cursor position toward the end of the edit buffer, unchanged. Otherwise,
   1362 set to the first line in the edit buffer that is part of the text region specified by the motion command.</p>
   1363 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1364 <h5><a name="tag_20_146_13_42" id="tag_20_146_13_42"></a>Scan Backwards for Regular Expression</h5>
   1365 <dl compact>
   1366 <dd></dd>
   1367 <dt><i>Synopsis</i>:</dt>
   1368 <dd>
   1369 <pre>
   1370 <tt>?
   1371 </tt></pre></dd>
   1372 </dl>
   1373 <p>Scan backwards; the <b>?</b> command shall be equivalent to the <b>/</b> command (see <a href="#tag_20_146_13_36">Find Regular
   1374 Expression</a> ) with the following exceptions:</p>
   1375 <ol>
   1376 <li>
   1377 <p>The input prompt shall be a <tt>'?'</tt>.</p>
   1378 </li>
   1379 <li>
   1380 <p>Each search shall begin from the character before the first character of the last match (or, if it is the first search, the
   1381 character before the cursor character).</p>
   1382 </li>
   1383 <li>
   1384 <p>The search direction shall be from the cursor toward the beginning of the edit buffer, and the <b>wrapscan</b> edit option shall
   1385 affect whether the search wraps to the end of the edit buffer and continues.</p>
   1386 </li>
   1387 <li>
   1388 <p>The remembered search direction shall be set to backward.</p>
   1389 </li>
   1390 </ol>
   1391 <h5><a name="tag_20_146_13_43" id="tag_20_146_13_43"></a>Execute</h5>
   1392 <dl compact>
   1393 <dd></dd>
   1394 <dt><i>Synopsis</i>:</dt>
   1395 <dd>
   1396 <pre>
   1397 <tt>@</tt><i>buffer</i><tt>
   1398 </tt></pre></dd>
   1399 </dl>
   1400 <p>If the <i>buffer</i> is specified as <b>@</b>, the last buffer executed shall be used. If no previous buffer has been executed,
   1401 it shall be an error.</p>
   1402 <p>Behave as if the contents of the named buffer were entered as standard input. After each line of a line-mode buffer, and all but
   1403 the last line of a character mode buffer, behave as if a &lt;newline&gt; were entered as standard input.</p>
   1404 <p>If an error occurs during this process, an error message shall be written, and no more characters resulting from the execution
   1405 of this command shall be processed.</p>
   1406 <p>If a <i>count</i> is specified, behave as if that count were entered as user input before the characters from the <b>@</b>
   1407 buffer were entered.</p>
   1408 <p><i>Current line</i>: As specified for the individual commands.</p>
   1409 <p><i>Current column</i>: As specified for the individual commands.</p>
   1410 <h5><a name="tag_20_146_13_44" id="tag_20_146_13_44"></a>Reverse Case</h5>
   1411 <dl compact>
   1412 <dd></dd>
   1413 <dt><i>Synopsis</i>:</dt>
   1414 <dd>
   1415 <pre>
   1416 <b>[</b><i>count</i><b>]</b><tt> ~
   1417 </tt></pre></dd>
   1418 </dl>
   1419 <p>Reverse the case of the current character and the next <i>count</i> -1 characters, such that lowercase characters that have
   1420 uppercase counterparts shall be changed to uppercase characters, and uppercase characters that have lowercase counterparts shall be
   1421 changed to lowercase characters, as prescribed by the current locale. No other characters shall be affected by this command.</p>
   1422 <p>If there are less than <i>count</i> -1 characters after the cursor in the edit buffer, <i>count</i> shall be adjusted to the
   1423 number of characters after the cursor in the edit buffer minus 1.</p>
   1424 <p>For the purposes of this command, the next character after the last non-&lt;newline&gt; on the line shall be the next character
   1425 in the edit buffer.</p>
   1426 <p><i>Current line</i>: Set to the line including the (<i>count</i>-1)th character after the cursor.</p>
   1427 <p><i>Current column</i>: Set to the last column in which any portion of the (<i>count</i>-1)th character after the cursor is
   1428 displayed.</p>
   1429 <h5><a name="tag_20_146_13_45" id="tag_20_146_13_45"></a>Append</h5>
   1430 <dl compact>
   1431 <dd></dd>
   1432 <dt><i>Synopsis</i>:</dt>
   1433 <dd>
   1434 <pre>
   1435 <b>[</b><i>count</i><b>]</b><tt> a
   1436 </tt></pre></dd>
   1437 </dl>
   1438 <p>Enter text input mode after the current cursor position. No characters already in the edit buffer shall be affected by this
   1439 command. A <i>count</i> shall cause the input text to be appended <i>count</i> -1 more times to the end of the input.</p>
   1440 <p><i>Current line/column</i>: As specified for the text input commands (see <a href="#tag_20_146_13_88">Input Mode Commands in
   1441 vi</a> ).</p>
   1442 <h5><a name="tag_20_146_13_46" id="tag_20_146_13_46"></a>Append at End-of-Line</h5>
   1443 <dl compact>
   1444 <dd></dd>
   1445 <dt><i>Synopsis</i>:</dt>
   1446 <dd>
   1447 <pre>
   1448 <b>[</b><i>count</i><b>]</b><tt> A
   1449 </tt></pre></dd>
   1450 </dl>
   1451 <p>This command shall be equivalent to the <i>vi</i> command:</p>
   1452 <pre>
   1453 <tt>$</tt><b> [ </b><i>count </i><b>]</b><tt> a
   1454 </tt></pre>
   1455 <p>(see <a href="#tag_20_146_13_45">Append</a> ).</p>
   1456 <h5><a name="tag_20_146_13_47" id="tag_20_146_13_47"></a>Move Backward to Preceding Word</h5>
   1457 <dl compact>
   1458 <dd></dd>
   1459 <dt><i>Synopsis</i>:</dt>
   1460 <dd>
   1461 <pre>
   1462 <b>[</b><i>count</i><b>]</b><tt> b
   1463 </tt></pre></dd>
   1464 </dl>
   1465 <p>With the exception that words are used as the delimiter instead of bigwords, this command shall be equivalent to the <b>B</b>
   1466 command.</p>
   1467 <h5><a name="tag_20_146_13_48" id="tag_20_146_13_48"></a>Move Backward to Preceding Bigword</h5>
   1468 <dl compact>
   1469 <dd></dd>
   1470 <dt><i>Synopsis</i>:</dt>
   1471 <dd>
   1472 <pre>
   1473 <b>[</b><i>count</i><b>]</b><tt> B
   1474 </tt></pre></dd>
   1475 </dl>
   1476 <p>If the edit buffer is empty or the cursor is on the first character of the edit buffer, it shall be an error. If less than
   1477 <i>count</i> bigwords begin between the cursor and the start of the edit buffer, <i>count</i> shall be adjusted to the number of
   1478 bigword beginnings between the cursor and the start of the edit buffer.</p>
   1479 <p>If used as a motion command:</p>
   1480 <ol>
   1481 <li>
   1482 <p>The text region shall be from the first character of the <i>count</i>th previous bigword beginning up to but not including the
   1483 cursor character.</p>
   1484 </li>
   1485 <li>
   1486 <p>Any text copied to a buffer shall be in character mode.</p>
   1487 </li>
   1488 </ol>
   1489 <p>If not used as a motion command:</p>
   1490 <p><i>Current line</i>: Set to the line containing the <i>current column</i>.</p>
   1491 <p><i>Current column</i>: Set to the last column upon which any part of the first character of the <i>count</i>th previous bigword
   1492 is displayed.</p>
   1493 <h5><a name="tag_20_146_13_49" id="tag_20_146_13_49"></a>Change</h5>
   1494 <dl compact>
   1495 <dd></dd>
   1496 <dt><i>Synopsis</i>:</dt>
   1497 <dd>
   1498 <pre>
   1499 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> c </tt><i>motion</i><tt>
   1500 </tt></pre></dd>
   1501 </dl>
   1502 <p>If the motion command is the <b>c</b> command repeated:</p>
   1503 <ol>
   1504 <li>
   1505 <p>The buffer text shall be in line mode.</p>
   1506 </li>
   1507 <li>
   1508 <p>If there are less than <i>count</i> -1 lines after the current line in the edit buffer, it shall be an error.</p>
   1509 </li>
   1510 <li>
   1511 <p>The text region shall be from the current line up to and including the next <i>count</i> -1 lines.</p>
   1512 </li>
   1513 </ol>
   1514 <p>Otherwise, the buffer text mode and text region shall be as specified by the motion command.</p>
   1515 <p>The replaced text shall be copied into <i>buffer</i>, if specified, and into the unnamed buffer. If the text to be replaced
   1516 contains characters from more than a single line, or the buffer text is in line mode, the replaced text shall be copied into the
   1517 numeric buffers as well.</p>
   1518 <p>If the buffer text is in line mode:</p>
   1519 <ol>
   1520 <li>
   1521 <p>Any lines that contain characters in the region shall be deleted, and the editor shall enter text input mode at the beginning of
   1522 a new line which shall replace the first line deleted.</p>
   1523 </li>
   1524 <li>
   1525 <p>If the <b>autoindent</b> edit option is set, <b>autoindent</b> characters equal to the <b>autoindent</b> characters on the first
   1526 line deleted shall be inserted as if entered by the user.</p>
   1527 </li>
   1528 </ol>
   1529 <p>Otherwise, if characters from more than one line are in the region of text:</p>
   1530 <ol>
   1531 <li>
   1532 <p>The text shall be deleted.</p>
   1533 </li>
   1534 <li>
   1535 <p>Any text remaining in the last line in the text region shall be appended to the first line in the region, and the last line in
   1536 the region shall be deleted.</p>
   1537 </li>
   1538 <li>
   1539 <p>The editor shall enter text input mode after the last character not deleted from the first line in the text region, if any;
   1540 otherwise, on the first column of the first line in the region.</p>
   1541 </li>
   1542 </ol>
   1543 <br>
   1544 <p>Otherwise:</p>
   1545 <ol>
   1546 <li>
   1547 <p>If the glyph for <tt>'$'</tt> is smaller than the region, the end of the region shall be marked with a <tt>'$'</tt>.</p>
   1548 </li>
   1549 <li>
   1550 <p>The editor shall enter text input mode, overwriting the region of text.</p>
   1551 </li>
   1552 </ol>
   1553 <p><i>Current line/column</i>: As specified for the text input commands (see <a href="#tag_20_146_13_88">Input Mode Commands in
   1554 vi</a> ).</p>
   1555 <h5><a name="tag_20_146_13_50" id="tag_20_146_13_50"></a>Change to End-of-Line</h5>
   1556 <dl compact>
   1557 <dd></dd>
   1558 <dt><i>Synopsis</i>:</dt>
   1559 <dd>
   1560 <pre>
   1561 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> C
   1562 </tt></pre></dd>
   1563 </dl>
   1564 <p>This command shall be equivalent to the <i>vi</i> command:</p>
   1565 <pre>
   1566 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> c$
   1567 </tt></pre>
   1568 <p>See the <b>c</b> command.</p>
   1569 <h5><a name="tag_20_146_13_51" id="tag_20_146_13_51"></a>Delete</h5>
   1570 <dl compact>
   1571 <dd></dd>
   1572 <dt><i>Synopsis</i>:</dt>
   1573 <dd>
   1574 <pre>
   1575 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> d </tt><i>motion</i><tt>
   1576 </tt></pre></dd>
   1577 </dl>
   1578 <p>If the motion command is the <b>d</b> command repeated:</p>
   1579 <ol>
   1580 <li>
   1581 <p>The buffer text shall be in line mode.</p>
   1582 </li>
   1583 <li>
   1584 <p>If there are less than <i>count</i> -1 lines after the current line in the edit buffer, it shall be an error.</p>
   1585 </li>
   1586 <li>
   1587 <p>The text region shall be from the current line up to and including the next <i>count</i> -1 lines.</p>
   1588 </li>
   1589 </ol>
   1590 <p>Otherwise, the buffer text mode and text region shall be as specified by the motion command.</p>
   1591 <p>If in open mode, and the current line is deleted, and the line remains on the display, an <tt>'@'</tt> character shall be
   1592 displayed as the first glyph of that line.</p>
   1593 <p>Delete the region of text into <i>buffer</i>, if specified, and into the unnamed buffer. If the text to be deleted contains
   1594 characters from more than a single line, or the buffer text is in line mode, the deleted text shall be copied into the numeric
   1595 buffers, as well.</p>
   1596 <p><i>Current line</i>: Set to the first text region line that appears in the edit buffer, unless that line has been deleted, in
   1597 which case it shall be set to the last line in the edit buffer, or line 1 if the edit buffer is empty.</p>
   1598 <p><i>Current column</i>:</p>
   1599 <ol>
   1600 <li>
   1601 <p>If the line is empty, set to column position 1.</p>
   1602 </li>
   1603 <li>
   1604 <p>Otherwise, if the buffer text is in line mode or the motion was from the cursor toward the end of the edit buffer:</p>
   1605 <ol type="a">
   1606 <li>
   1607 <p>If a character from the current line is displayed in the current column, set to the last column that displays any portion of
   1608 that character.</p>
   1609 </li>
   1610 <li>
   1611 <p>Otherwise, set to the last column in which any portion of any character in the line is displayed.</p>
   1612 </li>
   1613 </ol>
   1614 </li>
   1615 <li>
   1616 <p>Otherwise, if a character is displayed in the column that began the text region, set to the last column that displays any
   1617 portion of that character.</p>
   1618 </li>
   1619 <li>
   1620 <p>Otherwise, set to the last column in which any portion of any character in the line is displayed.</p>
   1621 </li>
   1622 </ol>
   1623 <h5><a name="tag_20_146_13_52" id="tag_20_146_13_52"></a>Delete to End-of-Line</h5>
   1624 <dl compact>
   1625 <dd></dd>
   1626 <dt><i>Synopsis</i>:</dt>
   1627 <dd>
   1628 <pre>
   1629 <b>[</b><i>buffer</i><b>]</b><tt> D
   1630 </tt></pre></dd>
   1631 </dl>
   1632 <p>Delete the text from the current position to the end of the current line; equivalent to the <i>vi</i> command:</p>
   1633 <pre>
   1634 <b>[</b><i>buffer</i><b>]</b><tt> d$
   1635 </tt></pre>
   1636 <h5><a name="tag_20_146_13_53" id="tag_20_146_13_53"></a>Move to End-of-Word</h5>
   1637 <dl compact>
   1638 <dd></dd>
   1639 <dt><i>Synopsis</i>:</dt>
   1640 <dd>
   1641 <pre>
   1642 <b>[</b><i>count</i><b>]</b><tt> e
   1643 </tt></pre></dd>
   1644 </dl>
   1645 <p>With the exception that words are used instead of bigwords as the delimiter, this command shall be equivalent to the <b>E</b>
   1646 command.</p>
   1647 <h5><a name="tag_20_146_13_54" id="tag_20_146_13_54"></a>Move to End-of-Bigword</h5>
   1648 <dl compact>
   1649 <dd></dd>
   1650 <dt><i>Synopsis</i>:</dt>
   1651 <dd>
   1652 <pre>
   1653 <b>[</b><i>count</i><b>]</b><tt> E
   1654 </tt></pre></dd>
   1655 </dl>
   1656 <p>If the edit buffer is empty it shall be an error. If less than <i>count</i> bigwords end between the cursor and the end of the
   1657 edit buffer, <i>count</i> shall be adjusted to the number of bigword endings between the cursor and the end of the edit buffer.</p>
   1658 <p>If used as a motion command:</p>
   1659 <ol>
   1660 <li>
   1661 <p>The text region shall be from the last character of the <i>count</i>th next bigword up to and including the cursor
   1662 character.</p>
   1663 </li>
   1664 <li>
   1665 <p>Any text copied to a buffer shall be in character mode.</p>
   1666 </li>
   1667 </ol>
   1668 <p>If not used as a motion command:</p>
   1669 <p><i>Current line</i>: Set to the line containing the current column.</p>
   1670 <p><i>Current column</i>: Set to the last column upon which any part of the last character of the <i>count</i>th next bigword is
   1671 displayed.</p>
   1672 <h5><a name="tag_20_146_13_55" id="tag_20_146_13_55"></a>Find Character in Current Line (Forward)</h5>
   1673 <dl compact>
   1674 <dd></dd>
   1675 <dt><i>Synopsis</i>:</dt>
   1676 <dd>
   1677 <pre>
   1678 <b>[</b><i>count</i><b>]</b><tt> f </tt><i>character</i><tt>
   1679 </tt></pre></dd>
   1680 </dl>
   1681 <p>It shall be an error if <i>count</i> occurrences of the character do not occur after the cursor in the line.</p>
   1682 <p>If used as a motion command:</p>
   1683 <ol>
   1684 <li>
   1685 <p>The text range shall be from the cursor character up to and including the <i>count</i>th occurrence of the specified character
   1686 after the cursor.</p>
   1687 </li>
   1688 <li>
   1689 <p>Any text copied to a buffer shall be in character mode.</p>
   1690 </li>
   1691 </ol>
   1692 <p>If not used as a motion command:</p>
   1693 <p><i>Current line</i>: Unchanged.</p>
   1694 <p><i>Current column</i>: Set to the last column in which any portion of the <i>count</i>th occurrence of the specified character
   1695 after the cursor appears in the line.</p>
   1696 <h5><a name="tag_20_146_13_56" id="tag_20_146_13_56"></a>Find Character in Current Line (Reverse)</h5>
   1697 <dl compact>
   1698 <dd></dd>
   1699 <dt><i>Synopsis</i>:</dt>
   1700 <dd>
   1701 <pre>
   1702 <b>[</b><i>count</i><b>]</b><tt> F </tt><i>character</i><tt>
   1703 </tt></pre></dd>
   1704 </dl>
   1705 <p>It shall be an error if <i>count</i> occurrences of the character do not occur before the cursor in the line.</p>
   1706 <p>If used as a motion command:</p>
   1707 <ol>
   1708 <li>
   1709 <p>The text region shall be from the <i>count</i>th occurrence of the specified character before the cursor, up to, but not
   1710 including the cursor character.</p>
   1711 </li>
   1712 <li>
   1713 <p>Any text copied to a buffer shall be in character mode.</p>
   1714 </li>
   1715 </ol>
   1716 <p>If not used as a motion command:</p>
   1717 <p><i>Current line</i>: Unchanged.</p>
   1718 <p><i>Current column</i>: Set to the last column in which any portion of the <i>count</i>th occurrence of the specified character
   1719 before the cursor appears in the line.</p>
   1720 <h5><a name="tag_20_146_13_57" id="tag_20_146_13_57"></a>Move to Line</h5>
   1721 <dl compact>
   1722 <dd></dd>
   1723 <dt><i>Synopsis</i>:</dt>
   1724 <dd>
   1725 <pre>
   1726 <b>[</b><i>count</i><b>]</b><tt> G
   1727 </tt></pre></dd>
   1728 </dl>
   1729 <p>If <i>count</i> is not specified, it shall default to the last line of the edit buffer. If <i>count</i> is greater than the last
   1730 line of the edit buffer, it shall be an error.</p>
   1731 <p>If used as a motion command:</p>
   1732 <ol>
   1733 <li>
   1734 <p>The text region shall be from the cursor line up to and including the specified line.</p>
   1735 </li>
   1736 <li>
   1737 <p>Any text copied to a buffer shall be in line mode.</p>
   1738 </li>
   1739 </ol>
   1740 <p>If not used as a motion command:</p>
   1741 <p><i>Current line</i>: Set to <i>count</i> if <i>count</i> is specified; otherwise, the last line.</p>
   1742 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1743 <h5><a name="tag_20_146_13_58" id="tag_20_146_13_58"></a>Move to Top of Screen</h5>
   1744 <dl compact>
   1745 <dd></dd>
   1746 <dt><i>Synopsis</i>:</dt>
   1747 <dd>
   1748 <pre>
   1749 <b>[</b><i>count</i><b>]</b><tt> H
   1750 </tt></pre></dd>
   1751 </dl>
   1752 <p>If the beginning of the line <i>count</i> greater than the first line of which any portion appears on the display does not
   1753 exist, it shall be an error.</p>
   1754 <p>If used as a motion command:</p>
   1755 <ol>
   1756 <li>
   1757 <p>If in open mode, the text region shall be the current line.</p>
   1758 </li>
   1759 <li>
   1760 <p>Otherwise, the text region shall be from the starting line up to and including (the first line of the display + <i>count</i>
   1761 -1).</p>
   1762 </li>
   1763 <li>
   1764 <p>Any text copied to a buffer shall be in line mode.</p>
   1765 </li>
   1766 </ol>
   1767 <p>If not used as a motion command:</p>
   1768 <p>If in open mode, this command shall set the current column to non-&lt;blank&gt; and do nothing else.</p>
   1769 <p>Otherwise, it shall set the current line and current column as follows.</p>
   1770 <p><i>Current line</i>: Set to (the first line of the display + <i>count</i> -1).</p>
   1771 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1772 <h5><a name="tag_20_146_13_59" id="tag_20_146_13_59"></a>Insert Before Cursor</h5>
   1773 <dl compact>
   1774 <dd></dd>
   1775 <dt><i>Synopsis</i>:</dt>
   1776 <dd>
   1777 <pre>
   1778 <b>[</b><i>count</i><b>]</b><tt> i
   1779 </tt></pre></dd>
   1780 </dl>
   1781 <p>Enter text input mode before the current cursor position. No characters already in the edit buffer shall be affected by this
   1782 command. A <i>count</i> shall cause the input text to be appended <i>count</i> -1 more times to the end of the input.</p>
   1783 <p><i>Current line/column</i>: As specified for the text input commands (see <a href="#tag_20_146_13_88">Input Mode Commands in
   1784 vi</a> ).</p>
   1785 <h5><a name="tag_20_146_13_60" id="tag_20_146_13_60"></a>Insert at Beginning of Line</h5>
   1786 <dl compact>
   1787 <dd></dd>
   1788 <dt><i>Synopsis</i>:</dt>
   1789 <dd>
   1790 <pre>
   1791 <b>[</b><i>count</i><b>]</b><tt> I
   1792 </tt></pre></dd>
   1793 </dl>
   1794 <p>This command shall be equivalent to the <i>vi</i> command ^[<i>count</i>]<b>i</b>.</p>
   1795 <h5><a name="tag_20_146_13_61" id="tag_20_146_13_61"></a>Join</h5>
   1796 <dl compact>
   1797 <dd></dd>
   1798 <dt><i>Synopsis</i>:</dt>
   1799 <dd>
   1800 <pre>
   1801 <b>[</b><i>count</i><b>]</b><tt> J
   1802 </tt></pre></dd>
   1803 </dl>
   1804 <p>If the current line is the last line in the edit buffer, it shall be an error.</p>
   1805 <p>This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>join</b> command with no addresses, and
   1806 an <a href="../utilities/ex.html"><i>ex</i></a> command <i>count</i> value of 1 if <i>count</i> was not specified or if a
   1807 <i>count</i> of 1 was specified, and an <a href="../utilities/ex.html"><i>ex</i></a> command <i>count</i> value of <i>count</i> -1
   1808 for any other value of <i>count</i>, except that the current line and column shall be set as follows.</p>
   1809 <p><i>Current line</i>: Unchanged.</p>
   1810 <p><i>Current column</i>: The last column in which any portion of the character following the last character in the initial line is
   1811 displayed, or the last non-&lt;newline&gt; in the line if no characters were appended.</p>
   1812 <h5><a name="tag_20_146_13_62" id="tag_20_146_13_62"></a>Move to Bottom of Screen</h5>
   1813 <dl compact>
   1814 <dd></dd>
   1815 <dt><i>Synopsis</i>:</dt>
   1816 <dd>
   1817 <pre>
   1818 <b>[</b><i>count</i><b>]</b><tt> L
   1819 </tt></pre></dd>
   1820 </dl>
   1821 <p>If the beginning of the line <i>count</i> less than the last line of which any portion appears on the display does not exist, it
   1822 shall be an error.</p>
   1823 <p>If used as a motion command:</p>
   1824 <ol>
   1825 <li>
   1826 <p>If in open mode, the text region shall be the current line.</p>
   1827 </li>
   1828 <li>
   1829 <p>Otherwise, the text region shall include all lines from the starting cursor line to (the last line of the display -(<i>count</i>
   1830 -1)).</p>
   1831 </li>
   1832 <li>
   1833 <p>Any text copied to a buffer shall be in line mode.</p>
   1834 </li>
   1835 </ol>
   1836 <p>If not used as a motion command:</p>
   1837 <ol>
   1838 <li>
   1839 <p>If in open mode, this command shall set the current column to non-&lt;blank&gt; and do nothing else.</p>
   1840 </li>
   1841 <li>
   1842 <p>Otherwise, it shall set the current line and current column as follows.</p>
   1843 </li>
   1844 </ol>
   1845 <p><i>Current line</i>: Set to (the last line of the display -(<i>count</i> -1)).</p>
   1846 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1847 <h5><a name="tag_20_146_13_63" id="tag_20_146_13_63"></a>Mark Position</h5>
   1848 <dl compact>
   1849 <dd></dd>
   1850 <dt><i>Synopsis</i>:</dt>
   1851 <dd>
   1852 <pre>
   1853 <tt>m </tt><i>letter</i><tt>
   1854 </tt></pre></dd>
   1855 </dl>
   1856 <p>This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>mark</b> command with the specified
   1857 character as an argument.</p>
   1858 <h5><a name="tag_20_146_13_64" id="tag_20_146_13_64"></a>Move to Middle of Screen</h5>
   1859 <dl compact>
   1860 <dd></dd>
   1861 <dt><i>Synopsis</i>:</dt>
   1862 <dd>
   1863 <pre>
   1864 <tt>M
   1865 </tt></pre></dd>
   1866 </dl>
   1867 <p>The middle line of the display shall be calculated as follows:</p>
   1868 <pre>
   1869 <tt>(the top line of the display) + (((number of lines displayed) +1) /2) -1
   1870 </tt></pre>
   1871 <p>If used as a motion command:</p>
   1872 <ol>
   1873 <li>
   1874 <p>If in open mode, the text region shall be the current line.</p>
   1875 </li>
   1876 <li>
   1877 <p>Otherwise, the text region shall include all lines from the starting cursor line up to and including the middle line of the
   1878 display.</p>
   1879 </li>
   1880 <li>
   1881 <p>Any text copied to a buffer shall be in line mode.</p>
   1882 </li>
   1883 </ol>
   1884 <p>If not used as a motion command:</p>
   1885 <p>If in open mode, this command shall set the current column to non-&lt;blank&gt; and do nothing else.</p>
   1886 <p>Otherwise, it shall set the current line and current column as follows.</p>
   1887 <p><i>Current line</i>: Set to the middle line of the display.</p>
   1888 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1889 <h5><a name="tag_20_146_13_65" id="tag_20_146_13_65"></a>Repeat Regular Expression Find (Forward)</h5>
   1890 <dl compact>
   1891 <dd></dd>
   1892 <dt><i>Synopsis</i>:</dt>
   1893 <dd>
   1894 <pre>
   1895 <tt>n
   1896 </tt></pre></dd>
   1897 </dl>
   1898 <p>If the remembered search direction was forward, the <b>n</b> command shall be equivalent to the <i>vi</i> <b>/</b> command with
   1899 no characters entered by the user. Otherwise, it shall be equivalent to the <i>vi</i> <b>?</b> command with no characters entered
   1900 by the user.</p>
   1901 <p>If the <b>n</b> command is used as a motion command for the <b>!</b> command, the editor shall not enter text input mode on the
   1902 last line on the screen, and shall behave as if the user entered a single <tt>'!'</tt> character as the text input.</p>
   1903 <h5><a name="tag_20_146_13_66" id="tag_20_146_13_66"></a>Repeat Regular Expression Find (Reverse)</h5>
   1904 <dl compact>
   1905 <dd></dd>
   1906 <dt><i>Synopsis</i>:</dt>
   1907 <dd>
   1908 <pre>
   1909 <tt>N
   1910 </tt></pre></dd>
   1911 </dl>
   1912 <p>Scan for the next match of the last pattern given to <b>/</b> or <b>?</b>, but in the reverse direction; this is the reverse of
   1913 <b>n</b>.</p>
   1914 <p>If the remembered search direction was forward, the <b>N</b> command shall be equivalent to the <i>vi</i> <b>?</b> command with
   1915 no characters entered by the user. Otherwise, it shall be equivalent to the <i>vi</i> <b>/</b> command with no characters entered
   1916 by the user. If the <b>N</b> command is used as a motion command for the <b>!</b> command, the editor shall not enter text input
   1917 mode on the last line on the screen, and shall behave as if the user entered a single <b>!</b> character as the text input.</p>
   1918 <h5><a name="tag_20_146_13_67" id="tag_20_146_13_67"></a>Insert Empty Line Below</h5>
   1919 <dl compact>
   1920 <dd></dd>
   1921 <dt><i>Synopsis</i>:</dt>
   1922 <dd>
   1923 <pre>
   1924 <tt>o
   1925 </tt></pre></dd>
   1926 </dl>
   1927 <p>Enter text input mode in a new line appended after the current line. A <i>count</i> shall cause the input text to be appended
   1928 <i>count</i> -1 more times to the end of the already added text, each time starting on a new, appended line.</p>
   1929 <p><i>Current line/column</i>: As specified for the text input commands (see <a href="#tag_20_146_13_88">Input Mode Commands in
   1930 vi</a> ).</p>
   1931 <h5><a name="tag_20_146_13_68" id="tag_20_146_13_68"></a>Insert Empty Line Above</h5>
   1932 <dl compact>
   1933 <dd></dd>
   1934 <dt><i>Synopsis</i>:</dt>
   1935 <dd>
   1936 <pre>
   1937 <tt>O
   1938 </tt></pre></dd>
   1939 </dl>
   1940 <p>Enter text input mode in a new line inserted before the current line. A <i>count</i> shall cause the input text to be appended
   1941 <i>count</i> -1 more times to the end of the already added text, each time starting on a new, appended line.</p>
   1942 <p><i>Current line/column</i>: As specified for the text input commands (see <a href="#tag_20_146_13_88">Input Mode Commands in
   1943 vi</a> ).</p>
   1944 <h5><a name="tag_20_146_13_69" id="tag_20_146_13_69"></a>Put from Buffer Following</h5>
   1945 <dl compact>
   1946 <dd></dd>
   1947 <dt><i>Synopsis</i>:</dt>
   1948 <dd>
   1949 <pre>
   1950 <b>[</b><i>buffer</i><b>]</b><tt> p
   1951 </tt></pre></dd>
   1952 </dl>
   1953 <p>If no <i>buffer</i> is specified, the unnamed buffer shall be used.</p>
   1954 <p>If the buffer text is in line mode, the text shall be appended below the current line, and each line of the buffer shall become
   1955 a new line in the edit buffer. A <i>count</i> shall cause the buffer text to be appended <i>count</i> -1 more times to the end of
   1956 the already added text, each time starting on a new, appended line.</p>
   1957 <p>If the buffer text is in character mode, the text shall be appended into the current line after the cursor, and each line of the
   1958 buffer other than the first and last shall become a new line in the edit buffer. A <i>count</i> shall cause the buffer text to be
   1959 appended <i>count</i> -1 more times to the end of the already added text, each time starting after the last added character.</p>
   1960 <p><i>Current line</i>: If the buffer text is in line mode, set the line to line +1; otherwise, unchanged.</p>
   1961 <p><i>Current column</i>: If the buffer text is in line mode:</p>
   1962 <ol>
   1963 <li>
   1964 <p>If there is a non-&lt;blank&gt; in the first line of the buffer, set to the last column on which any portion of the first
   1965 non-&lt;blank&gt; in the line is displayed.</p>
   1966 </li>
   1967 <li>
   1968 <p>If there is no non-&lt;blank&gt; in the first line of the buffer, set to the last column on which any portion of the last
   1969 non-&lt;newline&gt; in the first line of the buffer is displayed.</p>
   1970 </li>
   1971 </ol>
   1972 <p>If the buffer text is in character mode:</p>
   1973 <ol>
   1974 <li>
   1975 <p>If the text in the buffer is from more than a single line, then set to the last column on which any portion of the first
   1976 character from the buffer is displayed.</p>
   1977 </li>
   1978 <li>
   1979 <p>Otherwise, if the buffer is the unnamed buffer, set to the last column on which any portion of the last character from the
   1980 buffer is displayed.</p>
   1981 </li>
   1982 <li>
   1983 <p>Otherwise, set to the first column on which any portion of the first character from the buffer is displayed.</p>
   1984 </li>
   1985 </ol>
   1986 <h5><a name="tag_20_146_13_70" id="tag_20_146_13_70"></a>Put from Buffer Before</h5>
   1987 <dl compact>
   1988 <dd></dd>
   1989 <dt><i>Synopsis</i>:</dt>
   1990 <dd>
   1991 <pre>
   1992 <b>[</b><i>buffer</i><b>]</b><tt> P
   1993 </tt></pre></dd>
   1994 </dl>
   1995 <p>If no <i>buffer</i> is specified, the unnamed buffer shall be used.</p>
   1996 <p>If the buffer text is in line mode, the text shall be inserted above the current line, and each line of the buffer shall become
   1997 a new line in the edit buffer. A <i>count</i> shall cause the buffer text to be appended <i>count</i> -1 more times to the end of
   1998 the already added text, each time starting on a new, appended line.</p>
   1999 <p>If the buffer text is in character mode, the text shall be inserted into the current line before the cursor, and each line of
   2000 the buffer other than the first and last shall become a new line in the edit buffer. A <i>count</i> shall cause the buffer text to
   2001 be appended <i>count</i> -1 more times to the end of the already added text, each time starting after the last added character.</p>
   2002 <p><i>Current line</i>: Unchanged.</p>
   2003 <p><i>Current column</i>: If the buffer text is in line mode:</p>
   2004 <ol>
   2005 <li>
   2006 <p>If there is a non-&lt;blank&gt; in the first line of the buffer, set to the last column on which any portion of that character
   2007 is displayed.</p>
   2008 </li>
   2009 <li>
   2010 <p>If there is no non-&lt;blank&gt; in the first line of the buffer, set to the last column on which any portion of the last
   2011 non-&lt;newline&gt; in the first line of the buffer is displayed.</p>
   2012 </li>
   2013 </ol>
   2014 <p>If the buffer text is in character mode:</p>
   2015 <ol>
   2016 <li>
   2017 <p>If the text in the buffer is from more than a single line, then set to the last column on which any portion of the first
   2018 character from the buffer is displayed.</p>
   2019 </li>
   2020 <li>
   2021 <p>Otherwise, if the buffer is the unnamed buffer, set to the last column on which any portion of the last character from the
   2022 buffer is displayed.</p>
   2023 </li>
   2024 <li>
   2025 <p>Otherwise, set to the first column on which any portion of the first character from the buffer is displayed.</p>
   2026 </li>
   2027 </ol>
   2028 <h5><a name="tag_20_146_13_71" id="tag_20_146_13_71"></a>Enter ex Mode</h5>
   2029 <dl compact>
   2030 <dd></dd>
   2031 <dt><i>Synopsis</i>:</dt>
   2032 <dd>
   2033 <pre>
   2034 <tt>Q
   2035 </tt></pre></dd>
   2036 </dl>
   2037 <p>Leave visual or open mode and enter <a href="../utilities/ex.html"><i>ex</i></a> command mode.</p>
   2038 <p><i>Current line</i>: Unchanged.</p>
   2039 <p><i>Current column</i>: Unchanged.</p>
   2040 <h5><a name="tag_20_146_13_72" id="tag_20_146_13_72"></a>Replace Character</h5>
   2041 <dl compact>
   2042 <dd></dd>
   2043 <dt><i>Synopsis</i>:</dt>
   2044 <dd>
   2045 <pre>
   2046 <b>[</b><i>count</i><b>]</b><tt> r </tt><i>character</i><tt>
   2047 </tt></pre></dd>
   2048 </dl>
   2049 <p>Replace the <i>count</i> characters at and after the cursor with the specified character. If there are less than <i>count</i>
   2050 non-&lt;newline&gt; characters at and after the cursor on the line, it shall be an error.</p>
   2051 <p>If character is &lt;control&gt;-V, any next character other than the &lt;newline&gt; shall be stripped of any special meaning
   2052 and used as a literal character.</p>
   2053 <p>If character is &lt;ESC&gt;, no replacement shall be made and the current line and current column shall be unchanged.</p>
   2054 <p>If character is &lt;carriage-return&gt; or &lt;newline&gt;, <i>count</i> new lines shall be appended to the current line. All
   2055 but the last of these lines shall be empty. <i>count</i> characters at and after the cursor shall be discarded, and any remaining
   2056 characters after the cursor in the current line shall be moved to the last of the new lines. If the <b>autoindent</b> edit option
   2057 is set, they shall be preceded by the same number of <b>autoindent</b> characters found on the line from which the command was
   2058 executed.</p>
   2059 <p><i>Current line</i>: Unchanged unless the replacement character is a &lt;carriage-return&gt; or &lt;newline&gt;, in which case
   2060 it shall be set to line + <i>count</i>.</p>
   2061 <p><i>Current column</i>: Set to the last column position on which a portion of the last replaced character is displayed, or if the
   2062 replacement character caused new lines to be created, set to non-&lt;blank&gt;.</p>
   2063 <h5><a name="tag_20_146_13_73" id="tag_20_146_13_73"></a>Replace Characters</h5>
   2064 <dl compact>
   2065 <dd></dd>
   2066 <dt><i>Synopsis</i>:</dt>
   2067 <dd>
   2068 <pre>
   2069 <tt>R
   2070 </tt></pre></dd>
   2071 </dl>
   2072 <p>Enter text input mode at the current cursor position possibly replacing text on the current line. A <i>count</i> shall cause the
   2073 input text to be appended <i>count</i> -1 more times to the end of the input.</p>
   2074 <p><i>Current line/column</i>: As specified for the text input commands (see <a href="#tag_20_146_13_88">Input Mode Commands in
   2075 vi</a> ).</p>
   2076 <h5><a name="tag_20_146_13_74" id="tag_20_146_13_74"></a>Substitute Character</h5>
   2077 <dl compact>
   2078 <dd></dd>
   2079 <dt><i>Synopsis</i>:</dt>
   2080 <dd>
   2081 <pre>
   2082 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> s
   2083 </tt></pre></dd>
   2084 </dl>
   2085 <p>This command shall be equivalent to the <i>vi</i> command:</p>
   2086 <pre>
   2087 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> c&lt;space&gt;
   2088 </tt></pre>
   2089 <h5><a name="tag_20_146_13_75" id="tag_20_146_13_75"></a>Substitute Lines</h5>
   2090 <dl compact>
   2091 <dd></dd>
   2092 <dt><i>Synopsis</i>:</dt>
   2093 <dd>
   2094 <pre>
   2095 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> S
   2096 </tt></pre></dd>
   2097 </dl>
   2098 <p>This command shall be equivalent to the <i>vi</i> command:</p>
   2099 <pre>
   2100 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> c_
   2101 </tt></pre>
   2102 <h5><a name="tag_20_146_13_76" id="tag_20_146_13_76"></a>Move Cursor to Before Character (Forward)</h5>
   2103 <dl compact>
   2104 <dd></dd>
   2105 <dt><i>Synopsis</i>:</dt>
   2106 <dd>
   2107 <pre>
   2108 <b>[</b><i>count</i><b>]</b><tt> t </tt><i>character</i><tt>
   2109 </tt></pre></dd>
   2110 </dl>
   2111 <p>It shall be an error if <i>count</i> occurrences of the character do not occur after the cursor in the line.</p>
   2112 <p>If used as a motion command:</p>
   2113 <ol>
   2114 <li>
   2115 <p>The text region shall be from the cursor up to but not including the <i>count</i>th occurrence of the specified character after
   2116 the cursor.</p>
   2117 </li>
   2118 <li>
   2119 <p>Any text copied to a buffer shall be in character mode.</p>
   2120 </li>
   2121 </ol>
   2122 <p>If not used as a motion command:</p>
   2123 <p><i>Current line</i>: Unchanged.</p>
   2124 <p><i>Current column</i>: Set to the last column in which any portion of the character before the <i>count</i>th occurrence of the
   2125 specified character after the cursor appears in the line.</p>
   2126 <h5><a name="tag_20_146_13_77" id="tag_20_146_13_77"></a>Move Cursor to After Character (Reverse)</h5>
   2127 <dl compact>
   2128 <dd></dd>
   2129 <dt><i>Synopsis</i>:</dt>
   2130 <dd>
   2131 <pre>
   2132 <b>[</b><i>count</i><b>]</b><tt> T </tt><i>character</i><tt>
   2133 </tt></pre></dd>
   2134 </dl>
   2135 <p>It shall be an error if <i>count</i> occurrences of the character do not occur before the cursor in the line.</p>
   2136 <p>If used as a motion command:</p>
   2137 <ol>
   2138 <li>
   2139 <p>If the character before the cursor is the specified character, it shall be an error.</p>
   2140 </li>
   2141 <li>
   2142 <p>The text region shall be from the character before the cursor up to but not including the <i>count</i>th occurrence of the
   2143 specified character before the cursor.</p>
   2144 </li>
   2145 <li>
   2146 <p>Any text copied to a buffer shall be in character mode.</p>
   2147 </li>
   2148 </ol>
   2149 <p>If not used as a motion command:</p>
   2150 <p><i>Current line</i>: Unchanged.</p>
   2151 <p><i>Current column</i>: Set to the last column in which any portion of the character after the <i>count</i>th occurrence of the
   2152 specified character before the cursor appears in the line.</p>
   2153 <h5><a name="tag_20_146_13_78" id="tag_20_146_13_78"></a>Undo</h5>
   2154 <dl compact>
   2155 <dd></dd>
   2156 <dt><i>Synopsis</i>:</dt>
   2157 <dd>
   2158 <pre>
   2159 <tt>u
   2160 </tt></pre></dd>
   2161 </dl>
   2162 <p>This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>undo</b> command except that the current
   2163 line and current column shall be set as follows:</p>
   2164 <p><i>Current line</i>: Set to the first line added or changed if any; otherwise, move to the line preceding any deleted text if
   2165 one exists; otherwise, move to line 1.</p>
   2166 <p><i>Current column</i>: If undoing an <a href="../utilities/ex.html"><i>ex</i></a> command, set to the first
   2167 non-&lt;blank&gt;.</p>
   2168 <p>Otherwise, if undoing a text input command:</p>
   2169 <ol>
   2170 <li>
   2171 <p>If the command was a <b>C</b>, <b>c</b>, <b>O</b>, <b>o</b>, <b>R</b>, <b>S</b>, or <b>s</b> command, the current column shall
   2172 be set to the value it held when the text input command was entered.</p>
   2173 </li>
   2174 <li>
   2175 <p>Otherwise, set to the last column in which any portion of the first character after the deleted text is displayed, or, if no
   2176 non-&lt;newline&gt; characters follow the text deleted from this line, set to the last column in which any portion of the last
   2177 non-&lt;newline&gt; in the line is displayed, or 1 if the line is empty.</p>
   2178 </li>
   2179 </ol>
   2180 <p>Otherwise, if a single line was modified (that is, not added or deleted) by the <b>u</b> command:</p>
   2181 <ol>
   2182 <li>
   2183 <p>If text was added or changed, set to the last column in which any portion of the first character added or changed is
   2184 displayed.</p>
   2185 </li>
   2186 <li>
   2187 <p>If text was deleted, set to the last column in which any portion of the first character after the deleted text is displayed, or,
   2188 if no non-&lt;newline&gt; characters follow the deleted text, set to the last column in which any portion of the last
   2189 non-&lt;newline&gt; in the line is displayed, or 1 if the line is empty.</p>
   2190 </li>
   2191 </ol>
   2192 <p>Otherwise, set to non-&lt;blank&gt;.</p>
   2193 <h5><a name="tag_20_146_13_79" id="tag_20_146_13_79"></a>Undo Current Line</h5>
   2194 <dl compact>
   2195 <dd></dd>
   2196 <dt><i>Synopsis</i>:</dt>
   2197 <dd>
   2198 <pre>
   2199 <tt>U
   2200 </tt></pre></dd>
   2201 </dl>
   2202 <p>Restore the current line to its state immediately before the most recent time that it became the current line.</p>
   2203 <p><i>Current line</i>: Unchanged.</p>
   2204 <p><i>Current column</i>: Set to the first column in the line in which any portion of the first character in the line is
   2205 displayed.</p>
   2206 <h5><a name="tag_20_146_13_80" id="tag_20_146_13_80"></a>Move to Beginning of Word</h5>
   2207 <dl compact>
   2208 <dd></dd>
   2209 <dt><i>Synopsis</i>:</dt>
   2210 <dd>
   2211 <pre>
   2212 <b>[</b><i>count</i><b>]</b><tt> w
   2213 </tt></pre></dd>
   2214 </dl>
   2215 <p>With the exception that words are used as the delimiter instead of bigwords, this command shall be equivalent to the <b>W</b>
   2216 command.</p>
   2217 <h5><a name="tag_20_146_13_81" id="tag_20_146_13_81"></a>Move to Beginning of Bigword</h5>
   2218 <dl compact>
   2219 <dd></dd>
   2220 <dt><i>Synopsis</i>:</dt>
   2221 <dd>
   2222 <pre>
   2223 <b>[</b><i>count</i><b>]</b><tt> W
   2224 </tt></pre></dd>
   2225 </dl>
   2226 <p>If the edit buffer is empty, it shall be an error. If there are less than <i>count</i> bigwords between the cursor and the end
   2227 of the edit buffer, <i>count</i> shall be adjusted to move the cursor to the last bigword in the edit buffer.</p>
   2228 <p>If used as a motion command:</p>
   2229 <ol>
   2230 <li>
   2231 <p>If the associated command is <b>c</b>, <i>count</i> is 1, and the cursor is on a &lt;blank&gt;, the region of text shall be the
   2232 current character and no further action shall be taken.</p>
   2233 </li>
   2234 <li>
   2235 <p>If there are less than <i>count</i> bigwords between the cursor and the end of the edit buffer, then the command shall succeed,
   2236 and the region of text shall include the last character of the edit buffer.</p>
   2237 </li>
   2238 <li>
   2239 <p>If there are &lt;blank&gt; characters or an end-of-line that precede the <i>count</i>th bigword, and the associated command is
   2240 <b>c</b>, the region of text shall be up to and including the last character before the preceding &lt;blank&gt; characters or
   2241 end-of-line.</p>
   2242 </li>
   2243 <li>
   2244 <p>If there are &lt;blank&gt; characters or an end-of-line that precede the bigword, and the associated command is <b>d</b> or
   2245 <b>y</b>, the region of text shall be up to and including the last &lt;blank&gt; before the start of the bigword or
   2246 end-of-line.</p>
   2247 </li>
   2248 <li>
   2249 <p>Any text copied to a buffer shall be in character mode.</p>
   2250 </li>
   2251 </ol>
   2252 <p>If not used as a motion command:</p>
   2253 <ol>
   2254 <li>
   2255 <p>If the cursor is on the last character of the edit buffer, it shall be an error.</p>
   2256 </li>
   2257 </ol>
   2258 <p><i>Current line</i>: Set to the line containing the current column.</p>
   2259 <p><i>Current column</i>: Set to the last column in which any part of the first character of the <i>count</i>th next bigword is
   2260 displayed.</p>
   2261 <h5><a name="tag_20_146_13_82" id="tag_20_146_13_82"></a>Delete Character at Cursor</h5>
   2262 <dl compact>
   2263 <dd></dd>
   2264 <dt><i>Synopsis</i>:</dt>
   2265 <dd>
   2266 <pre>
   2267 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> x
   2268 </tt></pre></dd>
   2269 </dl>
   2270 <p>Delete the <i>count</i> characters at and after the current character into <i>buffer</i>, if specified, and into the unnamed
   2271 buffer.</p>
   2272 <p>If the line is empty, it shall be an error. If there are less than <i>count</i> non-&lt;newline&gt; characters at and after the
   2273 cursor on the current line, <i>count</i> shall be adjusted to the number of non-&lt;newline&gt; characters at and after the
   2274 cursor.</p>
   2275 <p><i>Current line</i>: Unchanged.</p>
   2276 <p><i>Current column</i>: If the line is empty, set to column position 1. Otherwise, if there were <i>count</i> or less
   2277 non-&lt;newline&gt; characters at and after the cursor on the current line, set to the last column that displays any part of the
   2278 last non-&lt;newline&gt; of the line. Otherwise, unchanged.</p>
   2279 <h5><a name="tag_20_146_13_83" id="tag_20_146_13_83"></a>Delete Character Before Cursor</h5>
   2280 <dl compact>
   2281 <dd></dd>
   2282 <dt><i>Synopsis</i>:</dt>
   2283 <dd>
   2284 <pre>
   2285 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> X
   2286 </tt></pre></dd>
   2287 </dl>
   2288 <p>Delete the <i>count</i> characters before the current character into <i>buffer</i>, if specified, and into the unnamed
   2289 buffer.</p>
   2290 <p>If there are no characters before the current character on the current line, it shall be an error. If there are less than
   2291 <i>count</i> previous characters on the current line, <i>count</i> shall be adjusted to the number of previous characters on the
   2292 line.</p>
   2293 <p><i>Current line</i>: Unchanged.</p>
   2294 <p><i>Current column</i>: Set to (current column - the width of the deleted characters).</p>
   2295 <h5><a name="tag_20_146_13_84" id="tag_20_146_13_84"></a>Yank</h5>
   2296 <dl compact>
   2297 <dd></dd>
   2298 <dt><i>Synopsis</i>:</dt>
   2299 <dd>
   2300 <pre>
   2301 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> y </tt><i>motion</i><tt>
   2302 </tt></pre></dd>
   2303 </dl>
   2304 <p>Copy (yank) the region of text into <i>buffer</i>, if specified, and into the unnamed buffer.</p>
   2305 <p>If the motion command is the <b>y</b> command repeated:</p>
   2306 <ol>
   2307 <li>
   2308 <p>The buffer shall be in line mode.</p>
   2309 </li>
   2310 <li>
   2311 <p>If there are less than <i>count</i> -1 lines after the current line in the edit buffer, it shall be an error.</p>
   2312 </li>
   2313 <li>
   2314 <p>The text region shall be from the current line up to and including the next <i>count</i> -1 lines.</p>
   2315 </li>
   2316 </ol>
   2317 <p>Otherwise, the buffer text mode and text region shall be as specified by the motion command.</p>
   2318 <p><i>Current line</i>: If the motion was from the current cursor position toward the end of the edit buffer, unchanged. Otherwise,
   2319 set to the first line in the edit buffer that is part of the text region specified by the motion command.</p>
   2320 <p><i>Current column</i>:</p>
   2321 <ol>
   2322 <li>
   2323 <p>If the motion was from the current cursor position toward the end of the edit buffer, unchanged.</p>
   2324 </li>
   2325 <li>
   2326 <p>Otherwise, if the current line is empty, set to column position 1.</p>
   2327 </li>
   2328 <li>
   2329 <p>Otherwise, set to the last column that displays any part of the first character in the file that is part of the text region
   2330 specified by the motion command.</p>
   2331 </li>
   2332 </ol>
   2333 <h5><a name="tag_20_146_13_85" id="tag_20_146_13_85"></a>Yank Current Line</h5>
   2334 <dl compact>
   2335 <dd></dd>
   2336 <dt><i>Synopsis</i>:</dt>
   2337 <dd>
   2338 <pre>
   2339 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> Y
   2340 </tt></pre></dd>
   2341 </dl>
   2342 <p>This command shall be equivalent to the <i>vi</i> command:</p>
   2343 <pre>
   2344 <b>[</b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt> y_
   2345 </tt></pre>
   2346 <h5><a name="tag_20_146_13_86" id="tag_20_146_13_86"></a>Redraw Window</h5>
   2347 <p>If in open mode, the <b>z</b> command shall have the Synopsis:</p>
   2348 <dl compact>
   2349 <dd></dd>
   2350 <dt><i>Synopsis</i>:</dt>
   2351 <dd>
   2352 <pre>
   2353 <b>[</b><i>count</i><b>]</b><tt> z
   2354 </tt></pre></dd>
   2355 </dl>
   2356 <p>If <i>count</i> is not specified, it shall default to the <b>window</b> edit option -1. The <b>z</b> command shall be equivalent
   2357 to the <a href="../utilities/ex.html"><i>ex</i></a> <b>z</b> command, with a type character of <b>=</b> and a <i>count</i> of
   2358 <i>count</i> -2, except that the current line and current column shall be set as follows, and the <b>window</b> edit option shall
   2359 not be affected. If the calculation for the <i>count</i> argument would result in a negative number, the <i>count</i> argument to
   2360 the <a href="../utilities/ex.html"><i>ex</i></a> <b>z</b> command shall be zero. A blank line shall be written after the last line
   2361 is written.</p>
   2362 <p><i>Current line</i>: Unchanged.</p>
   2363 <p><i>Current column</i>: Unchanged.</p>
   2364 <p>If not in open mode, the <b>z</b> command shall have the following Synopsis:</p>
   2365 <dl compact>
   2366 <dd></dd>
   2367 <dt><i>Synopsis</i>:</dt>
   2368 <dd>
   2369 <pre>
   2370 <b>[</b><i>line</i><b>]</b><tt> z </tt><b>[</b><i>count</i><b>] </b><i>character</i><tt>
   2371 </tt></pre></dd>
   2372 </dl>
   2373 <p>If <i>line</i> is not specified, it shall default to the current line. If <i>line</i> is specified, but is greater than the
   2374 number of lines in the edit buffer, it shall default to the number of lines in the edit buffer.</p>
   2375 <p>If <i>count</i> is specified, the value of the <b>window</b> edit option shall be set to <i>count</i> (as described in the
   2376 <a href="../utilities/ex.html"><i>ex</i></a> <b>window</b> command), and the screen shall be redrawn.</p>
   2377 <p><i>line</i> shall be placed as specified by the following characters:</p>
   2378 <dl compact>
   2379 <dd></dd>
   2380 <dt>&lt;newline&gt;,&nbsp;&lt;carriage-return&gt;</dt>
   2381 <dd><br>
   2382 Place the beginning of the line on the first line of the display.</dd>
   2383 <dt><tt>.</tt></dt>
   2384 <dd>Place the beginning of the line in the center of the display. The middle line of the display shall be calculated as described
   2385 for the <b>M</b> command.</dd>
   2386 <dt><tt>-</tt></dt>
   2387 <dd>Place an unspecified portion of the line on the last line of the display.</dd>
   2388 <dt><tt>+</tt></dt>
   2389 <dd>If <i>line</i> was specified, equivalent to the &lt;newline&gt; case. If <i>line</i> was not specified, display a screen where
   2390 the first line of the display shall be (current last line) +1. If there are no lines after the last line in the display, it shall
   2391 be an error.</dd>
   2392 <dt><tt>^</tt></dt>
   2393 <dd>If <i>line</i> was specified, display a screen where the last line of the display shall contain an unspecified portion of the
   2394 first line of a display that had an unspecified portion of the specified line on the last line of the display. If this calculation
   2395 results in a line before the beginning of the edit buffer, display the first screen of the edit buffer.
   2396 <p>Otherwise, display a screen where the last line of the display shall contain an unspecified portion of (current first line -1).
   2397 If this calculation results in a line before the beginning of the edit buffer, it shall be an error.</p>
   2398 </dd>
   2399 </dl>
   2400 <br>
   2401 <p><i>Current line</i>: If <i>line</i> and the <tt>'^'</tt> character were specified:</p>
   2402 <ol>
   2403 <li>
   2404 <p>If the first screen was displayed as a result of the command attempting to display lines before the beginning of the edit
   2405 buffer: if the first screen was already displayed, unchanged; otherwise, set to (current first line -1).</p>
   2406 </li>
   2407 <li>
   2408 <p>Otherwise, set to the last line of the display.</p>
   2409 </li>
   2410 </ol>
   2411 <p>If <i>line</i> and the <tt>'+'</tt> character were specified, set to the first line of the display.</p>
   2412 <p>Otherwise, if <i>line</i> was specified, set to <i>line</i>.</p>
   2413 <p>Otherwise, unchanged.</p>
   2414 <p><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   2415 <h5><a name="tag_20_146_13_87" id="tag_20_146_13_87"></a>Exit</h5>
   2416 <dl compact>
   2417 <dd></dd>
   2418 <dt><i>Synopsis</i>:</dt>
   2419 <dd>
   2420 <pre>
   2421 <tt>ZZ
   2422 </tt></pre></dd>
   2423 </dl>
   2424 <p>This command shall be equivalent to the <a href="../utilities/ex.html"><i>ex</i></a> <b>xit</b> command with no addresses,
   2425 trailing <b>!</b>, or filename (see the <a href="../utilities/ex.html"><i>ex</i></a> <b>xit</b> command).</p>
   2426 <h5><a name="tag_20_146_13_88" id="tag_20_146_13_88"></a>Input Mode Commands in vi</h5>
   2427 <p>In text input mode, the current line shall consist of zero or more of the following categories, plus the terminating
   2428 &lt;newline&gt;:</p>
   2429 <ol>
   2430 <li>
   2431 <p>Characters preceding the text input entry point</p>
   2432 <p>Characters in this category shall not be modified during text input mode.</p>
   2433 </li>
   2434 <li>
   2435 <p><b>autoindent</b> characters</p>
   2436 <p><b>autoindent</b> characters shall be automatically inserted into each line that is created in text input mode, either as a
   2437 result of entering a &lt;newline&gt; or &lt;carriage-return&gt; while in text input mode, or as an effect of the command itself;
   2438 for example, <b>O</b> or <b>o</b> (see the <a href="../utilities/ex.html"><i>ex</i></a> <b>autoindent</b> command), as if entered
   2439 by the user.</p>
   2440 <p>It shall be possible to erase <b>autoindent</b> characters with the &lt;control&gt;-D command; it is unspecified whether they
   2441 can be erased by &lt;control&gt;-H, &lt;control&gt;-U, and &lt;control&gt;-W characters. Erasing any <b>autoindent</b> character
   2442 turns the glyph into erase-columns and deletes the character from the edit buffer, but does not change its representation on the
   2443 screen.</p>
   2444 </li>
   2445 <li>
   2446 <p>Text input characters</p>
   2447 <p>Text input characters are the characters entered by the user. Erasing any text input character turns the glyph into
   2448 erase-columns and deletes the character from the edit buffer, but does not change its representation on the screen.</p>
   2449 <p>Each text input character entered by the user (that does not have a special meaning) shall be treated as follows:</p>
   2450 <ol type="a">
   2451 <li>
   2452 <p>The text input character shall be appended to the last character in the edit buffer from the first, second, or third
   2453 categories.</p>
   2454 </li>
   2455 <li>
   2456 <p>If there are no erase-columns on the screen, the text input command was the <b>R</b> command, and characters in the fifth
   2457 category from the original line follow the cursor, the next such character shall be deleted from the edit buffer. If the
   2458 <b>slowopen</b> edit option is not set, the corresponding glyph on the screen shall become erase-columns.</p>
   2459 </li>
   2460 <li>
   2461 <p>If there are erase-columns on the screen, as many columns as they occupy, or as are necessary, shall be overwritten to display
   2462 the text input character. (If only part of a multi-column glyph is overwritten, the remainder shall be left on the screen, and
   2463 continue to be treated as erase-columns; it is unspecified whether the remainder of the glyph is modified in any way.)</p>
   2464 </li>
   2465 <li>
   2466 <p>If additional display line columns are needed to display the text input character:</p>
   2467 <ol type="i">
   2468 <li>
   2469 <p>If the <b>slowopen</b> edit option is set, the text input characters shall be displayed on subsequent display line columns,
   2470 overwriting any characters displayed in those columns.</p>
   2471 </li>
   2472 <li>
   2473 <p>Otherwise, any characters currently displayed on or after the column on the display line where the text input character is to be
   2474 displayed shall be pushed ahead the number of display line columns necessary to display the rest of the text input character.</p>
   2475 </li>
   2476 </ol>
   2477 </li>
   2478 </ol>
   2479 </li>
   2480 <li>
   2481 <p>Erase-columns</p>
   2482 <p>Erase-columns are not logically part of the edit buffer, appearing only on the screen, and may be overwritten on the screen by
   2483 subsequent text input characters. When text input mode ends, all erase-columns shall no longer appear on the screen.</p>
   2484 <p>Erase-columns are initially the region of text specified by the <b>c</b> command (see <a href="#tag_20_146_13_49">Change</a> );
   2485 however, erasing <b>autoindent</b> or text input characters causes the glyphs of the erased characters to be treated as
   2486 erase-columns.</p>
   2487 </li>
   2488 <li>
   2489 <p>Characters following the text region for the <b>c</b> command, or the text input entry point for all other commands</p>
   2490 <p>Characters in this category shall not be modified during text input mode, except as specified in category 3.b. for the <b>R</b>
   2491 text input command, or as &lt;blank&gt; characters deleted when a &lt;newline&gt; or &lt;carriage-return&gt; is entered.</p>
   2492 </li>
   2493 </ol>
   2494 <p>It is unspecified whether it is an error to attempt to erase past the beginning of a line that was created by the entry of a
   2495 &lt;newline&gt; or &lt;carriage-return&gt; during text input mode. If it is not an error, the editor shall behave as if the erasing
   2496 character was entered immediately after the last text input character entered on the previous line, and all of the
   2497 non-&lt;newline&gt; characters on the current line shall be treated as erase-columns.</p>
   2498 <p>When text input mode is entered, or after a text input mode character is entered (except as specified for the special characters
   2499 below), the cursor shall be positioned as follows:</p>
   2500 <ol>
   2501 <li>
   2502 <p>On the first column that displays any part of the first erase-column, if one exists</p>
   2503 </li>
   2504 <li>
   2505 <p>Otherwise, if the <b>slowopen</b> edit option is set, on the first display line column after the last character in the first,
   2506 second, or third categories, if one exists</p>
   2507 </li>
   2508 <li>
   2509 <p>Otherwise, the first column that displays any part of the first character in the fifth category, if one exists</p>
   2510 </li>
   2511 <li>
   2512 <p>Otherwise, the display line column after the last character in the first, second, or third categories, if one exists</p>
   2513 </li>
   2514 <li>
   2515 <p>Otherwise, on column position 1</p>
   2516 </li>
   2517 </ol>
   2518 <p>The characters that are updated on the screen during text input mode are unspecified, other than that the last text input
   2519 character shall always be updated, and, if the <b>slowopen</b> edit option is not set, the current cursor character shall always be
   2520 updated.</p>
   2521 <p>The following specifications are for command characters entered during text input mode.</p>
   2522 <h5><a name="tag_20_146_13_89" id="tag_20_146_13_89"></a>NUL</h5>
   2523 <dl compact>
   2524 <dd></dd>
   2525 <dt><i>Synopsis</i>:</dt>
   2526 <dd>
   2527 <pre>
   2528 <tt>NUL
   2529 </tt></pre></dd>
   2530 </dl>
   2531 <p>If the first character of the text input is a NUL, the most recently input text shall be input as if entered by the user, and
   2532 then text input mode shall be exited. The text shall be input literally; that is, characters are neither macro or abbreviation
   2533 expanded, nor are any characters interpreted in any special manner. It is unspecified whether implementations shall support more
   2534 than 256 bytes of remembered input text.</p>
   2535 <h5><a name="tag_20_146_13_90" id="tag_20_146_13_90"></a>&lt;control&gt;-D</h5>
   2536 <dl compact>
   2537 <dd></dd>
   2538 <dt><i>Synopsis</i>:</dt>
   2539 <dd>
   2540 <pre>
   2541 <tt>&lt;control&gt;-D
   2542 </tt></pre></dd>
   2543 </dl>
   2544 <p>The &lt;control&gt;-D character shall have no special meaning when in text input mode for a line-oriented command (see <a href=
   2545 "#tag_20_146_13_02">Command Descriptions in vi</a> ).</p>
   2546 <p>This command need not be supported on block-mode terminals.</p>
   2547 <p>If the cursor does not follow an <b>autoindent</b> character, or an <b>autoindent</b> character and a <tt>'0'</tt> or
   2548 <tt>'^'</tt> character:</p>
   2549 <ol>
   2550 <li>
   2551 <p>If the cursor is in column position 1, the &lt;control&gt;-D character shall be discarded and no further action taken.</p>
   2552 </li>
   2553 <li>
   2554 <p>Otherwise, the &lt;control&gt;-D character shall have no special meaning.</p>
   2555 </li>
   2556 </ol>
   2557 <p>If the last input character was a <tt>'0'</tt>, the cursor shall be moved to column position 1.</p>
   2558 <p>Otherwise, if the last input character was a <tt>'^'</tt>, the cursor shall be moved to column position 1. In addition, the
   2559 <b>autoindent</b> level for the next input line shall be derived from the same line from which the <b>autoindent</b> level for the
   2560 current input line was derived.</p>
   2561 <p>Otherwise, the cursor shall be moved back to the column after the previous shiftwidth (see the <a href=
   2562 "../utilities/ex.html"><i>ex</i></a> <b>shiftwidth</b> command) boundary.</p>
   2563 <p>All of the glyphs on columns between the starting cursor position and (inclusively) the ending cursor position shall become
   2564 erase-columns as described in <a href="#tag_20_146_13_88">Input Mode Commands in vi</a> .</p>
   2565 <p><i>Current line</i>: Unchanged.</p>
   2566 <p><i>Current column</i>: Set to 1 if the &lt;control&gt;-D was preceded by a <tt>'^'</tt> or <tt>'0'</tt>; otherwise, set to
   2567 (column -1) -((column -2) % <b>shiftwidth</b>).</p>
   2568 <h5><a name="tag_20_146_13_91" id="tag_20_146_13_91"></a>&lt;control&gt;-H</h5>
   2569 <dl compact>
   2570 <dd></dd>
   2571 <dt><i>Synopsis</i>:</dt>
   2572 <dd>
   2573 <pre>
   2574 <tt>&lt;control&gt;-H
   2575 </tt></pre></dd>
   2576 </dl>
   2577 <p>If in text input mode for a line-oriented command, and there are no characters to erase, text input mode shall be terminated, no
   2578 further action shall be done for this command, and the current line and column shall be unchanged.</p>
   2579 <p>If there are characters other than <b>autoindent</b> characters that have been input on the current line before the cursor, the
   2580 cursor shall move back one character.</p>
   2581 <p>Otherwise, if there are <b>autoindent</b> characters on the current line before the cursor, it is implementation-defined whether
   2582 the &lt;control&gt;-H command is an error or if the cursor moves back one <b>autoindent</b> character.</p>
   2583 <p>Otherwise, if the cursor is in column position 1 and there are previous lines that have been input, it is implementation-defined
   2584 whether the &lt;control&gt;-H command is an error or if it is equivalent to entering &lt;control&gt;-H after the last input
   2585 character on the previous input line.</p>
   2586 <p>Otherwise, it shall be an error.</p>
   2587 <p>All of the glyphs on columns between the starting cursor position and (inclusively) the ending cursor position shall become
   2588 erase-columns as described in <a href="#tag_20_146_13_88">Input Mode Commands in vi</a> .</p>
   2589 <p>The current erase character (see <a href="../utilities/stty.html"><i>stty</i></a>) shall cause an equivalent action to the
   2590 &lt;control&gt;-H command, unless the previously inserted character was a &lt;backslash&gt;, in which case it shall be as if the
   2591 literal current erase character had been inserted instead of the &lt;backslash&gt;.</p>
   2592 <p><i>Current line</i>: Unchanged, unless previously input lines are erased, in which case it shall be set to line -1.</p>
   2593 <p><i>Current column</i>: Set to the first column that displays any portion of the character backed up over.</p>
   2594 <h5><a name="tag_20_146_13_92" id="tag_20_146_13_92"></a>&lt;newline&gt;</h5>
   2595 <dl compact>
   2596 <dd></dd>
   2597 <dt><i>Synopsis</i>:</dt>
   2598 <dd>
   2599 <pre>
   2600 <tt>&lt;newline&gt;
   2601 <br>
   2602 &lt;carriage-return&gt;
   2603 <br>
   2604 &lt;control&gt;-J
   2605 <br>
   2606 &lt;control&gt;-M
   2607 </tt></pre></dd>
   2608 </dl>
   2609 <p>If input was part of a line-oriented command, text input mode shall be terminated and the command shall continue execution with
   2610 the input provided.</p>
   2611 <p>Otherwise, terminate the current line. If there are no characters other than <b>autoindent</b> characters on the line, all
   2612 characters on the line shall be discarded. Otherwise, it is unspecified whether the <b>autoindent</b> characters in the line are
   2613 modified by entering these characters.</p>
   2614 <p>Continue text input mode on a new line appended after the current line. If the <b>slowopen</b> edit option is set, the lines on
   2615 the screen below the current line shall not be pushed down, but the first of them shall be cleared and shall appear to be
   2616 overwritten. Otherwise, the lines of the screen below the current line shall be pushed down.</p>
   2617 <p>If the <b>autoindent</b> edit option is set, an appropriate number of <b>autoindent</b> characters shall be added as a prefix to
   2618 the line as described by the <a href="../utilities/ex.html"><i>ex</i></a> <b>autoindent</b> edit option.</p>
   2619 <p>All columns after the cursor that are erase-columns (as described in <a href="#tag_20_146_13_88">Input Mode Commands in vi</a> )
   2620 shall be discarded.</p>
   2621 <p>If the <b>autoindent</b> edit option is set, all &lt;blank&gt; characters immediately following the cursor shall be
   2622 discarded.</p>
   2623 <p>All remaining characters after the cursor shall be transferred to the new line, positioned after any <b>autoindent</b>
   2624 characters.</p>
   2625 <p><i>Current line</i>: Set to current line +1.</p>
   2626 <p><i>Current column</i>: Set to the first column that displays any portion of the first character after the <b>autoindent</b>
   2627 characters on the new line, if any, or the first column position after the last <b>autoindent</b> character, if any, or column
   2628 position 1.</p>
   2629 <h5><a name="tag_20_146_13_93" id="tag_20_146_13_93"></a>&lt;control&gt;-T</h5>
   2630 <dl compact>
   2631 <dd></dd>
   2632 <dt><i>Synopsis</i>:</dt>
   2633 <dd>
   2634 <pre>
   2635 <tt>&lt;control&gt;-T
   2636 </tt></pre></dd>
   2637 </dl>
   2638 <p>The &lt;control&gt;-T character shall have no special meaning when in text input mode for a line-oriented command (see <a href=
   2639 "#tag_20_146_13_02">Command Descriptions in vi</a> ).</p>
   2640 <p>This command need not be supported on block-mode terminals.</p>
   2641 <p>Behave as if the user entered the minimum number of &lt;blank&gt; characters necessary to move the cursor forward to the column
   2642 position after the next <b>shiftwidth</b> (see the <a href="../utilities/ex.html"><i>ex</i></a> <b>shiftwidth</b> command)
   2643 boundary.</p>
   2644 <p><i>Current line</i>: Unchanged.</p>
   2645 <p><i>Current column</i>: Set to <i>column</i> + <b>shiftwidth</b> - ((column -1) % <b>shiftwidth</b>).</p>
   2646 <h5><a name="tag_20_146_13_94" id="tag_20_146_13_94"></a>&lt;control&gt;-U</h5>
   2647 <dl compact>
   2648 <dd></dd>
   2649 <dt><i>Synopsis</i>:</dt>
   2650 <dd>
   2651 <pre>
   2652 <tt>&lt;control&gt;-U
   2653 </tt></pre></dd>
   2654 </dl>
   2655 <p>If there are characters other than <b>autoindent</b> characters that have been input on the current line before the cursor, the
   2656 cursor shall move to the first character input after the <b>autoindent</b> characters.</p>
   2657 <p>Otherwise, if there are <b>autoindent</b> characters on the current line before the cursor, it is implementation-defined whether
   2658 the &lt;control&gt;-U command is an error or if the cursor moves to the first column position on the line.</p>
   2659 <p>Otherwise, if the cursor is in column position 1 and there are previous lines that have been input, it is implementation-defined
   2660 whether the &lt;control&gt;-U command is an error or if it is equivalent to entering &lt;control&gt;-U after the last input
   2661 character on the previous input line.</p>
   2662 <p>Otherwise, it shall be an error.</p>
   2663 <p>All of the glyphs on columns between the starting cursor position and (inclusively) the ending cursor position shall become
   2664 erase-columns as described in <a href="#tag_20_146_13_88">Input Mode Commands in vi</a> .</p>
   2665 <p>The current <i>kill</i> character (see <a href="../utilities/stty.html"><i>stty</i></a>) shall cause an equivalent action to the
   2666 &lt;control&gt;-U command, unless the previously inserted character was a &lt;backslash&gt;, in which case it shall be as if the
   2667 literal current <i>kill</i> character had been inserted instead of the &lt;backslash&gt;.</p>
   2668 <p><i>Current line</i>: Unchanged, unless previously input lines are erased, in which case it shall be set to line -1.</p>
   2669 <p><i>Current column</i>: Set to the first column that displays any portion of the last character backed up over.</p>
   2670 <h5><a name="tag_20_146_13_95" id="tag_20_146_13_95"></a>&lt;control&gt;-V</h5>
   2671 <dl compact>
   2672 <dd></dd>
   2673 <dt><i>Synopsis</i>:</dt>
   2674 <dd>
   2675 <pre>
   2676 <tt>&lt;control&gt;-V
   2677 <br>
   2678 &lt;control&gt;-Q
   2679 </tt></pre></dd>
   2680 </dl>
   2681 <p>Allow the entry of any subsequent character, other than &lt;control&gt;-J or the &lt;newline&gt;, as a literal character,
   2682 removing any special meaning that it may have to the editor in text input mode. If a &lt;control&gt;-V or &lt;control&gt;-Q is
   2683 entered before a &lt;control&gt;-J or &lt;newline&gt;, the &lt;control&gt;-V or &lt;control&gt;-Q character shall be discarded, and
   2684 the &lt;control&gt;-J or &lt;newline&gt; shall behave as described in the &lt;newline&gt; command character during input mode.</p>
   2685 <p>For purposes of the display only, the editor shall behave as if a <tt>'^'</tt> character was entered, and the cursor shall be
   2686 positioned as if overwriting the <tt>'^'</tt> character. When a subsequent character is entered, the editor shall behave as if that
   2687 character was entered instead of the original &lt;control&gt;-V or &lt;control&gt;-Q character.</p>
   2688 <p><i>Current line</i>: Unchanged.</p>
   2689 <p><i>Current column</i>: Unchanged.</p>
   2690 <h5><a name="tag_20_146_13_96" id="tag_20_146_13_96"></a>&lt;control&gt;-W</h5>
   2691 <dl compact>
   2692 <dd></dd>
   2693 <dt><i>Synopsis</i>:</dt>
   2694 <dd>
   2695 <pre>
   2696 <tt>&lt;control&gt;-W
   2697 </tt></pre></dd>
   2698 </dl>
   2699 <p>If there are characters other than <b>autoindent</b> characters that have been input on the current line before the cursor, the
   2700 cursor shall move back over the last word preceding the cursor (including any &lt;blank&gt; characters between the end of the last
   2701 word and the current cursor); the cursor shall not move to before the first character after the end of any <b>autoindent</b>
   2702 characters.</p>
   2703 <p>Otherwise, if there are <b>autoindent</b> characters on the current line before the cursor, it is implementation-defined whether
   2704 the &lt;control&gt;-W command is an error or if the cursor moves to the first column position on the line.</p>
   2705 <p>Otherwise, if the cursor is in column position 1 and there are previous lines that have been input, it is implementation-defined
   2706 whether the &lt;control&gt;-W command is an error or if it is equivalent to entering &lt;control&gt;-W after the last input
   2707 character on the previous input line.</p>
   2708 <p>Otherwise, it shall be an error.</p>
   2709 <p>All of the glyphs on columns between the starting cursor position and (inclusively) the ending cursor position shall become
   2710 erase-columns as described in <a href="#tag_20_146_13_88">Input Mode Commands in vi</a> .</p>
   2711 <p><i>Current line</i>: Unchanged, unless previously input lines are erased, in which case it shall be set to line -1.</p>
   2712 <p><i>Current column</i>: Set to the first column that displays any portion of the last character backed up over.</p>
   2713 <h5><a name="tag_20_146_13_97" id="tag_20_146_13_97"></a>&lt;ESC&gt;</h5>
   2714 <dl compact>
   2715 <dd></dd>
   2716 <dt><i>Synopsis</i>:</dt>
   2717 <dd>
   2718 <pre>
   2719 <tt>&lt;ESC&gt;
   2720 </tt></pre></dd>
   2721 </dl>
   2722 <p>If input was part of a line-oriented command:</p>
   2723 <ol>
   2724 <li>
   2725 <p>If <i>interrupt</i> was entered, text input mode shall be terminated and the editor shall return to command mode. The terminal
   2726 shall be alerted.</p>
   2727 </li>
   2728 <li>
   2729 <p>If &lt;ESC&gt; was entered, text input mode shall be terminated and the command shall continue execution with the input
   2730 provided.</p>
   2731 </li>
   2732 </ol>
   2733 <p>Otherwise, terminate text input mode and return to command mode.</p>
   2734 <p>Any <b>autoindent</b> characters entered on newly created lines that have no other non-&lt;newline&gt; characters shall be
   2735 deleted.</p>
   2736 <p>Any leading <b>autoindent</b> and &lt;blank&gt; characters on newly created lines shall be rewritten to be the minimum number of
   2737 &lt;blank&gt; characters possible.</p>
   2738 <p>The screen shall be redisplayed as necessary to match the contents of the edit buffer.</p>
   2739 <p><i>Current line</i>: Unchanged.<br></p>
   2740 <p><i>Current column</i>:</p>
   2741 <ol>
   2742 <li>
   2743 <p>If there are text input characters on the current line, the column shall be set to the last column where any portion of the last
   2744 text input character is displayed.</p>
   2745 </li>
   2746 <li>
   2747 <p>Otherwise, if a character is displayed in the current column, unchanged.</p>
   2748 </li>
   2749 <li>
   2750 <p>Otherwise, set to column position 1.</p>
   2751 </li>
   2752 </ol>
   2753 </blockquote>
   2754 <h4 class="mansect"><a name="tag_20_146_14" id="tag_20_146_14"></a>EXIT STATUS</h4>
   2755 <blockquote>
   2756 <p>The following exit values shall be returned:</p>
   2757 <dl compact>
   2758 <dd></dd>
   2759 <dt>&nbsp;0</dt>
   2760 <dd>Successful completion.</dd>
   2761 <dt>&gt;0</dt>
   2762 <dd>An error occurred.</dd>
   2763 </dl>
   2764 </blockquote>
   2765 <h4 class="mansect"><a name="tag_20_146_15" id="tag_20_146_15"></a>CONSEQUENCES OF ERRORS</h4>
   2766 <blockquote>
   2767 <p>When an unrecoverable error is encountered it shall be equivalent to a SIGHUP asynchronous event.</p>
   2768 <p>Otherwise, when an error is encountered, the editor shall behave as specified in <a href="#tag_20_146_13_02">Command
   2769 Descriptions in vi</a> .</p>
   2770 </blockquote>
   2771 <hr>
   2772 <div class="box"><em>The following sections are informative.</em></div>
   2773 <h4 class="mansect"><a name="tag_20_146_16" id="tag_20_146_16"></a>APPLICATION USAGE</h4>
   2774 <blockquote>
   2775 <p>None.</p>
   2776 </blockquote>
   2777 <h4 class="mansect"><a name="tag_20_146_17" id="tag_20_146_17"></a>EXAMPLES</h4>
   2778 <blockquote>
   2779 <p>None.</p>
   2780 </blockquote>
   2781 <h4 class="mansect"><a name="tag_20_146_18" id="tag_20_146_18"></a>RATIONALE</h4>
   2782 <blockquote>
   2783 <p>See the RATIONALE for <a href="../utilities/ex.html#"><i>ex</i></a> for more information on <i>vi</i>. Major portions of the
   2784 <i>vi</i> utility specification point to <a href="../utilities/ex.html"><i>ex</i></a> to avoid inadvertent divergence. While
   2785 <a href="../utilities/ex.html"><i>ex</i></a> and <i>vi</i> have historically been implemented as a single utility, this is not
   2786 required by POSIX.1-2024.</p>
   2787 <p>It is recognized that portions of <i>vi</i> would be difficult, if not impossible, to implement satisfactorily on a block-mode
   2788 terminal, or a terminal without any form of cursor addressing, thus it is not a mandatory requirement that such features should
   2789 work on all terminals. It is the intention, however, that a <i>vi</i> implementation should provide the full set of capabilities on
   2790 all terminals capable of supporting them.</p>
   2791 <p>Historically, <i>vi</i> exited immediately if the standard input was not a terminal. POSIX.1-2024 permits, but does not require,
   2792 this behavior. An end-of-file condition is not equivalent to an end-of-file character. A common end-of-file character,
   2793 &lt;control&gt;-D, is historically a <i>vi</i> command.</p>
   2794 <p>The text in the STDOUT section reflects the usage of the verb <i>display</i> in this section; some implementations of <i>vi</i>
   2795 use standard output to write to the terminal, but POSIX.1-2024 does not require that to be the case.</p>
   2796 <p>Historically, implementations reverted to open mode if the terminal was incapable of supporting full visual mode. POSIX.1-2024
   2797 requires this behavior. Historically, the open mode of <i>vi</i> behaved roughly equivalently to the visual mode, with the
   2798 exception that only a single line from the edit buffer (one &quot;buffer line&quot;) was kept current at any time. This line was normally
   2799 displayed on the next-to-last line of a terminal with cursor addressing (and the last line performed its normal visual functions
   2800 for line-oriented commands and messages). In addition, some few commands behaved differently in open mode than in visual mode.
   2801 POSIX.1-2024 requires conformance to historical practice.</p>
   2802 <p>Historically, <a href="../utilities/ex.html"><i>ex</i></a> and <i>vi</i> implementations have expected text to proceed in the
   2803 usual European/Latin order of left to right, top to bottom. There is no requirement in POSIX.1-2024 that this be the case. The
   2804 specification was deliberately written using words like &quot;before&quot;, &quot;after&quot;, &quot;first&quot;, and &quot;last&quot; in order to permit
   2805 implementations to support the natural text order of the language.</p>
   2806 <p>Historically, lines past the end of the edit buffer were marked with single &lt;tilde&gt; (<tt>'~'</tt>) characters; that is, if
   2807 the one-based display was 20 lines in length, and the last line of the file was on line one, then lines 2-20 would contain only a
   2808 single <tt>'~'</tt> character.</p>
   2809 <p>Historically, the <i>vi</i> editor attempted to display only complete lines at the bottom of the screen (it did display partial
   2810 lines at the top of the screen). If a line was too long to fit in its entirety at the bottom of the screen, the screen lines where
   2811 the line would have been displayed were displayed as single <tt>'@'</tt> characters, instead of displaying part of the line.
   2812 POSIX.1-2024 permits, but does not require, this behavior. Implementations are encouraged to attempt always to display a complete
   2813 line at the bottom of the screen when doing scrolling or screen positioning by buffer lines.</p>
   2814 <p>Historically, lines marked with <tt>'@'</tt> were also used to minimize output to dumb terminals over slow lines; that is,
   2815 changes local to the cursor were updated, but changes to lines on the screen that were not close to the cursor were simply marked
   2816 with an <tt>'@'</tt> sign instead of being updated to match the current text. POSIX.1-2024 permits, but does not require this
   2817 feature because it is used ever less frequently as terminals become smarter and connections are faster.</p>
   2818 <h5><a name="tag_20_146_18_01" id="tag_20_146_18_01"></a>Initialization in ex and vi</h5>
   2819 <p>Historically, <i>vi</i> always had a line in the edit buffer, even if the edit buffer was &quot;empty&quot;. For example:</p>
   2820 <ol>
   2821 <li>
   2822 <p>The <a href="../utilities/ex.html"><i>ex</i></a> command <b>=</b> executed from visual mode wrote &quot;1&quot; when the buffer was
   2823 empty.</p>
   2824 </li>
   2825 <li>
   2826 <p>Writes from visual mode of an empty edit buffer wrote files of a single character (a &lt;newline&gt;), while writes from
   2827 <a href="../utilities/ex.html"><i>ex</i></a> mode of an empty edit buffer wrote empty files.</p>
   2828 </li>
   2829 <li>
   2830 <p>Put and read commands into an empty edit buffer left an empty line at the top of the edit buffer.</p>
   2831 </li>
   2832 </ol>
   2833 <p>For consistency, POSIX.1-2024 does not permit any of these behaviors.</p>
   2834 <p>Historically, <i>vi</i> did not always return the terminal to its original modes; for example, ICRNL was modified if it was not
   2835 originally set. POSIX.1-2024 does not permit this behavior.</p>
   2836 <h5><a name="tag_20_146_18_02" id="tag_20_146_18_02"></a>Command Descriptions in vi</h5>
   2837 <p>Motion commands are among the most complicated aspects of <i>vi</i> to describe. With some exceptions, the text region and
   2838 buffer type effect of a motion command on a <i>vi</i> command are described on a case-by-case basis. The descriptions of text
   2839 regions in POSIX.1-2024 are not intended to imply direction; that is, an inclusive region from line <i>n</i> to line <i>n</i>+5 is
   2840 identical to a region from line <i>n</i>+5 to line <i>n</i>. This is of more than academic interest—movements to marks can be in
   2841 either direction, and, if the <b>wrapscan</b> option is set, so can movements to search points. Historically, lines are always
   2842 stored into buffers in text order; that is, from the start of the edit buffer to the end. POSIX.1-2024 requires conformance to
   2843 historical practice.</p>
   2844 <p>Historically, command counts were applied to any associated motion, and were multiplicative to any supplied motion count. For
   2845 example, <b>2cw</b> is the same as <b>c2w</b>, and <b>2c3w</b> is the same as <b>c6w</b>. POSIX.1-2024 requires this behavior.
   2846 Historically, <i>vi</i> commands that used bigwords, words, paragraphs, and sentences as objects treated groups of empty lines, or
   2847 lines that contained only &lt;blank&gt; characters, inconsistently. Some commands treated them as a single entity, while others
   2848 treated each line separately. For example, the <b>w</b>, <b>W</b>, and <b>B</b> commands treated groups of empty lines as
   2849 individual words; that is, the command would move the cursor to each new empty line. The <b>e</b> and <b>E</b> commands treated
   2850 groups of empty lines as a single word; that is, the first use would move past the group of lines. The <b>b</b> command would just
   2851 beep at the user, or if done from the start of the line as a motion command, fail in unexpected ways. If the lines contained only
   2852 (or ended with) &lt;blank&gt; characters, the <b>w</b> and <b>W</b> commands would just beep at the user, the <b>E</b> and <b>e</b>
   2853 commands would treat the group as a single word, and the <b>B</b> and <b>b</b> commands would treat the lines as individual words.
   2854 For consistency and simplicity of specification, POSIX.1-2024 requires that all <i>vi</i> commands treat groups of empty or blank
   2855 lines as a single entity, and that movement through lines ending with &lt;blank&gt; characters be consistent with other
   2856 movements.</p>
   2857 <p>Historically, <i>vi</i> documentation indicated that any number of double-quotes were skipped after punctuation marks at
   2858 sentence boundaries; however, implementations only skipped single-quotes. POSIX.1-2024 requires both to be skipped.</p>
   2859 <p>Historically, the first and last characters in the edit buffer were word boundaries. This historical practice is required by
   2860 POSIX.1-2024.</p>
   2861 <p>Historically, <i>vi</i> attempted to update the minimum number of columns on the screen possible, which could lead to misleading
   2862 information being displayed. POSIX.1-2024 makes no requirements other than that the current character being entered is displayed
   2863 correctly, leaving all other decisions in this area up to the implementation.</p>
   2864 <p>Historically, lines were arbitrarily folded between columns of any characters that required multiple column positions on the
   2865 screen, with the exception of tabs, which terminated at the right-hand margin. POSIX.1-2024 permits the former and requires the
   2866 latter. Implementations that do not arbitrarily break lines between columns of characters that occupy multiple column positions
   2867 should not permit the cursor to rest on a column that does not contain any part of a character.</p>
   2868 <p>The historical <i>vi</i> had a problem in that all movements were by buffer lines, not by display or screen lines. This is often
   2869 the right thing to do; for example, single line movements, such as <b>j</b> or <b>k</b>, should work on buffer lines. Commands like
   2870 <b>dj</b>, or <b>j.</b>, where <b>.</b> is a change command, only make sense for buffer lines. It is not, however, the right thing
   2871 to do for screen motion or scrolling commands like &lt;control&gt;-D, &lt;control&gt;-F, and <b>H</b>. If the window is fairly
   2872 small, using buffer lines in these cases can result in completely random motion; for example, <b>1</b>&lt;control&gt;<b>-D</b> can
   2873 result in a completely changed screen, without any overlap. This is clearly not what the user wanted. The problem is even worse in
   2874 the case of the <b>H</b>, <b>L</b>, and <b>M</b> commands—as they position the cursor at the first non-&lt;blank&gt; of the line,
   2875 they may all refer to the same location in large lines, and will result in no movement at all.</p>
   2876 <p>In addition, if the line is larger than the screen, using buffer lines can make it impossible to display parts of the line—there
   2877 are not any commands that do not display the beginning of the line in historical <i>vi</i>, and if both the beginning and end of
   2878 the line cannot be on the screen at the same time, the user suffers. Finally, the page and half-page scrolling commands
   2879 historically moved to the first non-&lt;blank&gt; in the new line. If the line is approximately the same size as the screen, this
   2880 is inadequate because the cursor before and after a &lt;control&gt;-D command will refer to the same location on the screen.</p>
   2881 <p>Implementations of <a href="../utilities/ex.html"><i>ex</i></a> and <i>vi</i> exist that do not have these problems because the
   2882 relevant commands (&lt;control&gt;-B, &lt;control&gt;-D, &lt;control&gt;-F, &lt;control&gt;-U, &lt;control&gt;-Y,
   2883 &lt;control&gt;-E, <b>H</b>, <b>L</b>, and <b>M)</b> operate on display (screen) lines, not (edit) buffer lines.</p>
   2884 <p>POSIX.1-2024 does not permit this behavior by default because the standard developers believed that users would find it too
   2885 confusing. However, historical practice has been relaxed. For example, <a href="../utilities/ex.html"><i>ex</i></a> and <i>vi</i>
   2886 historically attempted, albeit sometimes unsuccessfully, to never put part of a line on the last lines of a screen; for example, if
   2887 a line would not fit in its entirety, no part of the line was displayed, and the screen lines corresponding to the line contained
   2888 single <tt>'@'</tt> characters. This behavior is permitted, but not required by POSIX.1-2024, so that it is possible for
   2889 implementations to support long lines in small screens more reasonably without changing the commands to be oriented to the display
   2890 (instead of oriented to the buffer). POSIX.1-2024 also permits implementations to refuse to edit any edit buffer containing a line
   2891 that will not fit on the screen in its entirety.</p>
   2892 <p>The display area (for example, the value of the <b>window</b> edit option) has historically been &quot;grown&quot;, or expanded, to
   2893 display new text when local movements are done in displays where the number of lines displayed is less than the maximum possible.
   2894 Expansion has historically been the first choice, when the target line is less than the maximum possible expansion value away.
   2895 Scrolling has historically been the next choice, done when the target line is less than half a display away, and otherwise, the
   2896 screen was redrawn. There were exceptions, however, in that <a href="../utilities/ex.html"><i>ex</i></a> commands generally always
   2897 caused the screen to be redrawn. POSIX.1-2024 does not specify a standard behavior because there may be external issues, such as
   2898 connection speed, the number of characters necessary to redraw as opposed to scroll, or terminal capabilities that implementations
   2899 will have to accommodate.</p>
   2900 <p>The current line in POSIX.1-2024 maps one-to-one to a buffer line in the file. The current column does not. There are two
   2901 different column values that are described by POSIX.1-2024. The first is the current column value as set by many of the <i>vi</i>
   2902 commands. This value is remembered for the lifetime of the editor. The second column value is the actual position on the screen
   2903 where the cursor rests. The two are not always the same. For example, when the cursor is backed by a multi-column character, the
   2904 actual cursor position on the screen has historically been the last column of the character in command mode, and the first column
   2905 of the character in input mode.</p>
   2906 <p>Commands that set the current line, but that do not set the current cursor value (for example, <b>j</b> and <b>k</b>) attempt to
   2907 get as close as possible to the remembered column position, so that the cursor tends to restrict itself to a vertical column as the
   2908 user moves around in the edit buffer. POSIX.1-2024 requires conformance to historical practice, requiring that the display location
   2909 of the cursor on the display line be adjusted from the current column value as necessary to support this historical behavior.</p>
   2910 <p>Historically, only a single line (and for some terminals, a single line minus 1 column) of characters could be entered by the
   2911 user for the line-oriented commands; that is, <b>:</b>, <b>!</b>, <b>/</b>, or <b>?</b>. POSIX.1-2024 permits, but does not
   2912 require, this limitation.</p>
   2913 <p>Historically, &quot;soft&quot; errors in <i>vi</i> caused the terminal to be alerted, but no error message was displayed. As a general
   2914 rule, no error message was displayed for errors in command execution in <i>vi</i>, when the error resulted from the user attempting
   2915 an invalid or impossible action, or when a searched-for object was not found. Examples of soft errors included <b>h</b> at the left
   2916 margin, &lt;control&gt;-B or <b>[[</b> at the beginning of the file, <b>2G</b> at the end of the file, and so on. In addition,
   2917 errors such as <b>%</b>, <b>]]</b>, <b>}</b>, <b>)</b>, <b>N</b>, <b>n</b>, <b>f</b>, <b>F</b>, <b>t</b>, and <b>T</b> failing to
   2918 find the searched-for object were soft as well. Less consistently, <b>/</b> and <b>?</b> displayed an error message if the pattern
   2919 was not found, <b>/</b>, <b>?</b>, <b>N</b>, and <b>n</b> displayed an error message if no previous regular expression had been
   2920 specified, and <b>;</b> did not display an error message if no previous <b>f</b>, <b>F</b>, <b>t</b>, or <b>T</b> command had
   2921 occurred. Also, behavior in this area might reasonably be based on a runtime evaluation of the speed of a network connection.
   2922 Finally, some implementations have provided error messages for soft errors in order to assist naive users, based on the value of a
   2923 verbose edit option. POSIX.1-2024 does not list specific errors for which an error message shall be displayed. Implementations
   2924 should conform to historical practice in the absence of any strong reason to diverge.</p>
   2925 <h5><a name="tag_20_146_18_03" id="tag_20_146_18_03"></a>Page Backwards</h5>
   2926 <p>The &lt;control&gt;-B and &lt;control&gt;-F commands historically considered it an error to attempt to page past the beginning
   2927 or end of the file, whereas the &lt;control&gt;-D and &lt;control&gt;-U commands simply moved to the beginning or end of the file.
   2928 For consistency, POSIX.1-2024 requires the latter behavior for all four commands. All four commands still consider it an error if
   2929 the current line is at the beginning (&lt;control&gt;-B, &lt;control&gt;-U) or end (&lt;control&gt;-F, &lt;control&gt;-D) of the
   2930 file. Historically, the &lt;control&gt;-B and &lt;control&gt;-F commands skip two lines in order to include overlapping lines when
   2931 a single command is entered. This makes less sense in the presence of a <i>count</i>, as there will be, by definition, no
   2932 overlapping lines. The actual calculation used by historical implementations of the <i>vi</i> editor for &lt;control&gt;-B was:</p>
   2933 <pre>
   2934 <tt>((current first line) - count x (window edit option)) +2
   2935 </tt></pre>
   2936 <p>and for &lt;control&gt;-F was:</p>
   2937 <pre>
   2938 <tt>((current first line) + count x (window edit option)) -2
   2939 </tt></pre>
   2940 <p>This calculation does not work well when intermixing commands with and without counts; for example, <b>3</b>&lt;control&gt;-F is
   2941 not equivalent to entering the &lt;control&gt;-F command three times, and is not reversible by entering the &lt;control&gt;-B
   2942 command three times. For consistency with other <i>vi</i> commands that take counts, POSIX.1-2024 requires a different
   2943 calculation.</p>
   2944 <h5><a name="tag_20_146_18_04" id="tag_20_146_18_04"></a>Scroll Forward</h5>
   2945 <p>The 4BSD and System V implementations of <i>vi</i> differed on the initial value used by the <b>scroll</b> command. 4BSD
   2946 used:</p>
   2947 <pre>
   2948 <tt>((window edit option) +1) /2
   2949 </tt></pre>
   2950 <p>while System V used the value of the <b>scroll</b> edit option. The System V version is specified by POSIX.1-2024 because the
   2951 standard developers believed that it was more intuitive and permitted the user a method of setting the scroll value initially
   2952 without also setting the number of lines that are displayed.</p>
   2953 <h5><a name="tag_20_146_18_05" id="tag_20_146_18_05"></a>Scroll Forward by Line</h5>
   2954 <p>Historically, the &lt;control&gt;-E and &lt;control&gt;-Y commands considered it an error if the last and first lines,
   2955 respectively, were already on the screen. POSIX.1-2024 requires conformance to historical practice. Historically, the
   2956 &lt;control&gt;-E and &lt;control&gt;-Y commands had no effect in open mode. For simplicity and consistency of specification,
   2957 POSIX.1-2024 requires that they behave as usual, albeit with a single line screen.</p>
   2958 <h5><a name="tag_20_146_18_06" id="tag_20_146_18_06"></a>Clear and Redisplay</h5>
   2959 <p>The historical &lt;control&gt;-L command refreshed the screen exactly as it was supposed to be currently displayed, replacing
   2960 any <tt>'@'</tt> characters for lines that had been deleted but not updated on the screen with refreshed <tt>'@'</tt> characters.
   2961 The intent of the &lt;control&gt;-L command is to refresh when the screen has been accidentally overwritten; for example, by a
   2962 <b>write</b> command from another user, or modem noise.</p>
   2963 <h5><a name="tag_20_146_18_07" id="tag_20_146_18_07"></a>Redraw Screen</h5>
   2964 <p>The historical &lt;control&gt;-R command redisplayed only when necessary to update lines that had been deleted but not updated
   2965 on the screen and that were flagged with <tt>'@'</tt> characters. There is no requirement that the screen be in any way refreshed
   2966 if no lines of this form are currently displayed. POSIX.1-2024 permits implementations to extend this command to refresh lines on
   2967 the screen flagged with <tt>'@'</tt> characters because they are too long to be displayed in the current framework; however, the
   2968 current line and column need not be modified.</p>
   2969 <h5><a name="tag_20_146_18_08" id="tag_20_146_18_08"></a>Search for tagstring</h5>
   2970 <p>Historically, the first non-&lt;blank&gt; at or after the cursor was the first character, and all subsequent characters that
   2971 were word characters, up to the end of the line, were included. For example, with the cursor on the leading &lt;space&gt; or on the
   2972 <tt>'#'</tt> character in the text <tt>"#bar@"</tt>, the tag was <tt>"#bar"</tt>. On the character <tt>'b'</tt> it was
   2973 <tt>"bar"</tt>, and on the <tt>'a'</tt> it was <tt>"ar"</tt>. POSIX.1-2024 requires this behavior.</p>
   2974 <h5><a name="tag_20_146_18_09" id="tag_20_146_18_09"></a>Replace Text with Results from Shell Command</h5>
   2975 <p>Historically, the <b>&lt;</b>, <b>&gt;</b>, and <b>!</b> commands considered most cursor motions other than line-oriented
   2976 motions an error; for example, the command <b>&gt;/foo&lt;CR&gt;</b> succeeded, while the command <b>&gt;l</b> failed, even though
   2977 the text region described by the two commands might be identical. For consistency, all three commands only consider entire lines
   2978 and not partial lines, and the region is defined as any line that contains a character that was specified by the motion.</p>
   2979 <h5><a name="tag_20_146_18_10" id="tag_20_146_18_10"></a>Move to Matching Character</h5>
   2980 <p>Other matching characters have been left implementation-defined in order to allow extensions such as matching <tt>'&lt;'</tt>
   2981 and <tt>'&gt;'</tt> for searching HTML, or <b>#ifdef</b>, <b>#else</b>, and <b>#endif</b> for searching C source.</p>
   2982 <h5><a name="tag_20_146_18_11" id="tag_20_146_18_11"></a>Repeat Substitution</h5>
   2983 <p>POSIX.1-2024 requires that any <b>c</b> and <b>g</b> flags specified to the previous substitute command be ignored; however, the
   2984 <b>r</b> flag may still apply, if supported by the implementation.</p>
   2985 <h5><a name="tag_20_146_18_12" id="tag_20_146_18_12"></a>Return to Previous (Context or Section)</h5>
   2986 <p>The <b>[[</b>, <b>]]</b>, <b>(</b>, <b>)</b>, <b>{</b>, and <b>}</b> commands are all affected by &quot;section boundaries&quot;, but in
   2987 some historical implementations not all of the commands recognize the same section boundaries. This is a bug, not a feature, and a
   2988 unique section-boundary algorithm was not described for each command. One special case that is preserved is that the sentence
   2989 command moves to the end of the last line of the edit buffer while the other commands go to the beginning, in order to preserve the
   2990 traditional character cut semantics of the sentence command. Historically, <i>vi</i> section boundaries at the beginning and end of
   2991 the edit buffer were the first non-&lt;blank&gt; on the first and last lines of the edit buffer if one exists; otherwise, the last
   2992 character of the first and last lines of the edit buffer if one exists. To increase consistency with other section locations, this
   2993 has been simplified by POSIX.1-2024 to the first character of the first and last lines of the edit buffer, or the first and the
   2994 last lines of the edit buffer if they are empty.</p>
   2995 <p>Sentence boundaries were problematic in the historical <i>vi</i>. They were not only the boundaries as defined for the section
   2996 and paragraph commands, but they were the first non-&lt;blank&gt; that occurred after those boundaries, as well. Historically, the
   2997 <i>vi</i> section commands were documented as taking an optional window size as a <i>count</i> preceding the command. This was not
   2998 implemented in historical versions, so POSIX.1-2024 requires that the <i>count</i> repeat the command, for consistency with other
   2999 <i>vi</i> commands.</p>
   3000 <h5><a name="tag_20_146_18_13" id="tag_20_146_18_13"></a>Repeat</h5>
   3001 <p>Historically, mapped commands other than text input commands could not be repeated using the <b>period</b> command. POSIX.1-2024
   3002 requires conformance to historical practice.</p>
   3003 <p>The restrictions on the interpretation of special characters (for example, &lt;control&gt;-H) in the repetition of text input
   3004 mode commands is intended to match historical practice. For example, given the input sequence:</p>
   3005 <pre>
   3006 <tt>iab&lt;control&gt;-H&lt;control&gt;-H&lt;control&gt;-Hdef&lt;escape&gt;
   3007 </tt></pre>
   3008 <p>the user should be informed of an error when the sequence is first entered, but not during a command repetition. The character
   3009 &lt;control&gt;-T is specifically exempted from this restriction. Historical implementations of <i>vi</i> ignored &lt;control&gt;-T
   3010 characters that were input in the original command during command repetition. POSIX.1-2024 prohibits this behavior.</p>
   3011 <h5><a name="tag_20_146_18_14" id="tag_20_146_18_14"></a>Find Regular Expression</h5>
   3012 <p>Historically, commands did not affect the line searched to or from if the motion command was a search (<b>/</b>, <b>?</b>,
   3013 <b>N</b>, <b>n</b>) and the final position was the start/end of the line. There were some special cases and <i>vi</i> was not
   3014 consistent. POSIX.1-2024 does not permit this behavior, for consistency. Historical implementations permitted but were unable to
   3015 handle searches as motion commands that wrapped (that is, due to the edit option <b>wrapscan</b>) to the original location.
   3016 POSIX.1-2024 requires that this behavior be treated as an error.</p>
   3017 <p>Historically, the syntax <tt>"/RE/0"</tt> was used to force the command to cut text in line mode. POSIX.1-2024 requires
   3018 conformance to historical practice.</p>
   3019 <p>Historically, in open mode, a <b>z</b> specified to a search command redisplayed the current line instead of displaying the
   3020 current screen with the current line highlighted. For consistency and simplicity of specification, POSIX.1-2024 does not permit
   3021 this behavior.</p>
   3022 <p>Historically, trailing <b>z</b> commands were permitted and ignored if entered as part of a search used as a motion command. For
   3023 consistency and simplicity of specification, POSIX.1-2024 does not permit this behavior.</p>
   3024 <h5><a name="tag_20_146_18_15" id="tag_20_146_18_15"></a>Execute an ex Command</h5>
   3025 <p>Historically, <i>vi</i> implementations restricted the commands that could be entered on the colon command line (for example,
   3026 <b>append</b> and <b>change</b>), and some other commands were known to cause them to fail catastrophically. For consistency,
   3027 POSIX.1-2024 does not permit these restrictions. When executing an <a href="../utilities/ex.html"><i>ex</i></a> command by entering
   3028 <b>:</b>, it is not possible to enter a &lt;newline&gt; as part of the command because it is considered the end of the command. A
   3029 different approach is to enter <a href="../utilities/ex.html"><i>ex</i></a> command mode by using the <i>vi</i> <b>Q</b> command
   3030 (and later resuming visual mode with the <a href="../utilities/ex.html"><i>ex</i></a> <b>vi</b> command). In <a href=
   3031 "../utilities/ex.html"><i>ex</i></a> command mode, the single-line limitation does not exist. So, for example, the following is
   3032 valid:</p>
   3033 <pre>
   3034 <tt>Q
   3035 s/break here/break\
   3036 here/
   3037 vi
   3038 </tt></pre>
   3039 <p>POSIX.1-2024 requires that, if the <a href="../utilities/ex.html"><i>ex</i></a> command overwrites any part of the screen that
   3040 would be erased by a refresh, <i>vi</i> pauses for a character from the user. Historically, this character could be any character;
   3041 for example, a character input by the user before the message appeared, or even a mapped character. This is probably a bug, but
   3042 implementations that have tried to be more rigorous by requiring that the user enter a specific character, or that the user enter a
   3043 character after the message was displayed, have been forced by user indignation back into historical behavior. POSIX.1-2024
   3044 requires conformance to historical practice.</p>
   3045 <h5><a name="tag_20_146_18_16" id="tag_20_146_18_16"></a>Shift Left (Right)</h5>
   3046 <p>Refer to the Rationale for the <b>!</b> and <b>/</b> commands. Historically, the <b>&lt;</b> and <b>&gt;</b> commands sometimes
   3047 moved the cursor to the first non-&lt;blank&gt; (for example if the command was repeated or with <b>_</b> as the motion command),
   3048 and sometimes left it unchanged. POSIX.1-2024 does not permit this inconsistency, requiring instead that the cursor always move to
   3049 the first non-&lt;blank&gt;. Historically, the <b>&lt;</b> and <b>&gt;</b> commands did not support buffer arguments, although some
   3050 implementations allow the specification of an optional buffer. This behavior is neither required nor disallowed by
   3051 POSIX.1-2024.</p>
   3052 <h5><a name="tag_20_146_18_17" id="tag_20_146_18_17"></a>Execute</h5>
   3053 <p>Historically, buffers could execute other buffers, and loops, infinite and otherwise, were possible. POSIX.1-2024 requires
   3054 conformance to historical practice. The *<i>buffer</i> syntax of <a href="../utilities/ex.html"><i>ex</i></a> is not required in
   3055 <i>vi</i>, because it is not historical practice and has been used in some <i>vi</i> implementations to support additional
   3056 scripting languages.</p>
   3057 <h5><a name="tag_20_146_18_18" id="tag_20_146_18_18"></a>Reverse Case</h5>
   3058 <p>Historically, the <b>~</b> command ignored any associated <i>count</i>, and acted only on the characters in the current line.
   3059 For consistency with other <i>vi</i> commands, POSIX.1-2024 requires that an associated <i>count</i> act on the next <i>count</i>
   3060 characters, and that the command move to subsequent lines if warranted by <i>count</i>, to make it possible to modify large pieces
   3061 of text in a reasonably efficient manner. There exist <i>vi</i> implementations that optionally require an associated motion
   3062 command for the <b>~</b> command. Implementations supporting this functionality are encouraged to base it on the <b>tildedop</b>
   3063 edit option and handle the text regions and cursor positioning identically to the <b>yank</b> command.</p>
   3064 <h5><a name="tag_20_146_18_19" id="tag_20_146_18_19"></a>Append</h5>
   3065 <p>Historically, <i>count</i>s specified to the <b>A</b>, <b>a</b>, <b>I</b>, and <b>i</b> commands repeated the input of the first
   3066 line <i>count</i> times, and did not repeat the subsequent lines of the input text. POSIX.1-2024 requires that the entire text
   3067 input be repeated <i>count</i> times.</p>
   3068 <h5><a name="tag_20_146_18_20" id="tag_20_146_18_20"></a>Move Backward to Preceding Word</h5>
   3069 <p>Historically, <i>vi</i> became confused if word commands were used as motion commands in empty files. POSIX.1-2024 requires that
   3070 this be an error. Historical implementations of <i>vi</i> had a large number of bugs in the word movement commands, and they varied
   3071 greatly in behavior in the presence of empty lines, &quot;words&quot; made up of a single character, and lines containing only
   3072 &lt;blank&gt; characters. For consistency and simplicity of specification, POSIX.1-2024 does not permit this behavior.</p>
   3073 <h5><a name="tag_20_146_18_21" id="tag_20_146_18_21"></a>Change to End-of-Line</h5>
   3074 <p>Some historical implementations of the <b>C</b> command did not behave as described by POSIX.1-2024 when the <b>$</b> key was
   3075 remapped because they were implemented by pushing the <b>$</b> key onto the input queue and reprocessing it. POSIX.1-2024 does not
   3076 permit this behavior. Historically, the <b>C</b>, <b>S</b>, and <b>s</b> commands did not copy replaced text into the numeric
   3077 buffers. For consistency and simplicity of specification, POSIX.1-2024 requires that they behave like their respective <b>c</b>
   3078 commands in all respects.</p>
   3079 <h5><a name="tag_20_146_18_22" id="tag_20_146_18_22"></a>Delete</h5>
   3080 <p>Historically, lines in open mode that were deleted were scrolled up, and an <b>@</b> glyph written over the beginning of the
   3081 line. In the case of terminals that are incapable of the necessary cursor motions, the editor erased the deleted line from the
   3082 screen. POSIX.1-2024 requires conformance to historical practice; that is, if the terminal cannot display the <tt>'@'</tt>
   3083 character, the line cannot remain on the screen.</p>
   3084 <h5><a name="tag_20_146_18_23" id="tag_20_146_18_23"></a>Delete to End-of-Line</h5>
   3085 <p>Some historical implementations of the <b>D</b> command did not behave as described by POSIX.1-2024 when the <b>$</b> key was
   3086 remapped because they were implemented by pushing the <b>$</b> key onto the input queue and reprocessing it. POSIX.1-2024 does not
   3087 permit this behavior.</p>
   3088 <h5><a name="tag_20_146_18_24" id="tag_20_146_18_24"></a>Join</h5>
   3089 <p>An historical oddity of <i>vi</i> is that the commands <b>J</b>, <b>1J</b>, and <b>2J</b> are all equivalent. POSIX.1-2024
   3090 requires conformance to historical practice. The <i>vi</i> <b>J</b> command is specified in terms of the <a href=
   3091 "../utilities/ex.html"><i>ex</i></a> <b>join</b> command with an <a href="../utilities/ex.html"><i>ex</i></a> command <i>count</i>
   3092 value. The address correction for a <i>count</i> that is past the end of the edit buffer is necessary for historical compatibility
   3093 for both <a href="../utilities/ex.html"><i>ex</i></a> and <i>vi</i>.</p>
   3094 <h5><a name="tag_20_146_18_25" id="tag_20_146_18_25"></a>Mark Position</h5>
   3095 <p>Historical practice is that only lowercase letters, plus backquote and single-quote, could be used to mark a cursor position.
   3096 POSIX.1-2024 requires conformance to historical practice, but encourages implementations to support other characters as marks as
   3097 well.</p>
   3098 <h5><a name="tag_20_146_18_26" id="tag_20_146_18_26"></a>Repeat Regular Expression Find (Forward and Reverse)</h5>
   3099 <p>Historically, the <b>N</b> and <b>n</b> commands could not be used as motion components for the <b>c</b> command. With the
   3100 exception of the <b>cN</b> command, which worked if the search crossed a line boundary, the text region would be discarded, and the
   3101 user would not be in text input mode. For consistency and simplicity of specification, POSIX.1-2024 does not permit this
   3102 behavior.</p>
   3103 <h5><a name="tag_20_146_18_27" id="tag_20_146_18_27"></a>Insert Empty Line (Below and Above)</h5>
   3104 <p>Historically, counts to the <b>O</b> and <b>o</b> commands were used as the number of physical lines to open, if the terminal
   3105 was dumb and the <b>slowopen</b> option was not set. This was intended to minimize traffic over slow connections and repainting for
   3106 dumb terminals. POSIX.1-2024 does not permit this behavior, requiring that a <i>count</i> to the open command behave as for other
   3107 text input commands. This change to historical practice was made for consistency, and because a superset of the functionality is
   3108 provided by the <b>slowopen</b> edit option.</p>
   3109 <h5><a name="tag_20_146_18_28" id="tag_20_146_18_28"></a>Put from Buffer (Following and Before)</h5>
   3110 <p>Historically, <i>count</i>s to the <b>p</b> and <b>P</b> commands were ignored if the buffer was a line mode buffer, but were
   3111 (mostly) implemented as described in POSIX.1-2024 if the buffer was a character mode buffer. Because implementations exist that do
   3112 not have this limitation, and because pasting lines multiple times is generally useful, POSIX.1-2024 requires that <i>count</i> be
   3113 supported for all <b>p</b> and <b>P</b> commands.</p>
   3114 <p>Historical implementations of <i>vi</i> were widely known to have major problems in the <b>p</b> and <b>P</b> commands,
   3115 particularly when unusual regions of text were copied into the edit buffer. The standard developers viewed these as bugs, and they
   3116 are not permitted for consistency and simplicity of specification.</p>
   3117 <p>Historically, a <b>P</b> or <b>p</b> command (or an <a href="../utilities/ex.html"><i>ex</i></a> <b>put</b> command executed
   3118 from open or visual mode) executed in an empty file, left an empty line as the first line of the file. For consistency and
   3119 simplicity of specification, POSIX.1-2024 does not permit this behavior.</p>
   3120 <h5><a name="tag_20_146_18_29" id="tag_20_146_18_29"></a>Replace Character</h5>
   3121 <p>Historically, the <b>r</b> command did not correctly handle the <i>erase</i> and <i>word erase</i> characters as arguments, nor
   3122 did it handle an associated <i>count</i> greater than 1 with a &lt;carriage-return&gt; argument, for which it replaced <i>count</i>
   3123 characters with a single &lt;newline&gt;. POSIX.1-2024 does not permit these inconsistencies.</p>
   3124 <p>Historically, the <b>r</b> command permitted the &lt;control&gt;-V escaping of entered characters, such as &lt;ESC&gt; and the
   3125 &lt;carriage-return&gt;; however, it required two leading &lt;control&gt;-V characters instead of one. POSIX.1-2024 requires that
   3126 this be changed for consistency with the other text input commands of <i>vi</i>.</p>
   3127 <p>Historically, it is an error to enter the <b>r</b> command if there are less than <i>count</i> characters at or after the cursor
   3128 in the line. While a reasonable and unambiguous extension would be to permit the <b>r</b> command on empty lines, it would require
   3129 that too large a <i>count</i> be adjusted to match the number of characters at or after the cursor for consistency, which is
   3130 sufficiently different from historical practice to be avoided. POSIX.1-2024 requires conformance to historical practice.</p>
   3131 <h5><a name="tag_20_146_18_30" id="tag_20_146_18_30"></a>Replace Characters</h5>
   3132 <p>Historically, if there were <b>autoindent</b> characters in the line on which the <b>R</b> command was run, and
   3133 <b>autoindent</b> was set, the first &lt;newline&gt; would be properly indented and no characters would be replaced by the
   3134 &lt;newline&gt;. Each additional &lt;newline&gt; would replace <i>n</i> characters, where <i>n</i> was the number of characters
   3135 that were needed to indent the rest of the line to the proper indentation level. This behavior is a bug and is not permitted by
   3136 POSIX.1-2024.</p>
   3137 <h5><a name="tag_20_146_18_31" id="tag_20_146_18_31"></a>Undo</h5>
   3138 <p>Historical practice for cursor positioning after undoing commands was mixed. In most cases, when undoing commands that affected
   3139 a single line, the cursor was moved to the start of added or changed text, or immediately after deleted text. However, if the user
   3140 had moved from the line being changed, the column was either set to the first non-&lt;blank&gt;, returned to the origin of the
   3141 command, or remained unchanged. When undoing commands that affected multiple lines or entire lines, the cursor was moved to the
   3142 first character in the first line restored. As an example of how inconsistent this was, a search, followed by an <b>o</b> text
   3143 input command, followed by an <b>undo</b> would return the cursor to the location where the <b>o</b> command was entered, but a
   3144 <b>cw</b> command followed by an <b>o</b> command followed by an <b>undo</b> would return the cursor to the first non-&lt;blank&gt;
   3145 of the line. POSIX.1-2024 requires the most useful of these behaviors, and discards the least useful, in the interest of
   3146 consistency and simplicity of specification.</p>
   3147 <h5><a name="tag_20_146_18_32" id="tag_20_146_18_32"></a>Yank</h5>
   3148 <p>Historically, the <b>yank</b> command did not move to the end of the motion if the motion was in the forward direction. It moved
   3149 to the end of the motion if the motion was in the backward direction, except for the <b>_</b> command, or for the <b>G</b> and
   3150 <b>'</b> commands when the end of the motion was on the current line. This was further complicated by the fact that for a number of
   3151 motion commands, the <b>yank</b> command moved the cursor but did not update the screen; for example, a subsequent command would
   3152 move the cursor from the end of the motion, even though the cursor on the screen had not reflected the cursor movement for the
   3153 <b>yank</b> command. POSIX.1-2024 requires that all <b>yank</b> commands associated with backward motions move the cursor to the
   3154 end of the motion for consistency, and specifically, to make <b>'</b> commands as motions consistent with search patterns as
   3155 motions.</p>
   3156 <h5><a name="tag_20_146_18_33" id="tag_20_146_18_33"></a>Yank Current Line</h5>
   3157 <p>Some historical implementations of the <b>Y</b> command did not behave as described by POSIX.1-2024 when the <tt>'_'</tt> key
   3158 was remapped because they were implemented by pushing the <tt>'_'</tt> key onto the input queue and reprocessing it. POSIX.1-2024
   3159 does not permit this behavior.</p>
   3160 <h5><a name="tag_20_146_18_34" id="tag_20_146_18_34"></a>Redraw Window</h5>
   3161 <p>Historically, the <b>z</b> command always redrew the screen. This is permitted but not required by POSIX.1-2024, because of the
   3162 frequent use of the <b>z</b> command in macros such as <b>map n nz.</b> for screen positioning, instead of its use to change the
   3163 screen size. The standard developers believed that expanding or scrolling the screen offered a better interface for users. The
   3164 ability to redraw the screen is preserved if the optional new window size is specified, and in the &lt;control&gt;-L and
   3165 &lt;control&gt;-R commands.</p>
   3166 <p>The semantics of <b>z^</b> are confusing at best. Historical practice is that the screen before the screen that ended with the
   3167 specified line is displayed. POSIX.1-2024 requires conformance to historical practice.</p>
   3168 <p>Historically, the <b>z</b> command would not display a partial line at the top or bottom of the screen. If the partial line
   3169 would normally have been displayed at the bottom of the screen, the command worked, but the partial line was replaced with
   3170 <tt>'@'</tt> characters. If the partial line would normally have been displayed at the top of the screen, the command would fail.
   3171 For consistency and simplicity of specification, POSIX.1-2024 does not permit this behavior.</p>
   3172 <p>Historically, the <b>z</b> command with a line specification of 1 ignored the command. For consistency and simplicity of
   3173 specification, POSIX.1-2024 does not permit this behavior.</p>
   3174 <p>Historically, the <b>z</b> command did not set the cursor column to the first non-&lt;blank&gt; for the character if the first
   3175 screen was to be displayed, and was already displayed. For consistency and simplicity of specification, POSIX.1-2024 does not
   3176 permit this behavior.</p>
   3177 <h5><a name="tag_20_146_18_35" id="tag_20_146_18_35"></a>Input Mode Commands in vi</h5>
   3178 <p>Historical implementations of <i>vi</i> did not permit the user to erase more than a single line of input, or to use normal
   3179 erase characters such as <i>line erase</i>, <i>worderase</i>, and <i>erase</i> to erase <b>autoindent</b> characters. As there
   3180 exist implementations of <i>vi</i> that do not have these limitations, both behaviors are permitted, but only historical practice
   3181 is required. In the case of these extensions, <i>vi</i> is required to pause at the <b>autoindent</b> and previous line
   3182 boundaries.</p>
   3183 <p>Historical implementations of <i>vi</i> updated only the portion of the screen where the current cursor character was displayed.
   3184 For example, consider the <i>vi</i> input keystrokes:</p>
   3185 <pre>
   3186 <tt>iabcd&lt;escape&gt;0C&lt;tab&gt;
   3187 </tt></pre>
   3188 <p>Historically, the &lt;tab&gt; would overwrite the characters <tt>"abcd"</tt> when it was displayed. Other implementations
   3189 replace only the <tt>'a'</tt> character with the &lt;tab&gt;, and then push the rest of the characters ahead of the cursor. Both
   3190 implementations have problems. The historical implementation is probably visually nicer for the above example; however, for the
   3191 keystrokes:</p>
   3192 <pre>
   3193 <tt>iabcd&lt;ESC&gt;0R&lt;tab&gt;&lt;ESC&gt;
   3194 </tt></pre>
   3195 <p>the historical implementation results in the string <tt>"bcd"</tt> disappearing and then magically reappearing when the
   3196 &lt;ESC&gt; character is entered. POSIX.1-2024 requires the former behavior when overwriting erase-columns—that is, overwriting
   3197 characters that are no longer logically part of the edit buffer—and the latter behavior otherwise.</p>
   3198 <p>Historical implementations of <i>vi</i> discarded the &lt;control&gt;-D and &lt;control&gt;-T characters when they were entered
   3199 at places where their command functionality was not appropriate. POSIX.1-2024 requires that the &lt;control&gt;-T functionality
   3200 always be available, and that &lt;control&gt;-D be treated as any other key when not operating on <b>autoindent</b> characters.</p>
   3201 <h5><a name="tag_20_146_18_36" id="tag_20_146_18_36"></a>NUL</h5>
   3202 <p>Some historical implementations of <i>vi</i> limited the number of characters entered using the NUL input character to 256
   3203 bytes. POSIX.1-2024 permits this limitation; however, implementations are encouraged to remove this limit.</p>
   3204 <h5><a name="tag_20_146_18_37" id="tag_20_146_18_37"></a>&lt;control&gt;-D</h5>
   3205 <p>See also Rationale for the input mode command &lt;newline&gt;. The hidden assumptions in the &lt;control&gt;-D command (and in
   3206 the <i>vi</i> <b>autoindent</b> specification in general) is that &lt;space&gt; characters take up a single column on the screen
   3207 and that &lt;tab&gt; characters are comprised of an integral number of &lt;space&gt; characters.</p>
   3208 <h5><a name="tag_20_146_18_38" id="tag_20_146_18_38"></a>&lt;newline&gt;</h5>
   3209 <p>Implementations are permitted to rewrite <b>autoindent</b> characters in the line when &lt;newline&gt;, &lt;carriage-return&gt;,
   3210 &lt;control&gt;-D, and &lt;control&gt;-T are entered, or when the <b>shift</b> commands are used, because historical
   3211 implementations have both done so and found it necessary to do so. For example, a &lt;control&gt;-D when the cursor is preceded by
   3212 a single &lt;tab&gt;, with <b>tabstop</b> set to 8, and <b>shiftwidth</b> set to 3, will result in the &lt;tab&gt; being replaced
   3213 by several &lt;space&gt; characters.</p>
   3214 <h5><a name="tag_20_146_18_39" id="tag_20_146_18_39"></a>&lt;control&gt;-T</h5>
   3215 <p>See also the Rationale for the input mode command &lt;newline&gt;. Historically, &lt;control&gt;-T only worked if no
   3216 non-&lt;blank&gt; characters had yet been input in the current input line. In addition, the characters inserted by
   3217 &lt;control&gt;-T were treated as <b>autoindent</b> characters, and could not be erased using normal user erase characters. Because
   3218 implementations exist that do not have these limitations, and as moving to a column boundary is generally useful, POSIX.1-2024
   3219 requires that both limitations be removed.</p>
   3220 <h5><a name="tag_20_146_18_40" id="tag_20_146_18_40"></a>&lt;control&gt;-V</h5>
   3221 <p>Historically, <i>vi</i> used <b>^V</b>, regardless of the value of the literal-next character of the terminal. POSIX.1-2024
   3222 requires conformance to historical practice.</p>
   3223 <p>The uses described for &lt;control&gt;-V can also be accomplished with &lt;control&gt;-Q, which is useful on terminals that use
   3224 &lt;control&gt;-V for the down-arrow function. However, most historical implementations use &lt;control&gt;-Q for the
   3225 <i>termios</i> START character, so the editor will generally not receive the &lt;control&gt;-Q unless <b>stty ixon</b> mode is set
   3226 to off. (In addition, some historical implementations of <i>vi</i> explicitly set <b>ixon</b> mode to on, so it was difficult for
   3227 the user to set it to off.) Any of the command characters described in POSIX.1-2024 can be made ineffective by their selection as
   3228 <i>termios</i> control characters, using the <a href="../utilities/stty.html"><i>stty</i></a> utility or other methods described in
   3229 the System Interfaces volume of POSIX.1-2024.</p>
   3230 <h5><a name="tag_20_146_18_41" id="tag_20_146_18_41"></a>&lt;ESC&gt;</h5>
   3231 <p>Historically, SIGINT alerted the terminal when used to end input mode. This behavior is permitted, but not required, by
   3232 POSIX.1-2024.</p>
   3233 </blockquote>
   3234 <h4 class="mansect"><a name="tag_20_146_19" id="tag_20_146_19"></a>FUTURE DIRECTIONS</h4>
   3235 <blockquote>
   3236 <p>If this utility is directed to create a new directory entry that contains any bytes that have the encoded value of a
   3237 &lt;newline&gt; character, implementations are encouraged to treat this as an error. A future version of this standard may require
   3238 implementations to treat this as an error.</p>
   3239 </blockquote>
   3240 <h4 class="mansect"><a name="tag_20_146_20" id="tag_20_146_20"></a>SEE ALSO</h4>
   3241 <blockquote>
   3242 <p><a href="../utilities/ed.html#"><i>ed</i></a> , <a href="../utilities/ex.html#"><i>ex</i></a> , <a href=
   3243 "../utilities/stty.html#"><i>stty</i></a></p>
   3244 <p>XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
   3245 </blockquote>
   3246 <h4 class="mansect"><a name="tag_20_146_21" id="tag_20_146_21"></a>CHANGE HISTORY</h4>
   3247 <blockquote>
   3248 <p>First released in Issue 2.</p>
   3249 </blockquote>
   3250 <h4 class="mansect"><a name="tag_20_146_22" id="tag_20_146_22"></a>Issue 5</h4>
   3251 <blockquote>
   3252 <p>The FUTURE DIRECTIONS section is added.</p>
   3253 </blockquote>
   3254 <h4 class="mansect"><a name="tag_20_146_23" id="tag_20_146_23"></a>Issue 6</h4>
   3255 <blockquote>
   3256 <p>This utility is marked as part of the User Portability Utilities option.</p>
   3257 <p>The APPLICATION USAGE section is added.</p>
   3258 <p>The obsolescent SYNOPSIS is removed.</p>
   3259 <p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
   3260 <ul>
   3261 <li>
   3262 <p>The <b>reindent</b> command description is added.</p>
   3263 </li>
   3264 </ul>
   3265 <p>The <i>vi</i> utility has been extensively rewritten for alignment with the IEEE&nbsp;P1003.2b draft standard.</p>
   3266 <p>IEEE PASC Interpretations 1003.2 #57, #62, #63, #64, #78, and #188 are applied.</p>
   3267 <p>IEEE PASC Interpretation 1003.2 #207 is applied, clarifying the description of the <b>R</b> command in a manner similar to the
   3268 descriptions of other text input mode commands such as <b>i</b>, <b>o</b>, and <b>O</b>.</p>
   3269 <p>The <b>-l</b> option is removed.</p>
   3270 <p>IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;1-2002, item XCU/TC1/D6/41 is applied, adding [<i>count</i>] to the Synopsis for
   3271 <b>[[</b>.</p>
   3272 <p>IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;1-2002, item XCU/TC1/D6/42 is applied, adding [<i>count</i>] to the Synopsis for
   3273 <b>]]</b>.</p>
   3274 </blockquote>
   3275 <h4 class="mansect"><a name="tag_20_146_24" id="tag_20_146_24"></a>Issue 7</h4>
   3276 <blockquote>
   3277 <p>Austin Group Interpretation 1003.1-2001 #027 is applied, clarifying that <tt>'+'</tt> may be recognized as an option delimiter
   3278 in the OPTIONS section.</p>
   3279 <p>Austin Group Interpretation 1003.1-2001 #087 is applied, updating the Put from Buffer Before (<b>P</b>) command description to
   3280 address multi-line requirements.</p>
   3281 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
   3282 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0202 [812] is applied.</p>
   3283 </blockquote>
   3284 <h4 class="mansect"><a name="tag_20_146_25" id="tag_20_146_25"></a>Issue 8</h4>
   3285 <blockquote>
   3286 <p>Austin Group Defect 251 is applied, encouraging implementations to disallow the creation of filenames containing any bytes that
   3287 have the encoded value of a &lt;newline&gt; character.</p>
   3288 <p>Austin Group Defect 1310 is applied, changing the CONSEQUENCES OF ERRORS section.</p>
   3289 <p>Austin Group Defect 1676 is applied, changing the typeface of some bold text in the RATIONALE section.</p>
   3290 </blockquote>
   3291 <div class="box"><em>End of informative text.</em></div>
   3292 <hr>
   3293 <p>&nbsp;</p>
   3294 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
   3295 <hr size="2" noshade>
   3296 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
   3297 POSIX™ is a Trademark of The IEEE.<br>
   3298 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
   3299 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
   3300 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
   3301 ]</font></center>
   3302 <hr size="2" noshade>
   3303 <div class="NAVHEADER">
   3304 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
   3305 <tr class="nav">
   3306 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/val.html" accesskey="P">&lt;&lt;&lt;
   3307 Previous</a></td>
   3308 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
   3309 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/wait.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
   3310 </tr>
   3311 </table>
   3312 <hr align="left" width="100%"></div>
   3313 </body>
   3314 </html>