isposix

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

git clone git://bebou.netlib.re/isposix

Log | Files | Refs | README |

ex.html (278315B)


      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>ex</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/env.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/expand.html" accesskey="N">Next
     19 &gt;&gt;&gt;</a></td>
     20 </tr>
     21 </table>
     22 <hr align="left" width="100%"></div>
     23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     24 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     25 IEEE Std 1003.1-2024<br>
     26 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     27 <hr size="2" noshade>
     28 <a name="top" id="top"></a> <a name="ex" id="ex"></a> <a name="tag_20_40" id="tag_20_40"></a><!-- ex -->
     29 <h4 class="mansect"><a name="tag_20_40_01" id="tag_20_40_01"></a>NAME</h4>
     30 <blockquote>ex — text editor</blockquote>
     31 <h4 class="mansect"><a name="tag_20_40_02" id="tag_20_40_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt=
     34 "[Option Start]" border="0"> ex</tt> <b>[</b><tt>-rR</tt><b>] [</b><tt>-s|-v</tt><b>] [</b><tt>-c</tt> <i>command</i><b>]
     35 [</b><tt>-t</tt> <i>tagstring</i><b>] [</b><tt>-w</tt> <i>size</i><b>] [</b><i>file</i><tt>...</tt><b>]</b> <tt><img src=
     36 "../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
     37 </blockquote>
     38 <h4 class="mansect"><a name="tag_20_40_03" id="tag_20_40_03"></a>DESCRIPTION</h4>
     39 <blockquote>
     40 <p>The <i>ex</i> utility is a line-oriented text editor. There are two other modes of the editor—open and visual—in which
     41 screen-oriented editing is available. This is described more fully by the <i>ex</i> <b>open</b> and <b>visual</b> commands and in
     42 <a href="../utilities/vi.html#"><i>vi</i></a> .</p>
     43 <p>If an operand is <tt>'-'</tt>, the results are unspecified.</p>
     44 <p>This section uses the term <i>edit buffer</i> to describe the current working text. No specific implementation is implied by
     45 this term. All editing changes are performed on the edit buffer, and no changes to it shall affect any file until an editor command
     46 writes the file.</p>
     47 <p>Certain terminals do not have all the capabilities necessary to support the complete <i>ex</i> definition, such as the
     48 full-screen editing commands (<i>visual mode</i> or <i>open mode</i>). When these commands cannot be supported on such terminals,
     49 this condition shall not produce an error message such as &quot;not an editor command&quot; or report a syntax error. The implementation
     50 may either accept the commands and produce results on the screen that are the result of an unsuccessful attempt to meet the
     51 requirements of this volume of POSIX.1-2024 or report an error describing the terminal-related deficiency.</p>
     52 </blockquote>
     53 <h4 class="mansect"><a name="tag_20_40_04" id="tag_20_40_04"></a>OPTIONS</h4>
     54 <blockquote>
     55 <p>The <i>ex</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     56 Guidelines</i></a> , except for the unspecified usage of <tt>'-'</tt>, and that <tt>'+'</tt> may be recognized as an option
     57 delimiter as well as <tt>'-'</tt>.</p>
     58 <p>The following options shall be supported:</p>
     59 <dl compact>
     60 <dd></dd>
     61 <dt><b>-c&nbsp;</b><i>command</i></dt>
     62 <dd>Specify an initial command to be executed in the first edit buffer loaded from an existing file (see the EXTENDED DESCRIPTION
     63 section). Implementations may support more than a single <b>-c</b> option. In such implementations, the specified commands shall be
     64 executed in the order specified on the command line.</dd>
     65 <dt><b>-r</b></dt>
     66 <dd>Recover the named files (see the EXTENDED DESCRIPTION section). Recovery information for a file shall be saved during an editor
     67 or system crash (for example, when the editor is terminated by a signal which the editor can catch), or after the use of an
     68 <i>ex</i> <b>preserve</b> command.
     69 <p>A <i>crash</i> in this context is an unexpected failure of the system or utility that requires restarting the failed system or
     70 utility. A system crash implies that any utilities running at the time also crash. In the case of an editor or system crash, the
     71 number of changes to the edit buffer (since the most recent <b>preserve</b> command) that will be recovered is unspecified.</p>
     72 <p>If no <i>file</i> operands are given and the <b>-t</b> option is not specified, all other options, the <i>EXINIT</i> variable,
     73 and any <b>.exrc</b> files shall be ignored; a list of all recoverable files available to the invoking user shall be written, and
     74 the editor shall exit normally without further action.</p>
     75 </dd>
     76 <dt><b>-R</b></dt>
     77 <dd>Set <b>readonly</b> edit option.</dd>
     78 <dt><b>-s</b></dt>
     79 <dd>Prepare <i>ex</i> for batch use by taking the following actions:
     80 <ul>
     81 <li>
     82 <p>Suppress writing prompts and informational (but not diagnostic) messages.</p>
     83 </li>
     84 <li>
     85 <p>Ignore the value of <i>TERM</i> and any implementation default terminal type and assume the terminal is a type incapable of
     86 supporting open or visual modes; see the <b>visual</b> command and the description of <a href="../utilities/vi.html#"><i>vi</i></a>
     87 .</p>
     88 </li>
     89 <li>
     90 <p>Suppress the use of the <i>EXINIT</i> environment variable and the reading of any <b>.exrc</b> file; see the EXTENDED
     91 DESCRIPTION section.</p>
     92 </li>
     93 <li>
     94 <p>Suppress autoindentation, ignoring the value of the <b>autoindent</b> edit option.</p>
     95 </li>
     96 </ul>
     97 </dd>
     98 <dt><b>-t&nbsp;</b><i>tagstring</i></dt>
     99 <dd>Edit the file containing the specified <i>tagstring</i>; see <a href="../utilities/ctags.html#"><i>ctags</i></a> . The tags
    100 feature represented by <b>-t</b> <i>tagstring</i> and the <b>tag</b> command is optional. It shall be provided on any system that
    101 also provides a conforming implementation of <a href="../utilities/ctags.html"><i>ctags</i></a>; otherwise, the use of <b>-t</b>
    102 produces undefined results. On any system, it shall be an error to specify more than a single <b>-t</b> option.</dd>
    103 <dt><b>-v</b></dt>
    104 <dd>Begin in visual mode (see <a href="../utilities/vi.html#"><i>vi</i></a> ).</dd>
    105 <dt><b>-w&nbsp;</b><i>size</i></dt>
    106 <dd>Set the value of the <i>window</i> editor option to <i>size</i>.</dd>
    107 </dl>
    108 </blockquote>
    109 <h4 class="mansect"><a name="tag_20_40_05" id="tag_20_40_05"></a>OPERANDS</h4>
    110 <blockquote>
    111 <p>The following operand shall be supported:</p>
    112 <dl compact>
    113 <dd></dd>
    114 <dt><i>file</i></dt>
    115 <dd>A pathname of a file to be edited.</dd>
    116 </dl>
    117 </blockquote>
    118 <h4 class="mansect"><a name="tag_20_40_06" id="tag_20_40_06"></a>STDIN</h4>
    119 <blockquote>
    120 <p>The standard input consists of a series of commands and input text, as described in the EXTENDED DESCRIPTION section. The
    121 implementation may limit each line of standard input to a length of {LINE_MAX}.</p>
    122 <p>If the standard input is not a terminal device, it shall be as if the <b>-s</b> option had been specified.</p>
    123 <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,
    124 it shall be equivalent to a SIGHUP asynchronous event.</p>
    125 </blockquote>
    126 <h4 class="mansect"><a name="tag_20_40_07" id="tag_20_40_07"></a>INPUT FILES</h4>
    127 <blockquote>
    128 <p>Input files shall be text files or files that would be text files except for an incomplete last line that is not longer than
    129 {LINE_MAX}-1 bytes in length and contains no NUL characters. By default, any incomplete last line shall be treated as if it had a
    130 trailing &lt;newline&gt;. The editing of other forms of files may optionally be allowed by <i>ex</i> implementations.</p>
    131 <p>The <b>.exrc</b> files and source files shall be text files consisting of <i>ex</i> commands; see the EXTENDED DESCRIPTION
    132 section.</p>
    133 <p>By default, the editor shall read lines from the files to be edited without interpreting any of those lines as any form of
    134 editor command.</p>
    135 </blockquote>
    136 <h4 class="mansect"><a name="tag_20_40_08" id="tag_20_40_08"></a>ENVIRONMENT VARIABLES</h4>
    137 <blockquote>
    138 <p>The following environment variables shall affect the execution of <i>ex</i>:</p>
    139 <dl compact>
    140 <dd></dd>
    141 <dt><i>COLUMNS</i></dt>
    142 <dd>Override the system-selected horizontal screen size. See XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment
    143 Variables</i></a> for valid values and results when it is unset or null.</dd>
    144 <dt><i>EXINIT</i></dt>
    145 <dd>Determine a list of <i>ex</i> commands that are executed on editor start-up. See the EXTENDED DESCRIPTION section for more
    146 details of the initialization phase.</dd>
    147 <dt><i>HOME</i></dt>
    148 <dd>Determine a pathname of a directory that shall be searched for an editor start-up file named <b>.exrc</b>; see the EXTENDED
    149 DESCRIPTION section.</dd>
    150 <dt><i>LANG</i></dt>
    151 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    152 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    153 variables used to determine the values of locale categories.)</dd>
    154 <dt><i>LC_ALL</i></dt>
    155 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    156 <dt><i>LC_COLLATE</i></dt>
    157 <dd><br>
    158 Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements within regular
    159 expressions.</dd>
    160 <dt><i>LC_CTYPE</i></dt>
    161 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    162 opposed to multi-byte characters in arguments and input files), the behavior of character classes within regular expressions, the
    163 classification of characters as uppercase or lowercase letters, the case conversion of letters, and the detection of word
    164 boundaries.</dd>
    165 <dt><i>LC_MESSAGES</i></dt>
    166 <dd><br>
    167 Determine the locale used to process affirmative responses, and the locale that should be used to affect the format and contents of
    168 diagnostic messages written to standard error.</dd>
    169 <dt><i>LINES</i></dt>
    170 <dd>Override the system-selected vertical screen size, used as the number of lines in a screenful and the vertical screen size in
    171 visual mode. See XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> for valid values and results
    172 when it is unset or null.</dd>
    173 <dt><i>NLSPATH</i></dt>
    174 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    175 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    176 "0"></dd>
    177 <dt><i>PATH</i></dt>
    178 <dd>Determine the search path for the shell command specified in the <i>ex</i> editor commands <b>!</b>, <b>shell</b>, <b>read</b>,
    179 and <b>write</b>, and the open and visual mode command <b>!</b>; see the description of command search and execution in <a href=
    180 "../utilities/V3_chap02.html#tag_19_09_01_04"><i>2.9.1.4 Command Search and Execution</i></a> .</dd>
    181 <dt><i>SHELL</i></dt>
    182 <dd>Determine the preferred command line interpreter for use as the default value of the <b>shell</b> edit option.</dd>
    183 <dt><i>TERM</i></dt>
    184 <dd>Determine the name of the terminal type. If this variable is unset or null, an unspecified default terminal type shall be
    185 used.</dd>
    186 </dl>
    187 </blockquote>
    188 <h4 class="mansect"><a name="tag_20_40_09" id="tag_20_40_09"></a>ASYNCHRONOUS EVENTS</h4>
    189 <blockquote>
    190 <p>The following term is used in this and following sections to specify command and asynchronous event actions:</p>
    191 <dl compact>
    192 <dd></dd>
    193 <dt><i>complete&nbsp;write</i></dt>
    194 <dd><br>
    195 A complete write is a write of the entire contents of the edit buffer to a file of a type other than a terminal device, or the
    196 saving of the edit buffer caused by the user executing the <i>ex</i> <b>preserve</b> command. Writing the contents of the edit
    197 buffer to a temporary file that will be removed when the editor exits shall not be considered a complete write.</dd>
    198 </dl>
    199 <p>The following actions shall be taken upon receipt of signals:</p>
    200 <dl compact>
    201 <dd></dd>
    202 <dt>SIGINT</dt>
    203 <dd>If the standard input is not a terminal device, <i>ex</i> shall not write the file or return to command or text input mode, and
    204 shall exit with a non-zero exit status.
    205 <p>Otherwise, if executing an open or visual text input mode command, <i>ex</i> in receipt of SIGINT shall behave identically to
    206 its receipt of the &lt;ESC&gt; character.</p>
    207 <p>Otherwise:</p>
    208 <ol>
    209 <li>
    210 <p>If executing an <i>ex</i> text input mode command, all input lines that have been completely entered shall be resolved into the
    211 edit buffer, and any partially entered line shall be discarded.</p>
    212 </li>
    213 <li>
    214 <p>If there is a currently executing command, it shall be aborted and a message displayed. Unless otherwise specified by the
    215 <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> command descriptions, it is unspecified whether any lines modified by the
    216 executing command appear modified, or as they were before being modified by the executing command, in the buffer.</p>
    217 <p>If the currently executing command was a motion command, its associated command shall be discarded.</p>
    218 </li>
    219 <li>
    220 <p>If in open or visual command mode, the terminal shall be alerted.</p>
    221 </li>
    222 <li>
    223 <p>The editor shall then return to command mode.</p>
    224 </li>
    225 </ol>
    226 </dd>
    227 <dt>SIGCONT</dt>
    228 <dd>If <i>ex</i> is in open mode or visual mode, the actions described below for SIGWINCH shall be taken, except that the screen
    229 shall always be refreshed (regardless of whether the terminal window size changed).</dd>
    230 <dt>SIGHUP</dt>
    231 <dd>If the edit buffer has been modified since the last complete write, <i>ex</i> shall attempt to save the edit buffer so that it
    232 can be recovered later using the <b>-r</b> option or the <i>ex</i> <b>recover</b> command. The editor shall not write the file or
    233 return to command or text input mode, and shall terminate with a non-zero exit status.</dd>
    234 <dt>SIGTERM</dt>
    235 <dd>Refer to SIGHUP.</dd>
    236 <dt>SIGWINCH</dt>
    237 <dd>If <i>ex</i> is in open mode or visual mode, the current terminal window size associated with the terminal on standard output
    238 shall be obtained, as if by a call to XSH <a href="../functions/tcgetwinsize.html#"><i>tcgetwinsize</i></a> . If the terminal
    239 window size is successfully obtained, it shall be used as follows:
    240 <ul>
    241 <li>
    242 <p>If the <i>COLUMNS</i> environment variable is unset or does not contain a number, the horizontal screen size shall be set to the
    243 number of columns in the obtained terminal window size.</p>
    244 </li>
    245 <li>
    246 <p>If <i>ex</i> is in visual mode, the <b>-w</b> option was not specified and the <i>LINES</i> environment variable is unset or
    247 does not contain a number, the vertical screen size shall be set to the number of rows in the obtained terminal window size.</p>
    248 </li>
    249 </ul>
    250 <p>If the above resulted in either the vertical screen size or the horizontal screen size (or both) changing to a different value,
    251 <i>ex</i> shall update the values it has for the number of lines and columns in the display and shall adjust the <b>window</b> edit
    252 option and the column number at which the <b>wrapmargin</b> edit option takes effect (if non-zero) accordingly (see <a href=
    253 "#tag_20_40_13_60">Edit Options in ex</a> ) and refresh the screen; otherwise, <i>ex</i> may refresh the screen.</p>
    254 </dd>
    255 </dl>
    256 <p>The action taken for all other signals is unspecified.</p>
    257 </blockquote>
    258 <h4 class="mansect"><a name="tag_20_40_10" id="tag_20_40_10"></a>STDOUT</h4>
    259 <blockquote>
    260 <p>The standard output shall be used only for writing prompts to the user, for informational messages, and for writing lines from
    261 the file.</p>
    262 </blockquote>
    263 <h4 class="mansect"><a name="tag_20_40_11" id="tag_20_40_11"></a>STDERR</h4>
    264 <blockquote>
    265 <p>The standard error shall be used only for diagnostic messages.</p>
    266 </blockquote>
    267 <h4 class="mansect"><a name="tag_20_40_12" id="tag_20_40_12"></a>OUTPUT FILES</h4>
    268 <blockquote>
    269 <p>The output from <i>ex</i> shall be text files.</p>
    270 </blockquote>
    271 <h4 class="mansect"><a name="tag_20_40_13" id="tag_20_40_13"></a>EXTENDED DESCRIPTION</h4>
    272 <blockquote>
    273 <p>Only the <i>ex</i> mode of the editor is described in this section. See <a href="../utilities/vi.html#"><i>vi</i></a> for
    274 additional editing capabilities available in <i>ex</i>.</p>
    275 <p>When an error occurs, <i>ex</i> shall write a message. If the terminal supports a standout mode (such as inverse video), the
    276 message shall be written in standout mode. If the terminal does not support a standout mode, and the edit option <b>errorbells</b>
    277 is set, an alert action shall precede the error message.</p>
    278 <p>By default, <i>ex</i> shall start in command mode, which shall be indicated by a <b>:</b> prompt; see the <b>prompt</b> command.
    279 Text input mode can be entered by the <b>append</b>, <b>insert</b>, or <b>change</b> commands; it can be exited (and command mode
    280 re-entered) by typing a &lt;period&gt; (<tt>'.'</tt>) alone at the beginning of a line.</p>
    281 <h5><a name="tag_20_40_13_01" id="tag_20_40_13_01"></a>Initialization in ex and vi</h5>
    282 <p>The following symbols are used in this and following sections to specify locations in the edit buffer:</p>
    283 <dl compact>
    284 <dd></dd>
    285 <dt><i>alternate&nbsp;and&nbsp;current&nbsp;pathnames</i></dt>
    286 <dd><br>
    287 Two pathnames, named <i>current</i> and <i>alternate</i>, are maintained by the editor. Any <i>ex</i> commands that take filenames
    288 as arguments shall set them as follows:
    289 <ol>
    290 <li>
    291 <p>If a <i>file</i> argument is specified to the <i>ex</i> <b>edit</b>, <b>ex</b>, or <b>recover</b> commands, or if an <i>ex</i>
    292 <b>tag</b> command replaces the contents of the edit buffer.</p>
    293 <ol type="a">
    294 <li>
    295 <p>If the command replaces the contents of the edit buffer, the current pathname shall be set to the <i>file</i> argument or the
    296 file indicated by the tag, and the alternate pathname shall be set to the previous value of the current pathname.</p>
    297 </li>
    298 <li>
    299 <p>Otherwise, the alternate pathname shall be set to the <i>file</i> argument.</p>
    300 </li>
    301 </ol>
    302 </li>
    303 <li>
    304 <p>If a <i>file</i> argument is specified to the <i>ex</i> <b>next</b> command:</p>
    305 <ol type="a">
    306 <li>
    307 <p>If the command replaces the contents of the edit buffer, the current pathname shall be set to the first <i>file</i> argument,
    308 and the alternate pathname shall be set to the previous value of the current pathname.</p>
    309 </li>
    310 </ol>
    311 </li>
    312 <li>
    313 <p>If a <i>file</i> argument is specified to the <i>ex</i> <b>file</b> command, the current pathname shall be set to the
    314 <i>file</i> argument, and the alternate pathname shall be set to the previous value of the current pathname.</p>
    315 </li>
    316 <li>
    317 <p>If a <i>file</i> argument is specified to the <i>ex</i> <b>read</b> and <b>write</b> commands (that is, when reading or writing
    318 a file, and not to the program named by the <b>shell</b> edit option), or a <i>file</i> argument is specified to the <i>ex</i>
    319 <b>xit</b> command:</p>
    320 <ol type="a">
    321 <li>
    322 <p>If the current pathname has no value, the current pathname shall be set to the <i>file</i> argument.</p>
    323 </li>
    324 <li>
    325 <p>Otherwise, the alternate pathname shall be set to the <i>file</i> argument.</p>
    326 </li>
    327 </ol>
    328 </li>
    329 </ol>
    330 <p>If the alternate pathname is set to the previous value of the current pathname when the current pathname had no previous value,
    331 then the alternate pathname shall have no value as a result.</p>
    332 </dd>
    333 <dt><i>current&nbsp;line</i></dt>
    334 <dd><br>
    335 The line of the edit buffer referenced by the cursor. Each command description specifies the current line after the command has
    336 been executed, as the <i>current line value</i>. When the edit buffer contains no lines, the current line shall be zero; see
    337 <a href="#tag_20_40_13_02">Addressing in ex</a> .</dd>
    338 <dt><i>current&nbsp;column</i></dt>
    339 <dd><br>
    340 The current display line column occupied by the cursor. (The columns shall be numbered beginning at 1.) Each command description
    341 specifies the current column after the command has been executed, as the <i>current column</i> value. This column is an
    342 <i>ideal</i> column that is remembered over the lifetime of the editor. The actual display line column upon which the cursor rests
    343 may be different from the current column; see the cursor positioning discussion in <a href=
    344 "../utilities/vi.html#tag_20_146_13_02"><i>Command Descriptions in vi</i></a> .</dd>
    345 <dt><i>set&nbsp;to&nbsp;non-&lt;blank&gt;</i></dt>
    346 <dd><br>
    347 A description for a current column value, meaning that the current column shall be set to the last display line column on which is
    348 displayed any part of the first non-&lt;blank&gt; of the line. If the line has no non-&lt;blank&gt; non-&lt;newline&gt; characters,
    349 the current column shall be set to the last display line column on which is displayed any part of the last non-&lt;newline&gt;
    350 character in the line. If the line is empty, the current column shall be set to column position 1.</dd>
    351 </dl>
    352 <p>The length of lines in the edit buffer may be limited to {LINE_MAX} bytes. In open and visual mode, the length of lines in the
    353 edit buffer may be limited to the number of characters that will fit in the display. If either limit is exceeded during editing, an
    354 error message shall be written. If either limit is exceeded by a line read in from a file, an error message shall be written and
    355 the edit session may be terminated.</p>
    356 <p>If the editor stops running due to any reason other than a user command, and the edit buffer has been modified since the last
    357 complete write, it shall be equivalent to a SIGHUP asynchronous event. If the system crashes, it shall be equivalent to a SIGHUP
    358 asynchronous event.</p>
    359 <p>During initialization (before the first file is copied into the edit buffer or any user commands from the terminal are
    360 processed) the following shall occur:</p>
    361 <ol>
    362 <li>
    363 <p>If the environment variable <i>EXINIT</i> is set, the editor shall execute the <i>ex</i> commands contained in that
    364 variable.</p>
    365 </li>
    366 <li>
    367 <p>If the <i>EXINIT</i> variable is not set, and all of the following are true:</p>
    368 <ol type="a">
    369 <li>
    370 <p>The <i>HOME</i> environment variable is not null and not empty.</p>
    371 </li>
    372 <li>
    373 <p>The file <b>.exrc</b> in the directory referred to by the <i>HOME</i> environment variable:</p>
    374 <ol type="i">
    375 <li>
    376 <p>Exists</p>
    377 </li>
    378 <li>
    379 <p>Is owned by the same user ID as the real user ID of the process or the process has appropriate privileges</p>
    380 </li>
    381 <li>
    382 <p>Is not writable by anyone other than the owner</p>
    383 </li>
    384 </ol>
    385 </li>
    386 </ol>
    387 <p>the editor shall execute the <i>ex</i> commands contained in that file.</p>
    388 </li>
    389 <li>
    390 <p>If and only if all of the following are true:</p>
    391 <ol type="a">
    392 <li>
    393 <p>The current directory is not referred to by the <i>HOME</i> environment variable.</p>
    394 </li>
    395 <li>
    396 <p>A command in the <i>EXINIT</i> environment variable or a command in the <b>.exrc</b> file in the directory referred to by the
    397 <i>HOME</i> environment variable sets the editor option <b>exrc</b>.</p>
    398 </li>
    399 <li>
    400 <p>The <b>.exrc</b> file in the current directory:</p>
    401 <ol type="i">
    402 <li>
    403 <p>Exists</p>
    404 </li>
    405 <li>
    406 <p>Is owned by the same user ID as the real user ID of the process, or by one of a set of implementation-defined user IDs</p>
    407 </li>
    408 <li>
    409 <p>Is not writable by anyone other than the owner</p>
    410 </li>
    411 </ol>
    412 </li>
    413 </ol>
    414 <p>the editor shall attempt to execute the <i>ex</i> commands contained in that file.</p>
    415 </li>
    416 </ol>
    417 <p>Lines in any <b>.exrc</b> file that are blank lines shall be ignored. If any <b>.exrc</b> file exists, but is not read for
    418 ownership or permission reasons, it shall be an error.</p>
    419 <p>After the <i>EXINIT</i> variable and any <b>.exrc</b> files are processed, the first file specified by the user shall be edited,
    420 as follows:</p>
    421 <ol>
    422 <li>
    423 <p>If the user specified the <b>-t</b> option, the effect shall be as if the <i>ex</i> <b>tag</b> command was entered with the
    424 specified argument, with the exception that if tag processing does not result in a file to edit, the effect shall be as described
    425 in step 3. below.</p>
    426 </li>
    427 <li>
    428 <p>Otherwise, if the user specified any command line <i>file</i> arguments, the effect shall be as if the <i>ex</i> <b>edit</b>
    429 command was entered with the first of those arguments as its <i>file</i> argument.</p>
    430 </li>
    431 <li>
    432 <p>Otherwise, the effect shall be as if the <i>ex</i> <b>edit</b> command was entered with a nonexistent filename as its
    433 <i>file</i> argument. It is unspecified whether this action shall set the current pathname. In an implementation where this action
    434 does not set the current pathname, any editor command using the current pathname shall fail until an editor command sets the
    435 current pathname.</p>
    436 </li>
    437 </ol>
    438 <p>If the <b>-r</b> option was specified, the first time a file in the initial argument list or a file specified by the <b>-t</b>
    439 option is edited, if recovery information has previously been saved about it, that information shall be recovered and the editor
    440 shall behave as if the contents of the edit buffer have already been modified. If there are multiple instances of the file to be
    441 recovered, the one most recently saved shall be recovered, and an informational message that there are previous versions of the
    442 file that can be recovered shall be written. If no recovery information about a file is available, an informational message to this
    443 effect shall be written, and the edit shall proceed as usual.</p>
    444 <p>If the <b>-c</b> option was specified, the first time a file that already exists (including a file that might not exist but for
    445 which recovery information is available, when the <b>-r</b> option is specified) replaces or initializes the contents of the edit
    446 buffer, the current line shall be set to the last line of the edit buffer, the current column shall be set to non-&lt;blank&gt;,
    447 and the <i>ex</i> commands specified with the <b>-c</b> option shall be executed. In this case, the current line and current column
    448 shall not be set as described for the command associated with the replacement or initialization of the edit buffer contents.
    449 However, if the <b>-t</b> option or a <b>tag</b> command is associated with this action, the <b>-c</b> option commands shall be
    450 executed and then the movement to the tag shall be performed.</p>
    451 <p>The current argument list shall initially be set to the filenames specified by the user on the command line. If no filenames are
    452 specified by the user, the current argument list shall be empty. If the <b>-t</b> option was specified, it is unspecified whether
    453 any filename resulting from tag processing shall be prepended to the current argument list. In the case where the filename is added
    454 as a prefix to the current argument list, the current argument list reference shall be set to that filename. In the case where the
    455 filename is not added as a prefix to the current argument list, the current argument list reference shall logically be located
    456 before the first of the filenames specified on the command line (for example, a subsequent <i>ex</i> <b>next</b> command shall edit
    457 the first filename from the command line). If the <b>-t</b> option was not specified, the current argument list reference shall be
    458 to the first of the filenames on the command line.</p>
    459 <h5><a name="tag_20_40_13_02" id="tag_20_40_13_02"></a>Addressing in ex</h5>
    460 <p>Addressing in <i>ex</i> relates to the current line and the current column; the address of a line is its 1-based line number,
    461 the address of a column is its 1-based count from the beginning of the line. Generally, the current line is the last line affected
    462 by a command. The current line number is the address of the current line. In each command description, the effect of the command on
    463 the current line number and the current column is described.</p>
    464 <p>Addresses are constructed as follows:</p>
    465 <ol>
    466 <li>
    467 <p>The character <tt>'.'</tt> (period) shall address the current line.</p>
    468 </li>
    469 <li>
    470 <p>The character <tt>'$'</tt> shall address the last line of the edit buffer.</p>
    471 </li>
    472 <li>
    473 <p>The positive decimal number <i>n</i> shall address the <i>n</i>th line of the edit buffer.</p>
    474 </li>
    475 <li>
    476 <p>The address <tt>"'x"</tt> refers to the line marked with the mark name character <tt>'x'</tt>, which shall be a lowercase letter
    477 from the portable character set, the backquote character, or the single-quote character. It shall be an error if the line that was
    478 marked is not currently present in the edit buffer or the mark has not been set. Lines can be marked with the <i>ex</i> <b>mark</b>
    479 or <b>k</b> commands, or the <a href="../utilities/vi.html"><i>vi</i></a> <b>m</b> command.</p>
    480 </li>
    481 <li>
    482 <p>A regular expression enclosed by &lt;slash&gt; characters (<tt>'/'</tt>) shall address the first line found by searching
    483 forwards from the line following the current line toward the end of the edit buffer and stopping at the first line for which the
    484 line excluding the terminating &lt;newline&gt; matches the regular expression. As stated in <a href="#tag_20_40_13_58">Regular
    485 Expressions in ex</a> , an address consisting of a null regular expression delimited by &lt;slash&gt; characters (<tt>"//"</tt>)
    486 shall address the next line for which the line excluding the terminating &lt;newline&gt; matches the last regular expression
    487 encountered. In addition, the second &lt;slash&gt; can be omitted at the end of a command line. If the <b>wrapscan</b> edit option
    488 is set, the search shall wrap around to the beginning of the edit buffer and continue up to and including the current line, so that
    489 the entire edit buffer is searched. Within the regular expression, the sequence <tt>"\/"</tt> shall represent a literal
    490 &lt;slash&gt; instead of the regular expression delimiter.</p>
    491 </li>
    492 <li>
    493 <p>A regular expression enclosed in &lt;question-mark&gt; characters (<tt>'?'</tt>) shall address the first line found by searching
    494 backwards from the line preceding the current line toward the beginning of the edit buffer and stopping at the first line for which
    495 the line excluding the terminating &lt;newline&gt; matches the regular expression. An address consisting of a null regular
    496 expression delimited by &lt;question-mark&gt; characters (<tt>"??"</tt>) shall address the previous line for which the line
    497 excluding the terminating &lt;newline&gt; matches the last regular expression encountered. In addition, the second
    498 &lt;question-mark&gt; can be omitted at the end of a command line. If the <b>wrapscan</b> edit option is set, the search shall wrap
    499 around from the beginning of the edit buffer to the end of the edit buffer and continue up to and including the current line, so
    500 that the entire edit buffer is searched. Within the regular expression, the sequence <tt>"\?"</tt> shall represent a literal
    501 &lt;question-mark&gt; instead of the RE delimiter.</p>
    502 </li>
    503 <li>
    504 <p>A &lt;plus-sign&gt; (<tt>'+'</tt>) or a &lt;hyphen-minus&gt; (<tt>'-'</tt>) followed by a decimal number shall address the
    505 current line plus or minus the number. A <tt>'+'</tt> or <tt>'-'</tt> not followed by a decimal number shall address the current
    506 line plus or minus 1.</p>
    507 </li>
    508 </ol>
    509 <p>Addresses can be followed by zero or more address offsets, optionally &lt;blank&gt;-separated. Address offsets are constructed
    510 as follows:</p>
    511 <ol>
    512 <li>
    513 <p>A <tt>'+'</tt> or <tt>'-'</tt> immediately followed by a decimal number shall add (subtract) the indicated number of lines to
    514 (from) the address. A <tt>'+'</tt> or <tt>'-'</tt> not followed by a decimal number shall add (subtract) 1 to (from) the
    515 address.</p>
    516 </li>
    517 <li>
    518 <p>A decimal number shall add the indicated number of lines to the address.</p>
    519 </li>
    520 </ol>
    521 <p>It shall not be an error for an intermediate address value to be less than zero or greater than the last line in the edit
    522 buffer. It shall be an error for the final address value to be less than zero or greater than the last line in the edit buffer.</p>
    523 <p>Commands take zero, one, or two addresses; see the descriptions of <i>1addr</i> and <i>2addr</i> in <a href=
    524 "#tag_20_40_13_10">Command Descriptions in ex</a> . If more than the required number of addresses are provided to a command that
    525 requires zero addresses, it shall be an error. Otherwise, if more than the required number of addresses are provided to a command,
    526 the addresses specified first shall be evaluated and then discarded until the maximum number of valid addresses remain.</p>
    527 <p>Addresses shall be separated from each other by a &lt;comma&gt; (<tt>','</tt>) or a &lt;semicolon&gt; (<tt>';'</tt>). If no
    528 address is specified before or after a &lt;comma&gt; or &lt;semicolon&gt; separator, it shall be as if the address of the current
    529 line was specified before or after the separator. In the case of a &lt;semicolon&gt; separator, the current line (<tt>'.'</tt>)
    530 shall be set to the first address, and only then shall the next address be calculated. This feature can be used to determine the
    531 starting line for forwards and backwards searches (see rules 5. and 6.).</p>
    532 <p>A &lt;percent-sign&gt; (<tt>'%'</tt>) shall be equivalent to entering the two addresses <tt>"1,$"</tt>.</p>
    533 <p>Any delimiting &lt;blank&gt; characters between addresses, address separators, or address offsets shall be discarded.</p>
    534 <h5><a name="tag_20_40_13_03" id="tag_20_40_13_03"></a>Command Line Parsing in ex</h5>
    535 <p>The following symbol is used in this and following sections to describe parsing behavior:</p>
    536 <dl compact>
    537 <dd></dd>
    538 <dt><i>escape</i></dt>
    539 <dd>If a character is referred to as &quot;&lt;backslash&gt;-escaped&quot; or &quot;&lt;control&gt;-V-escaped&quot;, it shall mean that the
    540 character acquired or lost a special meaning by virtue of being preceded, respectively, by a &lt;backslash&gt; or &lt;control&gt;-V
    541 character. Unless otherwise specified, the escaping character shall be discarded at that time and shall not be further considered
    542 for any purpose.</dd>
    543 </dl>
    544 <p>Command-line parsing shall be done in the following steps. For each step, characters already evaluated shall be ignored; that
    545 is, the phrase &quot;leading character&quot; refers to the next character that has not yet been evaluated.</p>
    546 <ol>
    547 <li>
    548 <p>Leading &lt;colon&gt; characters shall be skipped.</p>
    549 </li>
    550 <li>
    551 <p>Leading &lt;blank&gt; characters shall be skipped.</p>
    552 </li>
    553 <li>
    554 <p>If the leading character is a double-quote character, the characters up to and including the next non-&lt;backslash&gt;-escaped
    555 &lt;newline&gt; shall be discarded, and any subsequent characters shall be parsed as a separate command.</p>
    556 </li>
    557 <li>
    558 <p>Leading characters that can be interpreted as addresses shall be evaluated; see <a href="#tag_20_40_13_02">Addressing in ex</a>
    559 .</p>
    560 </li>
    561 <li>
    562 <p>Leading &lt;blank&gt; characters shall be skipped.</p>
    563 </li>
    564 <li>
    565 <p>If the next character is a &lt;vertical-line&gt; character or a &lt;newline&gt;:</p>
    566 <ol type="a">
    567 <li>
    568 <p>If the next character is a &lt;newline&gt;:</p>
    569 <ol type="i">
    570 <li>
    571 <p>If <i>ex</i> is in open or visual mode, the current line shall be set to the last address specified, if any.</p>
    572 </li>
    573 <li>
    574 <p>Otherwise, if the last command was terminated by a &lt;vertical-line&gt; character, no action shall be taken; for example, the
    575 command <tt>"||&lt;newline&gt;"</tt> shall execute two implied commands, not three.</p>
    576 </li>
    577 <li>
    578 <p>Otherwise, step 6.b. shall apply.</p>
    579 </li>
    580 </ol>
    581 </li>
    582 <li>
    583 <p>Otherwise, the implied command shall be the <b>print</b> command. The last <b>#</b>, <b>p</b>, and <b>l</b> flags specified to
    584 any <i>ex</i> command shall be remembered and shall apply to this implied command. Executing the <i>ex</i> <b>number</b>,
    585 <b>print</b>, or <b>list</b> command shall set the remembered flags to <b>#</b>, nothing, and <b>l</b>, respectively, plus any
    586 other flags specified for that execution of the <b>number</b>, <b>print</b>, or <b>list</b> command.</p>
    587 <p>If <i>ex</i> is not currently performing a <b>global</b> or <b>v</b> command, and no address or count is specified, the current
    588 line shall be incremented by 1 before the command is executed. If incrementing the current line would result in an address past the
    589 last line in the edit buffer, the command shall fail, and the increment shall not happen.</p>
    590 </li>
    591 <li>
    592 <p>The &lt;newline&gt; or &lt;vertical-line&gt; character shall be discarded and any subsequent characters shall be parsed as a
    593 separate command.</p>
    594 </li>
    595 </ol>
    596 </li>
    597 <li>
    598 <p>The command name shall be comprised of the next character (if the character is not alphabetic), or the next character and any
    599 subsequent alphabetic characters (if the character is alphabetic), with the following exceptions:</p>
    600 <ol type="a">
    601 <li>
    602 <p>Commands that consist of any prefix of the characters in the command name <b>delete</b>, followed immediately by any of the
    603 characters <tt>'l'</tt>, <tt>'p'</tt>, <tt>'+'</tt>, <tt>'-'</tt>, or <tt>'#'</tt> shall be interpreted as a <b>delete</b> command,
    604 followed by a &lt;blank&gt;, followed by the characters that were not part of the prefix of the <b>delete</b> command. The maximum
    605 number of characters shall be matched to the command name <b>delete</b>; for example, <tt>"del"</tt> shall not be treated as
    606 <tt>"de"</tt> followed by the flag <b>l</b>.</p>
    607 </li>
    608 <li>
    609 <p>Commands that consist of the character <tt>'k'</tt>, followed by a character that can be used as the name of a mark, shall be
    610 equivalent to the mark command followed by a &lt;blank&gt;, followed by the character that followed the <tt>'k'</tt>.</p>
    611 </li>
    612 <li>
    613 <p>Commands that consist of the character <tt>'s'</tt>, followed by characters that could be interpreted as valid options to the
    614 <b>s</b> command, shall be the equivalent of the <b>s</b> command, without any pattern or replacement values, followed by a
    615 &lt;blank&gt;, followed by the characters after the <tt>'s'</tt>.</p>
    616 </li>
    617 </ol>
    618 </li>
    619 <li>
    620 <p>The command name shall be matched against the possible command names, and a command name that contains a prefix matching the
    621 characters specified by the user shall be the executed command. In the case of commands where the characters specified by the user
    622 could be ambiguous, the executed command shall be as follows:</p>
    623 <center>
    624 <table border="1" cellpadding="3" align="center">
    625 <tr valign="top">
    626 <td align="left">
    627 <p class="tent"><b>a</b></p>
    628 </td>
    629 <td align="left">
    630 <p class="tent"><b>append</b></p>
    631 </td>
    632 <td align="left">
    633 <p class="tent">n</p>
    634 </td>
    635 <td align="left">
    636 <p class="tent"><b>next</b></p>
    637 </td>
    638 <td align="left">
    639 <p class="tent"><b>t</b></p>
    640 </td>
    641 <td align="left">
    642 <p class="tent">t</p>
    643 </td>
    644 <td align="left">
    645 <p class="tent"><b>&nbsp;</b></p>
    646 </td>
    647 <td align="left">
    648 <p class="tent"><b>&nbsp;</b></p>
    649 </td>
    650 </tr>
    651 <tr valign="top">
    652 <td align="left">
    653 <p class="tent"><b>c</b></p>
    654 </td>
    655 <td align="left">
    656 <p class="tent"><b>change</b></p>
    657 </td>
    658 <td align="left">
    659 <p class="tent">p</p>
    660 </td>
    661 <td align="left">
    662 <p class="tent"><b>print</b></p>
    663 </td>
    664 <td align="left">
    665 <p class="tent"><b>u</b></p>
    666 </td>
    667 <td align="left">
    668 <p class="tent">undo</p>
    669 </td>
    670 <td align="left">
    671 <p class="tent"><b>&nbsp;</b></p>
    672 </td>
    673 <td align="left">
    674 <p class="tent"><b>&nbsp;</b></p>
    675 </td>
    676 </tr>
    677 <tr valign="top">
    678 <td align="left">
    679 <p class="tent"><b>ch</b></p>
    680 </td>
    681 <td align="left">
    682 <p class="tent"><b>change</b></p>
    683 </td>
    684 <td align="left">
    685 <p class="tent">pr</p>
    686 </td>
    687 <td align="left">
    688 <p class="tent"><b>print</b></p>
    689 </td>
    690 <td align="left">
    691 <p class="tent"><b>un</b></p>
    692 </td>
    693 <td align="left">
    694 <p class="tent">undo</p>
    695 </td>
    696 <td align="left">
    697 <p class="tent"><b>&nbsp;</b></p>
    698 </td>
    699 <td align="left">
    700 <p class="tent"><b>&nbsp;</b></p>
    701 </td>
    702 </tr>
    703 <tr valign="top">
    704 <td align="left">
    705 <p class="tent"><b>e</b></p>
    706 </td>
    707 <td align="left">
    708 <p class="tent"><b>edit</b></p>
    709 </td>
    710 <td align="left">
    711 <p class="tent">r</p>
    712 </td>
    713 <td align="left">
    714 <p class="tent"><b>read</b></p>
    715 </td>
    716 <td align="left">
    717 <p class="tent"><b>v</b></p>
    718 </td>
    719 <td align="left">
    720 <p class="tent">v</p>
    721 </td>
    722 <td align="left">
    723 <p class="tent"><b>&nbsp;</b></p>
    724 </td>
    725 <td align="left">
    726 <p class="tent"><b>&nbsp;</b></p>
    727 </td>
    728 </tr>
    729 <tr valign="top">
    730 <td align="left">
    731 <p class="tent"><b>m</b></p>
    732 </td>
    733 <td align="left">
    734 <p class="tent"><b>move</b></p>
    735 </td>
    736 <td align="left">
    737 <p class="tent">re</p>
    738 </td>
    739 <td align="left">
    740 <p class="tent"><b>read</b></p>
    741 </td>
    742 <td align="left">
    743 <p class="tent"><b>w</b></p>
    744 </td>
    745 <td align="left">
    746 <p class="tent">write</p>
    747 </td>
    748 <td align="left">
    749 <p class="tent"><b>&nbsp;</b></p>
    750 </td>
    751 <td align="left">
    752 <p class="tent"><b>&nbsp;</b></p>
    753 </td>
    754 </tr>
    755 <tr valign="top">
    756 <td align="left">
    757 <p class="tent"><b>ma</b></p>
    758 </td>
    759 <td align="left">
    760 <p class="tent"><b>mark</b></p>
    761 </td>
    762 <td align="left">
    763 <p class="tent">s</p>
    764 </td>
    765 <td align="left">
    766 <p class="tent"><b>s</b></p>
    767 </td>
    768 <td align="left">
    769 <p class="tent"><b>&nbsp;</b></p>
    770 </td>
    771 <td align="left">
    772 <p class="tent">&nbsp;</p>
    773 </td>
    774 <td align="left">
    775 <p class="tent"><b>&nbsp;</b></p>
    776 </td>
    777 <td align="left">
    778 <p class="tent"><b>&nbsp;</b></p>
    779 </td>
    780 </tr>
    781 </table>
    782 </center>
    783 <p class="tent">Implementation extensions with names causing similar ambiguities shall not be checked for a match until all
    784 possible matches for commands specified by POSIX.1-2024 have been checked.</p>
    785 </li>
    786 <li class="tent">If the command is a <b>!</b> command, or if the command is a <b>read</b> command followed by zero or more
    787 &lt;blank&gt; characters and a <b>!</b>, or if the command is a <b>write</b> command followed by one or more &lt;blank&gt;
    788 characters and a <b>!</b>, the rest of the command shall include all characters up to a non-&lt;backslash&gt;-escaped
    789 &lt;newline&gt;. The &lt;newline&gt; shall be discarded and any subsequent characters shall be parsed as a separate <i>ex</i>
    790 command.</li>
    791 <li class="tent">Otherwise, if the command is an <b>edit</b>, <b>ex</b>, or <b>next</b> command, or a <b>visual</b> command while
    792 in open or visual mode, the next part of the command shall be parsed as follows:
    793 <ol type="a">
    794 <li class="tent">Any <tt>'!'</tt> character immediately following the command shall be skipped and be part of the command.</li>
    795 <li class="tent">Any leading &lt;blank&gt; characters shall be skipped and be part of the command.</li>
    796 <li class="tent">If the next character is a <tt>'+'</tt>, characters up to the first non-&lt;backslash&gt;-escaped &lt;newline&gt;
    797 or non-&lt;backslash&gt;-escaped &lt;blank&gt; shall be skipped and be part of the command.</li>
    798 <li class="tent">The rest of the command shall be determined by the steps specified in paragraph 12.</li>
    799 </ol>
    800 </li>
    801 <li class="tent">Otherwise, if the command is a <b>global</b>, <b>open</b>, <b>s</b>, or <b>v</b> command, the next part of the
    802 command shall be parsed as follows:
    803 <ol type="a">
    804 <li class="tent">Any leading &lt;blank&gt; characters shall be skipped and be part of the command.</li>
    805 <li class="tent">If the next character is not an alphanumeric, double-quote, &lt;newline&gt;, &lt;backslash&gt;, or
    806 &lt;vertical-line&gt; character:
    807 <ol type="i">
    808 <li class="tent">The next character shall be used as a command delimiter.</li>
    809 <li class="tent">If the command is a <b>global</b>, <b>open</b>, or <b>v</b> command, characters up to the first
    810 non-&lt;backslash&gt;-escaped &lt;newline&gt;, or first non-&lt;backslash&gt;-escaped delimiter character, shall be skipped and be
    811 part of the command.</li>
    812 <li class="tent">If the command is an <b>s</b> command, characters up to the first non-&lt;backslash&gt;-escaped &lt;newline&gt;,
    813 or second non-&lt;backslash&gt;-escaped delimiter character, shall be skipped and be part of the command.</li>
    814 </ol>
    815 </li>
    816 <li class="tent">If the command is a <b>global</b> or <b>v</b> command, characters up to the first non-&lt;backslash&gt;-escaped
    817 &lt;newline&gt; shall be skipped and be part of the command.</li>
    818 <li class="tent">Otherwise, the rest of the command shall be determined by the steps specified in paragraph 12.</li>
    819 </ol>
    820 </li>
    821 <li class="tent">Otherwise:
    822 <ol type="a">
    823 <li class="tent">If the command was a <b>map</b>, <b>unmap</b>, <b>abbreviate</b>, or <b>unabbreviate</b> command, characters up to
    824 the first non-&lt;control&gt;-V-escaped &lt;newline&gt;, &lt;vertical-line&gt;, or double-quote character shall be skipped and be
    825 part of the command.</li>
    826 <li class="tent">Otherwise, characters up to the first non-&lt;backslash&gt;-escaped &lt;newline&gt;, &lt;vertical-line&gt;, or
    827 double-quote character shall be skipped and be part of the command.</li>
    828 <li class="tent">If the command was an <b>append</b>, <b>change</b>, or <b>insert</b> command, and the step 12.b. ended at a
    829 &lt;vertical-line&gt; character, any subsequent characters, up to the next non-&lt;backslash&gt;-escaped &lt;newline&gt; shall be
    830 used as input text to the command.</li>
    831 <li class="tent">If the command was ended by a double-quote character, all subsequent characters, up to the next
    832 non-&lt;backslash&gt;-escaped &lt;newline&gt;, shall be discarded.</li>
    833 <li class="tent">The terminating &lt;newline&gt; or &lt;vertical-line&gt; character shall be discarded and any subsequent
    834 characters shall be parsed as a separate <i>ex</i> command.</li>
    835 </ol>
    836 </li>
    837 </ol>
    838 <p class="tent">Command arguments shall be parsed as described by the Synopsis and Description of each individual <i>ex</i>
    839 command. This parsing shall not be &lt;blank&gt;-sensitive, except for the <b>!</b> argument, which has to follow the command name
    840 without intervening &lt;blank&gt; characters, and where it would otherwise be ambiguous. For example, <i>count</i> and <i>flag</i>
    841 arguments need not be &lt;blank&gt;-separated because <tt>"d22p"</tt> is not ambiguous, but <i>file</i> arguments to the <i>ex</i>
    842 <b>next</b> command need to be separated by one or more &lt;blank&gt; characters. Any &lt;blank&gt; in command arguments for the
    843 <b>abbreviate</b>, <b>unabbreviate</b>, <b>map</b>, and <b>unmap</b> commands can be &lt;control&gt;-V-escaped, in which case the
    844 &lt;blank&gt; shall not be used as an argument delimiter. Any &lt;blank&gt; in the command argument for any other command can be
    845 &lt;backslash&gt;-escaped, in which case that &lt;blank&gt; shall not be used as an argument delimiter.</p>
    846 <p class="tent">Within command arguments for the <b>abbreviate</b>, <b>unabbreviate</b>, <b>map</b>, and <b>unmap</b> commands, any
    847 character can be &lt;control&gt;-V-escaped. All such escaped characters shall be treated literally and shall have no special
    848 meaning. Within command arguments for all other <i>ex</i> commands that are not regular expressions or replacement strings, any
    849 character that would otherwise have a special meaning can be &lt;backslash&gt;-escaped. Escaped characters shall be treated
    850 literally, without special meaning as shell expansion characters or <tt>'!'</tt>, <tt>'%'</tt>, and <tt>'#'</tt> expansion
    851 characters. See <a href="#tag_20_40_13_58">Regular Expressions in ex</a> and <a href="#tag_20_40_13_59">Replacement Strings in
    852 ex</a> for descriptions of command arguments that are regular expressions or replacement strings.</p>
    853 <p class="tent">Non-&lt;backslash&gt;-escaped <tt>'%'</tt> characters appearing in <i>file</i> arguments to any <i>ex</i> command
    854 shall be replaced by the current pathname; unescaped <tt>'#'</tt> characters shall be replaced by the alternate pathname. It shall
    855 be an error if <tt>'%'</tt> or <tt>'#'</tt> characters appear unescaped in an argument and their corresponding values are not
    856 set.</p>
    857 <p class="tent">Non-&lt;backslash&gt;-escaped <tt>'!'</tt> characters in the arguments to either the <i>ex</i> <b>!</b> command or
    858 the open and visual mode <b>!</b> command, or in the arguments to the <i>ex</i> <b>read</b> command, where the first
    859 non-&lt;blank&gt; after the command name is a <tt>'!'</tt> character, or in the arguments to the <i>ex</i> <b>write</b> command
    860 where the command name is followed by one or more &lt;blank&gt; characters and the first non-&lt;blank&gt; after the command name
    861 is a <tt>'!'</tt> character, shall be replaced with the arguments to the last of those three commands as they appeared after all
    862 unescaped <tt>'%'</tt>, <tt>'#'</tt>, and <tt>'!'</tt> characters were replaced. It shall be an error if <tt>'!'</tt> characters
    863 appear unescaped in one of these commands and there has been no previous execution of one of these commands.</p>
    864 <p class="tent">If an error occurs during the parsing or execution of an <i>ex</i> command:</p>
    865 <ul>
    866 <li class="tent">An informational message to this effect shall be written. Execution of the <i>ex</i> command shall stop, and the
    867 cursor (for example, the current line and column) shall not be further modified.</li>
    868 <li class="tent">If the <i>ex</i> command resulted from a map expansion, all characters from that map expansion shall be discarded,
    869 except as otherwise specified by the <b>map</b> command.</li>
    870 <li class="tent">Otherwise, if the <i>ex</i> command resulted from the processing of an <i>EXINIT</i> environment variable, a
    871 <b>.exrc</b> file, a <b>:source</b> command, a <b>-c</b> option, or a <b>+</b><i>command</i> specified to an <i>ex</i> <b>edit</b>,
    872 <b>ex</b>, <b>next</b>, or <b>visual</b> command, no further commands from the source of the commands shall be executed.</li>
    873 <li class="tent">Otherwise, if the <i>ex</i> command resulted from the execution of a buffer or a <b>global</b> or <b>v</b>
    874 command, no further commands caused by the execution of the buffer or the <b>global</b> or <b>v</b> command shall be executed.</li>
    875 <li class="tent">Otherwise, if the <i>ex</i> command was not terminated by a &lt;newline&gt;, all characters up to and including
    876 the next non-&lt;backslash&gt;-escaped &lt;newline&gt; shall be discarded.</li>
    877 </ul>
    878 <h5><a name="tag_20_40_13_04" id="tag_20_40_13_04"></a>Input Editing in ex</h5>
    879 <p class="tent">The following symbol is used in this and the following sections to specify command actions:</p>
    880 <dl compact>
    881 <dd></dd>
    882 <dt><i>word</i></dt>
    883 <dd>In the POSIX locale, a word consists of a maximal sequence of letters, digits, and underscores, delimited at both ends by
    884 characters other than letters, digits, or underscores, or by the beginning or end of a line or the edit buffer.</dd>
    885 </dl>
    886 <p class="tent">When accepting input characters from the user, in either <i>ex</i> command mode or <i>ex</i> text input mode,
    887 <i>ex</i> shall enable canonical mode input processing, as defined in the System Interfaces volume of POSIX.1-2024.<br></p>
    888 <p class="tent">If in <i>ex</i> text input mode:</p>
    889 <ol>
    890 <li class="tent">If the <b>number</b> edit option is set, <i>ex</i> shall prompt for input using the line number that would be
    891 assigned to the line if it is entered, in the format specified for the <i>ex</i> <b>number</b> command.</li>
    892 <li class="tent">If the <b>autoindent</b> edit option is set, <i>ex</i> shall prompt for input using <b>autoindent</b> characters,
    893 as described by the <b>autoindent</b> edit option. <b>autoindent</b> characters shall follow the line number, if any.</li>
    894 </ol>
    895 <p class="tent">If in <i>ex</i> command mode:</p>
    896 <ol>
    897 <li class="tent">If the <b>prompt</b> edit option is set, input shall be prompted for using a single <tt>':'</tt> character;
    898 otherwise, there shall be no prompt.</li>
    899 </ol>
    900 <p class="tent">The input characters in the following sections shall have the following effects on the input line.</p>
    901 <h5><a name="tag_20_40_13_05" id="tag_20_40_13_05"></a>Scroll</h5>
    902 <dl compact>
    903 <dd></dd>
    904 <dt><i>Synopsis</i>:</dt>
    905 <dd>
    906 <p class="tent"></p>
    907 <pre>
    908 <tt>eof
    909 </tt></pre></dd>
    910 </dl>
    911 <p class="tent">See the description of the <a href="../utilities/stty.html"><i>stty</i></a> <i>eof</i> character in <a href=
    912 "../utilities/stty.html#"><i>stty</i></a> .</p>
    913 <p class="tent">If in <i>ex</i> command mode:</p>
    914 <blockquote>If the <i>eof</i> character is the first character entered on the line, the line shall be evaluated as if it contained
    915 two characters: a &lt;control&gt;-D and a &lt;newline&gt;.
    916 <p class="tent">Otherwise, the <i>eof</i> character shall have no special meaning.</p>
    917 </blockquote>
    918 <br>
    919 <p class="tent">If in <i>ex</i> text input mode:</p>
    920 <blockquote>If the cursor follows an <b>autoindent</b> character, the <b>autoindent</b> characters in the line shall be modified so
    921 that a part of the next text input character is displayed on the first column in the line after the previous <b>shiftwidth</b> edit
    922 option column boundary, and the user shall be prompted again for input for the same line.
    923 <p class="tent">Otherwise, if the cursor follows a <tt>'0'</tt>, which follows an <b>autoindent</b> character, and the <tt>'0'</tt>
    924 was the previous text input character, the <tt>'0'</tt> and all <b>autoindent</b> characters in the line shall be discarded, and
    925 the user shall be prompted again for input for the same line.</p>
    926 <p class="tent">Otherwise, if the cursor follows a <tt>'^'</tt>, which follows an <b>autoindent</b> character, and the <tt>'^'</tt>
    927 was the previous text input character, the <tt>'^'</tt> and all <b>autoindent</b> characters in the line shall be discarded, and
    928 the user shall be prompted again for input for the same line. In addition, the <b>autoindent</b> level for the next input line
    929 shall be derived from the same line from which the <b>autoindent</b> level for the current input line was derived.</p>
    930 <p class="tent">Otherwise, if there are no <b>autoindent</b> or text input characters in the line, the <i>eof</i> character shall
    931 be discarded.</p>
    932 <p class="tent">Otherwise, the <i>eof</i> character shall have no special meaning.</p>
    933 </blockquote>
    934 <h5><a name="tag_20_40_13_06" id="tag_20_40_13_06"></a>&lt;newline&gt;</h5>
    935 <dl compact>
    936 <dd></dd>
    937 <dt><i>Synopsis</i>:</dt>
    938 <dd>
    939 <p class="tent"></p>
    940 <pre>
    941 <tt>&lt;newline&gt;
    942 <br>
    943 &lt;control&gt;-J
    944 </tt></pre></dd>
    945 </dl>
    946 <p class="tent">If in <i>ex</i> command mode:</p>
    947 <blockquote>Cause the command line to be parsed; &lt;control&gt;-J shall be mapped to the &lt;newline&gt; for this
    948 purpose.</blockquote>
    949 <br>
    950 <p class="tent">If in <i>ex</i> text input mode:</p>
    951 <blockquote>Terminate the current line. If there are no characters other than <b>autoindent</b> characters on the line, all
    952 characters on the line shall be discarded.
    953 <p class="tent">Prompt for text input on a new line after the current line. If the <b>autoindent</b> edit option is set, an
    954 appropriate number of <b>autoindent</b> characters shall be added as a prefix to the line as described by the <i>ex</i>
    955 <b>autoindent</b> edit option.</p>
    956 </blockquote>
    957 <h5><a name="tag_20_40_13_07" id="tag_20_40_13_07"></a>&lt;backslash&gt;</h5>
    958 <dl compact>
    959 <dd></dd>
    960 <dt><i>Synopsis</i>:</dt>
    961 <dd>
    962 <p class="tent"></p>
    963 <pre>
    964 <tt>&lt;backslash&gt;
    965 </tt></pre></dd>
    966 </dl>
    967 <p class="tent">Allow the entry of a subsequent &lt;newline&gt; or &lt;control&gt;-J as a literal character, removing any special
    968 meaning that it may have to the editor during text input mode. The &lt;backslash&gt; character shall be retained and evaluated when
    969 the command line is parsed, or retained and included when the input text becomes part of the edit buffer.</p>
    970 <h5><a name="tag_20_40_13_08" id="tag_20_40_13_08"></a>&lt;control&gt;-V</h5>
    971 <dl compact>
    972 <dd></dd>
    973 <dt><i>Synopsis</i>:</dt>
    974 <dd>
    975 <p class="tent"></p>
    976 <pre>
    977 <tt>&lt;control&gt;-V
    978 </tt></pre></dd>
    979 </dl>
    980 <p class="tent">Allow the entry of any subsequent character as a literal character, removing any special meaning that it may have
    981 to the editor during text input mode. The &lt;control&gt;-V character shall be discarded before the command line is parsed or the
    982 input text becomes part of the edit buffer.</p>
    983 <p class="tent">If the &quot;literal next&quot; functionality is performed by the underlying system, it is implementation-defined whether a
    984 character other than &lt;control&gt;-V performs this function.</p>
    985 <h5><a name="tag_20_40_13_09" id="tag_20_40_13_09"></a>&lt;control&gt;-W</h5>
    986 <dl compact>
    987 <dd></dd>
    988 <dt><i>Synopsis</i>:</dt>
    989 <dd>
    990 <p class="tent"></p>
    991 <pre>
    992 <tt>&lt;control&gt;-W
    993 </tt></pre></dd>
    994 </dl>
    995 <p class="tent">Discard the &lt;control&gt;-W, and the word previous to it in the input line, including any &lt;blank&gt;
    996 characters following the word and preceding the &lt;control&gt;-W. If the &quot;word erase&quot; functionality is performed by the
    997 underlying system, it is implementation-defined whether a character other than &lt;control&gt;-W performs this function.</p>
    998 <h5><a name="tag_20_40_13_10" id="tag_20_40_13_10"></a>Command Descriptions in ex</h5>
    999 <p class="tent">The following symbols are used in this section to represent command modifiers. Some of these modifiers can be
   1000 omitted, in which case the specified defaults shall be used.</p>
   1001 <dl compact>
   1002 <dd></dd>
   1003 <dt><i>1addr</i></dt>
   1004 <dd>A single line address, given in any of the forms described in <a href="#tag_20_40_13_02">Addressing in ex</a> ; the default
   1005 shall be the current line (<tt>'.'</tt>), unless otherwise specified.
   1006 <p class="tent">If the line address is zero, it shall be an error, unless otherwise specified in the following command
   1007 descriptions.</p>
   1008 <p class="tent">If the edit buffer is empty, and the address is specified with a command other than <b>=</b>, <b>append</b>,
   1009 <b>insert</b>, <b>open</b>, <b>put</b>, <b>read</b>, or <b>visual</b>, or the address is not zero, it shall be an error.</p>
   1010 </dd>
   1011 <dt><i>2addr</i></dt>
   1012 <dd>Two addresses specifying an inclusive range of lines. If no addresses are specified, the default for <i>2addr</i> shall be the
   1013 current line only (<tt>".,."</tt>), unless otherwise specified in the following command descriptions. If one address is specified,
   1014 <i>2addr</i> shall specify that line only, unless otherwise specified in the following command descriptions.
   1015 <p class="tent">It shall be an error if the first address is greater than the second address.</p>
   1016 <p class="tent">If the edit buffer is empty, and the two addresses are specified with a command other than the <b>!</b>,
   1017 <b>write</b>, <b>wq</b>, or <b>xit</b> commands, or either address is not zero, it shall be an error.</p>
   1018 </dd>
   1019 <dt><i>count</i></dt>
   1020 <dd>A positive decimal number. If <i>count</i> is specified, it shall be equivalent to specifying an additional address to the
   1021 command, unless otherwise specified by the following command descriptions. The additional address shall be equal to the last
   1022 address specified to the command (either explicitly or by default) plus <i>count</i>-1.
   1023 <p class="tent">If this would result in an address greater than the last line of the edit buffer, it shall be corrected to equal
   1024 the last line of the edit buffer.</p>
   1025 </dd>
   1026 <dt><i>flags</i></dt>
   1027 <dd>One or more of the characters <tt>'+'</tt>, <tt>'-'</tt>, <tt>'#'</tt>, <tt>'p'</tt>, or <tt>'l'</tt> (ell). The flag
   1028 characters can be &lt;blank&gt;-separated, and in any order or combination. The characters <tt>'#'</tt>, <tt>'p'</tt>, and
   1029 <tt>'l'</tt> shall cause lines to be written in the format specified by the <b>print</b> command with the specified <i>flags</i>.
   1030 <p class="tent">The lines to be written are as follows:</p>
   1031 <ol>
   1032 <li class="tent">All edit buffer lines written during the execution of the <i>ex</i> <b>&</b>, <b>~</b>, <b>list</b>,
   1033 <b>number</b>, <b>open</b>, <b>print</b>, <b>s</b>, <b>visual</b>, and <b>z</b> commands shall be written as specified by
   1034 <i>flags</i>.</li>
   1035 <li class="tent">After the completion of an <i>ex</i> command with a flag as an argument, the current line shall be written as
   1036 specified by <i>flags</i>, unless the current line was the last line written by the command.</li>
   1037 </ol>
   1038 <p class="tent">The characters <tt>'+'</tt> and <tt>'-'</tt> cause the value of the current line after the execution of the
   1039 <i>ex</i> command to be adjusted by the offset address as described in <a href="#tag_20_40_13_02">Addressing in ex</a> . This
   1040 adjustment shall occur before the current line is written as described in 2. above.</p>
   1041 <p class="tent">The default for <i>flags</i> shall be none.</p>
   1042 </dd>
   1043 <dt><i>buffer</i></dt>
   1044 <dd>One of a number of named areas for holding text. The named buffers are specified by the alphanumeric characters of the POSIX
   1045 locale. There shall also be one &quot;unnamed&quot; buffer. When no buffer is specified for editor commands that use a buffer, the unnamed
   1046 buffer shall be used. Commands that store text into buffers shall store the text as it was before the command took effect, and
   1047 shall store text occurring earlier in the file before text occurring later in the file, regardless of how the text region was
   1048 specified. Commands that store text into buffers shall store the text into the unnamed buffer as well as any specified buffer.
   1049 <p class="tent">In <i>ex</i> commands, buffer names are specified as the name by itself. In open or visual mode commands the name
   1050 is preceded by a double-quote (<tt>'"'</tt> ) character.</p>
   1051 <p class="tent">If the specified buffer name is an uppercase character, and the buffer contents are to be modified, the buffer
   1052 shall be appended to rather than being overwritten. If the buffer is not being modified, specifying the buffer name in lowercase
   1053 and uppercase shall have identical results.</p>
   1054 <p class="tent">There shall also be buffers named by the numbers 1 through 9. In open and visual mode, if a region of text
   1055 including characters from more than a single line is being modified by the <a href="../utilities/vi.html"><i>vi</i></a> <b>c</b> or
   1056 <b>d</b> commands, the motion character associated with the <b>c</b> or <b>d</b> commands specifies that the buffer text shall be
   1057 in line mode, or the commands <b>%</b>, <b>`</b>, <b>/</b>, <b>?</b>, <b>(</b>, <b>)</b>, <b>N</b>, <b>n</b>, <b>{</b>, or <b>}</b>
   1058 are used to define a region of text for the <b>c</b> or <b>d</b> commands, the contents of buffers 1 through 8 shall be moved into
   1059 the buffer named by the next numerically greater value, the contents of buffer 9 shall be discarded, and the region of text shall
   1060 be copied into buffer 1. This shall be in addition to copying the text into a user-specified buffer or unnamed buffer, or both.
   1061 Numeric buffers can be specified as a source buffer for open and visual mode commands; however, specifying a numeric buffer as the
   1062 write target of an open or visual mode command shall have unspecified results.</p>
   1063 <p class="tent">The text of each buffer shall have the characteristic of being in either line or character mode. Appending text to
   1064 a non-empty buffer shall set the mode to match the characteristic of the text being appended. Appending text to a buffer shall
   1065 cause the creation of at least one additional line in the buffer. All text stored into buffers by <i>ex</i> commands shall be in
   1066 line mode. The <i>ex</i> commands that use buffers as the source of text specify individually how buffers of different modes are
   1067 handled. Each open or visual mode command that uses buffers for any purpose specifies individually the mode of the text stored into
   1068 the buffer and how buffers of different modes are handled.</p>
   1069 </dd>
   1070 <dt><i>file</i></dt>
   1071 <dd>Command text used to derive a pathname. The default shall be the current pathname, as defined previously, in which case, if no
   1072 current pathname has yet been established it shall be an error, except where specifically noted in the individual command
   1073 descriptions that follow. If the command text contains any of the characters <tt>'~'</tt>, <tt>'{'</tt>, <tt>'['</tt>,
   1074 <tt>'*'</tt>, <tt>'?'</tt>, <tt>'$'</tt>, <tt>'"'</tt>, backquote, single-quote, and &lt;backslash&gt;, it shall be subjected to
   1075 the process of &quot;shell expansions&quot;, as described below; if more than a single pathname results and the command expects only one,
   1076 it shall be an error.
   1077 <p class="tent">The process of shell expansions in the editor shall be done as follows. The <i>ex</i> utility shall pass two
   1078 arguments to the program named by the shell edit option; the first shall be <b>-c</b>, and the second shall be the string
   1079 <tt>"echo"</tt> and the command text as a single argument. The standard output and standard error of that command shall replace the
   1080 command text.</p>
   1081 </dd>
   1082 <dt><b>!</b></dt>
   1083 <dd>A character that can be appended to the command name to modify its operation, as detailed in the individual command
   1084 descriptions. With the exception of the <i>ex</i> <b>read</b>, <b>write</b>, and <b>!</b> commands, the <tt>'!'</tt> character
   1085 shall only act as a modifier if there are no &lt;blank&gt; characters between it and the command name.</dd>
   1086 <dt><i>remembered&nbsp;search&nbsp;direction</i></dt>
   1087 <dd><br>
   1088 The <a href="../utilities/vi.html"><i>vi</i></a> commands <b>N</b> and <b>n</b> begin searching in a forwards or backwards
   1089 direction in the edit buffer based on a remembered search direction, which is initially unset, and is set by the <i>ex</i>
   1090 <b>global</b>, <b>v</b>, <b>s</b>, and <b>tag</b> commands, and the <a href="../utilities/vi.html"><i>vi</i></a> <b>/</b> and
   1091 <b>?</b> commands.</dd>
   1092 </dl>
   1093 <h5><a name="tag_20_40_13_11" id="tag_20_40_13_11"></a>Abbreviate</h5>
   1094 <dl compact>
   1095 <dd></dd>
   1096 <dt><i>Synopsis</i>:</dt>
   1097 <dd>
   1098 <p class="tent"></p>
   1099 <pre>
   1100 <tt>ab</tt><b>[</b><i>breviate</i><b>][</b><i>lhs rhs</i><b>]</b><tt>
   1101 </tt></pre></dd>
   1102 </dl>
   1103 <p class="tent">If <i>lhs</i> and <i>rhs</i> are not specified, write the current list of abbreviations and do nothing more.</p>
   1104 <p class="tent">Implementations may restrict the set of characters accepted in <i>lhs</i> or <i>rhs</i>, except that printable
   1105 characters and &lt;blank&gt; characters shall not be restricted. Additional restrictions shall be implementation-defined.</p>
   1106 <p class="tent">In both <i>lhs</i> and <i>rhs</i>, any character may be escaped with a &lt;control&gt;-V, in which case the
   1107 character shall not be used to delimit <i>lhs</i> from <i>rhs</i>, and the escaping &lt;control&gt;-V shall be discarded.</p>
   1108 <p class="tent">In open and visual text input mode, if a non-word or &lt;ESC&gt; character that is not escaped by a
   1109 &lt;control&gt;-V character is entered after a word character, a check shall be made for a set of characters matching <i>lhs</i>,
   1110 in the text input entered during this command. If it is found, the effect shall be as if <i>rhs</i> was entered instead of
   1111 <i>lhs</i>.</p>
   1112 <p class="tent">The set of characters that are checked is defined as follows:</p>
   1113 <ol>
   1114 <li class="tent">If there are no characters inserted before the word and non-word or &lt;ESC&gt; characters that triggered the
   1115 check, the set of characters shall consist of the word character.</li>
   1116 <li class="tent">If the character inserted before the word and non-word or &lt;ESC&gt; characters that triggered the check is a
   1117 word character, the set of characters shall consist of the characters inserted immediately before the triggering characters that
   1118 are word characters, plus the triggering word character.</li>
   1119 <li class="tent">If the character inserted before the word and non-word or &lt;ESC&gt; characters that triggered the check is not a
   1120 word character, the set of characters shall consist of the characters that were inserted before the triggering characters that are
   1121 neither &lt;blank&gt; characters nor word characters, plus the triggering word character.</li>
   1122 </ol>
   1123 <p class="tent">It is unspecified whether the <i>lhs</i> argument entered for the <i>ex</i> <b>abbreviate</b> and
   1124 <b>unabbreviate</b> commands is replaced in this fashion. Regardless of whether or not the replacement occurs, the effect of the
   1125 command shall be as if the replacement had not occurred.</p>
   1126 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1127 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1128 <h5><a name="tag_20_40_13_12" id="tag_20_40_13_12"></a>Append</h5>
   1129 <dl compact>
   1130 <dd></dd>
   1131 <dt><i>Synopsis</i>:</dt>
   1132 <dd>
   1133 <p class="tent"></p>
   1134 <pre>
   1135 <b>[</b><i>1addr</i><b>] </b><tt>a</tt><b>[</b><tt>ppend</tt><b>][</b><tt>!</tt><b>]</b><tt>
   1136 </tt></pre></dd>
   1137 </dl>
   1138 <p class="tent">Enter <i>ex</i> text input mode; the input text shall be placed after the specified line. If line zero is
   1139 specified, the text shall be placed at the beginning of the edit buffer.</p>
   1140 <p class="tent">This command shall be affected by the <b>number</b> and <b>autoindent</b> edit options; following the command name
   1141 with <tt>'!'</tt> shall cause the <b>autoindent</b> edit option setting to be toggled for the duration of this command only.</p>
   1142 <p class="tent"><i>Current line</i>: Set to the last input line; if no lines were input, set to the specified line, or to the first
   1143 line of the edit buffer if a line of zero was specified, or zero if the edit buffer is empty.</p>
   1144 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1145 <h5><a name="tag_20_40_13_13" id="tag_20_40_13_13"></a>Arguments</h5>
   1146 <dl compact>
   1147 <dd></dd>
   1148 <dt><i>Synopsis</i>:</dt>
   1149 <dd>
   1150 <p class="tent"></p>
   1151 <pre>
   1152 <tt>ar</tt><b>[</b><i>gs</i><b>]</b><tt>
   1153 </tt></pre></dd>
   1154 </dl>
   1155 <p class="tent">Write the current argument list, with the current argument-list entry, if any, between <tt>'['</tt> and
   1156 <tt>']'</tt> characters.</p>
   1157 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1158 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1159 <h5><a name="tag_20_40_13_14" id="tag_20_40_13_14"></a>Change</h5>
   1160 <dl compact>
   1161 <dd></dd>
   1162 <dt><i>Synopsis</i>:</dt>
   1163 <dd>
   1164 <p class="tent"></p>
   1165 <pre>
   1166 <b>[</b><i>2addr</i><b>] </b><tt>c</tt><b>[</b><tt>hange</tt><b>][</b><tt>!</tt><b>][</b><i>count</i><b>]</b><tt>
   1167 </tt></pre></dd>
   1168 </dl>
   1169 <p class="tent">Enter <i>ex</i> text input mode; the input text shall replace the specified lines. The specified lines shall be
   1170 copied into the unnamed buffer, which shall become a line mode buffer.</p>
   1171 <p class="tent">This command shall be affected by the <b>number</b> and <b>autoindent</b> edit options; following the command name
   1172 with <tt>'!'</tt> shall cause the <b>autoindent</b> edit option setting to be toggled for the duration of this command only.</p>
   1173 <p class="tent"><i>Current line</i>: Set to the last input line; if no lines were input, set to the line before the first address,
   1174 or to the first line of the edit buffer if there are no lines preceding the first address, or to zero if the edit buffer is
   1175 empty.</p>
   1176 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1177 <h5><a name="tag_20_40_13_15" id="tag_20_40_13_15"></a>Change Directory</h5>
   1178 <dl compact>
   1179 <dd></dd>
   1180 <dt><i>Synopsis</i>:</dt>
   1181 <dd>
   1182 <p class="tent"></p>
   1183 <pre>
   1184 <tt>chd</tt><b>[</b><tt>ir</tt><b>][</b><tt>!</tt><b>][</b><i>directory</i><b>]</b><tt>
   1185 cd</tt><b>[</b><tt>!</tt><b>][</b><i>directory</i><b>]</b><tt>
   1186 </tt></pre></dd>
   1187 </dl>
   1188 <p class="tent">Change the current working directory to <i>directory</i>.</p>
   1189 <p class="tent">If no <i>directory</i> argument is specified, and the <i>HOME</i> environment variable is set to a non-null and
   1190 non-empty value, <i>directory</i> shall default to the value named in the <i>HOME</i> environment variable. If the <i>HOME</i>
   1191 environment variable is empty or is undefined, the default value of <i>directory</i> is implementation-defined.</p>
   1192 <p class="tent">If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete
   1193 write, and the current pathname does not begin with a <tt>'/'</tt>, it shall be an error.</p>
   1194 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1195 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1196 <h5><a name="tag_20_40_13_16" id="tag_20_40_13_16"></a>Copy</h5>
   1197 <dl compact>
   1198 <dd></dd>
   1199 <dt><i>Synopsis</i>:</dt>
   1200 <dd>
   1201 <p class="tent"></p>
   1202 <pre>
   1203 <b>[</b><i>2addr</i><b>] </b><tt>co</tt><b>[</b><tt>py</tt><b>] </b><i>1addr </i><b>[</b><i>flags</i><b>]
   1204 [</b><i>2addr</i><b>] </b><tt>t </tt><i>1addr </i><b>[</b><i>flags</i><b>]</b><tt>
   1205 </tt></pre></dd>
   1206 </dl>
   1207 <p class="tent">Copy the specified lines after the specified destination line; line zero specifies that the lines shall be placed
   1208 at the beginning of the edit buffer.</p>
   1209 <p class="tent"><i>Current line</i>: Set to the last line copied.</p>
   1210 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1211 <h5><a name="tag_20_40_13_17" id="tag_20_40_13_17"></a>Delete</h5>
   1212 <dl compact>
   1213 <dd></dd>
   1214 <dt><i>Synopsis</i>:</dt>
   1215 <dd>
   1216 <p class="tent"></p>
   1217 <pre>
   1218 <b>[</b><i>2addr</i><b>] </b><tt>d</tt><b>[</b><tt>elete</tt><b>][ </b><i>buffer</i><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1219 </tt></pre></dd>
   1220 </dl>
   1221 <p class="tent">Delete the specified lines into a buffer (defaulting to the unnamed buffer), which shall become a line-mode
   1222 buffer.</p>
   1223 <p class="tent">Flags can immediately follow the command name; see <a href="#tag_20_40_13_03">Command Line Parsing in ex</a> .</p>
   1224 <p class="tent"><i>Current line</i>: Set to the line following the deleted lines, or to the last line in the edit buffer if that
   1225 line is past the end of the edit buffer, or to zero if the edit buffer is empty.</p>
   1226 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1227 <h5><a name="tag_20_40_13_18" id="tag_20_40_13_18"></a>Edit</h5>
   1228 <dl compact>
   1229 <dd></dd>
   1230 <dt><i>Synopsis</i>:</dt>
   1231 <dd>
   1232 <p class="tent"></p>
   1233 <pre>
   1234 <tt>e</tt><b>[</b><tt>dit</tt><b>][</b><tt>!</tt><b>][</b><tt>+</tt><i>command</i><b>][</b><i>file</i><b>]</b><tt>
   1235 ex</tt><b>[</b><tt>!</tt><b>][</b><tt>+</tt><i>command</i><b>][</b><i>file</i><b>]</b><tt>
   1236 </tt></pre></dd>
   1237 </dl>
   1238 <p class="tent">If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete
   1239 write, it shall be an error.</p>
   1240 <p class="tent">If <i>file</i> is specified, replace the current contents of the edit buffer with the current contents of
   1241 <i>file</i>, and set the current pathname to <i>file</i>. If <i>file</i> is not specified, replace the current contents of the edit
   1242 buffer with the current contents of the file named by the current pathname. If for any reason the current contents of the file
   1243 cannot be accessed, the edit buffer shall be empty.</p>
   1244 <p class="tent">The <b>+</b><i>command</i> option shall be &lt;blank&gt;-delimited; &lt;blank&gt; characters within the
   1245 <b>+</b><i>command</i> can be escaped by preceding them with a &lt;backslash&gt; character. The <b>+</b><i>command</i> shall be
   1246 interpreted as an <i>ex</i> command immediately after the contents of the edit buffer have been replaced and the current line and
   1247 column have been set.</p>
   1248 <p class="tent">If the edit buffer is empty:</p>
   1249 <p class="tent"><i>Current line</i>: Set to 0.</p>
   1250 <p class="tent"><i>Current column</i>: Set to 1.</p>
   1251 <p class="tent">Otherwise, if executed while in <i>ex</i> command mode or if the <b>+</b><i>command</i> argument is specified:</p>
   1252 <p class="tent"><i>Current line</i>: Set to the last line of the edit buffer.</p>
   1253 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1254 <p class="tent">Otherwise, if <i>file</i> is omitted or results in the current pathname:</p>
   1255 <p class="tent"><i>Current line</i>: Set to the first line of the edit buffer.</p>
   1256 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1257 <p class="tent">Otherwise, if <i>file</i> is the same as the last file edited, the line and column shall be set as follows; if the
   1258 file was previously edited, the line and column may be set as follows:</p>
   1259 <p class="tent"><i>Current line</i>: Set to the last value held when that file was last edited. If this value is not a valid line
   1260 in the new edit buffer, set to the first line of the edit buffer.</p>
   1261 <p class="tent"><i>Current column</i>: If the current line was set to the last value held when the file was last edited, set to the
   1262 last value held when the file was last edited. Otherwise, or if the last value is not a valid column in the new edit buffer, set to
   1263 non-&lt;blank&gt;.<br></p>
   1264 <p class="tent">Otherwise:</p>
   1265 <p class="tent"><i>Current line</i>: Set to the first line of the edit buffer.</p>
   1266 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1267 <h5><a name="tag_20_40_13_19" id="tag_20_40_13_19"></a>File</h5>
   1268 <dl compact>
   1269 <dd></dd>
   1270 <dt><i>Synopsis</i>:</dt>
   1271 <dd>
   1272 <p class="tent"></p>
   1273 <pre>
   1274 <tt>f</tt><b>[</b><tt>ile</tt><b>][</b><i>file</i><b>]</b><tt>
   1275 </tt></pre></dd>
   1276 </dl>
   1277 <p class="tent">If a <i>file</i> argument is specified, the alternate pathname shall be set to the current pathname, and the
   1278 current pathname shall be set to <i>file</i>.</p>
   1279 <p class="tent">Write an informational message. If the file has a current pathname, it shall be included in this message;
   1280 otherwise, the message shall indicate that there is no current pathname. If the edit buffer contains lines, the current line number
   1281 and the number of lines in the edit buffer shall be included in this message; otherwise, the message shall indicate that the edit
   1282 buffer is empty. If the edit buffer has been modified since the last complete write, this fact shall be included in this message.
   1283 If the <b>readonly</b> edit option is set, this fact shall be included in this message. The message may contain other unspecified
   1284 information.</p>
   1285 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1286 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1287 <h5><a name="tag_20_40_13_20" id="tag_20_40_13_20"></a>Global</h5>
   1288 <dl compact>
   1289 <dd></dd>
   1290 <dt><i>Synopsis</i>:</dt>
   1291 <dd>
   1292 <p class="tent"></p>
   1293 <pre>
   1294 <b>[</b><i>2addr</i><b>] </b><tt>g</tt><b>[</b><tt>lobal</tt><b>] </b><tt>/</tt><i>pattern</i><tt>/ </tt><b>[</b><i>commands</i><b>]
   1295 [</b><i>2addr</i><b>] </b><tt>v /</tt><i>pattern</i><tt>/ </tt><b>[</b><i>commands</i><b>]</b><tt>
   1296 </tt></pre></dd>
   1297 </dl>
   1298 <p class="tent">The optional <tt>'!'</tt> character after the <b>global</b> command shall be the same as executing the <b>v</b>
   1299 command.</p>
   1300 <p class="tent">If <i>pattern</i> is empty (for example, <tt>"//"</tt>) or not specified, the last regular expression used in the
   1301 editor command shall be used as the <i>pattern</i>. The <i>pattern</i> can be delimited by &lt;slash&gt; characters (shown in the
   1302 Synopsis), as well as any non-alphanumeric or non-&lt;blank&gt; other than &lt;backslash&gt;, &lt;vertical-line&gt;,
   1303 &lt;newline&gt;, or double-quote. Within the pattern, in certain circumstances the delimiter can be used as a literal character;
   1304 see <a href="#tag_20_40_13_58">Regular Expressions in ex</a> .</p>
   1305 <p class="tent">If no lines are specified, the lines shall default to the entire file.</p>
   1306 <p class="tent">The <b>global</b> and <b>v</b> commands are logically two-pass operations. First, mark the lines within the
   1307 specified lines for which the line excluding the terminating &lt;newline&gt; matches (<b>global</b>) or does not match (<b>v</b> or
   1308 <b>global!</b>) the specified pattern. Second, execute the <i>ex</i> commands given by <i>commands</i>, with the current line
   1309 (<tt>'.'</tt>) set to each marked line. If an error occurs during this process, or the contents of the edit buffer are replaced
   1310 (for example, by the <i>ex</i> <b>:edit</b> command) an error message shall be written and no more commands resulting from the
   1311 execution of this command shall be processed.</p>
   1312 <p class="tent">Multiple <i>ex</i> commands can be specified by entering multiple commands on a single line using a
   1313 &lt;vertical-line&gt; to delimit them, or one per line, by escaping each &lt;newline&gt; with a &lt;backslash&gt;.</p>
   1314 <p class="tent">If no commands are specified:</p>
   1315 <ol>
   1316 <li class="tent">If in <i>ex</i> command mode, it shall be as if the <b>print</b> command were specified.</li>
   1317 <li class="tent">Otherwise, no command shall be executed.</li>
   1318 </ol>
   1319 <p class="tent">For the <b>append</b>, <b>change</b>, and <b>insert</b> commands, the input text shall be included as part of the
   1320 command, and the terminating &lt;period&gt; can be omitted if the command ends the list of commands. The <b>open</b> and
   1321 <b>visual</b> commands can be specified as one of the commands, in which case each marked line shall cause the editor to enter open
   1322 or visual mode. If open or visual mode is exited using the <a href="../utilities/vi.html"><i>vi</i></a> <b>Q</b> command, the
   1323 current line shall be set to the next marked line, and open or visual mode reentered, until the list of marked lines is
   1324 exhausted.</p>
   1325 <p class="tent">The <b>global</b>, <b>v</b>, and <b>undo</b> commands cannot be used in <i>commands</i>. Marked lines may be
   1326 deleted by commands executed for lines occurring earlier in the file than the marked lines. In this case, no commands shall be
   1327 executed for the deleted lines.</p>
   1328 <p class="tent">If the remembered search direction is not set, the <b>global</b> and <b>v</b> commands shall set it to forward.</p>
   1329 <p class="tent">The <b>autoprint</b> and <b>autoindent</b> edit options shall be inhibited for the duration of the <b>g</b> or
   1330 <b>v</b> command.</p>
   1331 <p class="tent"><i>Current line</i>: If no commands executed, set to the last marked line. Otherwise, as specified for the executed
   1332 <i>ex</i> commands.</p>
   1333 <p class="tent"><i>Current column</i>: If no commands are executed, set to non-&lt;blank&gt;; otherwise, as specified for the
   1334 individual <i>ex</i> commands.</p>
   1335 <h5><a name="tag_20_40_13_21" id="tag_20_40_13_21"></a>Insert</h5>
   1336 <dl compact>
   1337 <dd></dd>
   1338 <dt><i>Synopsis</i>:</dt>
   1339 <dd>
   1340 <p class="tent"></p>
   1341 <pre>
   1342 <b>[</b><i>1addr</i><b>] </b><tt>i</tt><b>[</b><tt>nsert</tt><b>][</b><tt>!</tt><b>]</b><tt>
   1343 </tt></pre></dd>
   1344 </dl>
   1345 <p class="tent">Enter <i>ex</i> text input mode; the input text shall be placed before the specified line. If the line is zero or
   1346 1, the text shall be placed at the beginning of the edit buffer.</p>
   1347 <p class="tent">This command shall be affected by the <b>number</b> and <b>autoindent</b> edit options; following the command name
   1348 with <tt>'!'</tt> shall cause the <b>autoindent</b> edit option setting to be toggled for the duration of this command only.</p>
   1349 <p class="tent"><i>Current line</i>: Set to the last input line; if no lines were input, set to the line before the specified line,
   1350 or to the first line of the edit buffer if there are no lines preceding the specified line, or zero if the edit buffer is
   1351 empty.</p>
   1352 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1353 <h5><a name="tag_20_40_13_22" id="tag_20_40_13_22"></a>Join</h5>
   1354 <dl compact>
   1355 <dd></dd>
   1356 <dt><i>Synopsis</i>:</dt>
   1357 <dd>
   1358 <p class="tent"></p>
   1359 <pre>
   1360 <b>[</b><i>2addr</i><b>] </b><tt>j</tt><b>[</b><tt>oin</tt><b>][</b><tt>!</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1361 </tt></pre></dd>
   1362 </dl>
   1363 <p class="tent">If <i>count</i> is specified:</p>
   1364 <blockquote>If no address was specified, the <b>join</b> command shall behave as if <i>2addr</i> were the current line and the
   1365 current line plus <i>count</i> (.,. + <i>count</i>).
   1366 <p class="tent">If one address was specified, the <b>join</b> command shall behave as if <i>2addr</i> were the specified address
   1367 and the specified address plus <i>count</i> (<i>addr</i>,<i>addr</i> + <i>count</i>).</p>
   1368 <p class="tent">If two addresses were specified, the <b>join</b> command shall behave as if an additional address, equal to the
   1369 last address plus <i>count</i> -1 (<i>addr1</i>,<i>addr2</i>,<i>addr2</i> + <i>count</i> -1), was specified.</p>
   1370 <p class="tent">If this would result in a second address greater than the last line of the edit buffer, it shall be corrected to be
   1371 equal to the last line of the edit buffer.</p>
   1372 </blockquote>
   1373 <p class="tent">If no <i>count</i> is specified:</p>
   1374 <blockquote>If no address was specified, the <b>join</b> command shall behave as if <i>2addr</i> were the current line and the next
   1375 line (.,. +1).
   1376 <p class="tent">If one address was specified, the <b>join</b> command shall behave as if <i>2addr</i> were the specified address
   1377 and the next line (<i>addr</i>,<i>addr</i> +1).</p>
   1378 </blockquote>
   1379 <p class="tent">Join the text from the specified lines together into a single line, which shall replace the specified lines.</p>
   1380 <p class="tent">If a <tt>'!'</tt> character is appended to the command name, the <b>join</b> shall be without modification of any
   1381 line, independent of the current locale.</p>
   1382 <p class="tent">Otherwise, in the POSIX locale, set the current line to the first of the specified lines, and then, for each
   1383 subsequent line, proceed as follows:</p>
   1384 <ol>
   1385 <li class="tent">Discard leading &lt;space&gt; characters from the line to be joined.</li>
   1386 <li class="tent">If the line to be joined is now empty, delete it, and skip steps 3 through 5.</li>
   1387 <li class="tent">If the current line ends in a &lt;blank&gt;, or the first character of the line to be joined is a <tt>')'</tt>
   1388 character, join the lines without further modification.</li>
   1389 <li class="tent">If the last character of the current line is a <tt>'.'</tt>, join the lines with two &lt;space&gt; characters
   1390 between them.</li>
   1391 <li class="tent">Otherwise, join the lines with a single &lt;space&gt; between them.</li>
   1392 </ol>
   1393 <p class="tent"><i>Current line</i>: Set to the first line specified.</p>
   1394 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1395 <h5><a name="tag_20_40_13_23" id="tag_20_40_13_23"></a>List</h5>
   1396 <dl compact>
   1397 <dd></dd>
   1398 <dt><i>Synopsis</i>:</dt>
   1399 <dd>
   1400 <p class="tent"></p>
   1401 <pre>
   1402 <b>[</b><i>2addr</i><b>] </b><tt>l</tt><b>[</b><tt>ist</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1403 </tt></pre></dd>
   1404 </dl>
   1405 <p class="tent">This command shall be equivalent to the <i>ex</i> command:</p>
   1406 <pre>
   1407 <b>[</b><i>2addr</i><b>] </b><tt>p</tt><b>[</b><tt>rint</tt><b>][</b><i>count</i><b>] </b><tt>l</tt><b>[</b><i>flags</i><b>]</b><tt>
   1408 </tt></pre>
   1409 <p class="tent">See <a href="#tag_20_40_13_31">Print</a> .</p>
   1410 <h5><a name="tag_20_40_13_24" id="tag_20_40_13_24"></a>Map</h5>
   1411 <dl compact>
   1412 <dd></dd>
   1413 <dt><i>Synopsis</i>:</dt>
   1414 <dd>
   1415 <p class="tent"></p>
   1416 <pre>
   1417 <tt>map</tt><b>[</b><tt>!</tt><b>][</b><i>lhs rhs</i><b>]</b><tt>
   1418 </tt></pre></dd>
   1419 </dl>
   1420 <p class="tent">If <i>lhs</i> and <i>rhs</i> are not specified:</p>
   1421 <ol>
   1422 <li class="tent">If <tt>'!'</tt> is specified, write the current list of text input mode maps.</li>
   1423 <li class="tent">Otherwise, write the current list of command mode maps.</li>
   1424 <li class="tent">Do nothing more.</li>
   1425 </ol>
   1426 <p class="tent">Implementations may restrict the set of characters accepted in <i>lhs</i> or <i>rhs</i>, except that printable
   1427 characters and &lt;blank&gt; characters shall not be restricted. Additional restrictions shall be implementation-defined. In both
   1428 <i>lhs</i> and <i>rhs</i>, any character can be escaped with a &lt;control&gt;-V, in which case the character shall not be used to
   1429 delimit <i>lhs</i> from <i>rhs</i>, and the escaping &lt;control&gt;-V shall be discarded.</p>
   1430 <p class="tent">If the character <tt>'!'</tt> is appended to the <b>map</b> command name, the mapping shall be effective during
   1431 open or visual text input mode rather than <b>open</b> or <b>visual</b> command mode. This allows <i>lhs</i> to have two different
   1432 <b>map</b> definitions at the same time: one for command mode and one for text input mode.<br></p>
   1433 <p class="tent">For command mode mappings:</p>
   1434 <blockquote>When the <i>lhs</i> is entered as any part of a <a href="../utilities/vi.html"><i>vi</i></a> command in open or visual
   1435 mode (but not as part of the arguments to the command), the action shall be as if the corresponding <i>rhs</i> had been entered.
   1436 <p class="tent">If any character in the command, other than the first, is escaped using a &lt;control&gt;-V character, that
   1437 character shall not be part of a match to an <i>lhs</i>.</p>
   1438 <p class="tent">It is unspecified whether implementations shall support <b>map</b> commands where the <i>lhs</i> is more than a
   1439 single character in length, where the first character of the <i>lhs</i> is printable.</p>
   1440 </blockquote>
   1441 <p class="tent"></p>
   1442 <blockquote>If <i>lhs</i> contains more than one character and the first character is <tt>'#'</tt>, followed by a sequence of
   1443 digits corresponding to a numbered function key, then when this function key is typed it shall be mapped to <i>rhs</i>. Characters
   1444 other than digits following a <tt>'#'</tt> character also represent the function key named by the characters in the <i>lhs</i>
   1445 following the <tt>'#'</tt> and may be mapped to <i>rhs</i>. It is unspecified how function keys are named or what function keys are
   1446 supported.</blockquote>
   1447 <p class="tent">For text input mode mappings:</p>
   1448 <blockquote>When the <i>lhs</i> is entered as any part of text entered in open or visual text input modes, the action shall be as
   1449 if the corresponding <i>rhs</i> had been entered.
   1450 <p class="tent">If any character in the input text is escaped using a &lt;control&gt;-V character, that character shall not be part
   1451 of a match to an <i>lhs</i>.</p>
   1452 <p class="tent">It is unspecified whether the <i>lhs</i> text entered for subsequent <b>map</b> or <b>unmap</b> commands is
   1453 replaced with the <i>rhs</i> text for the purposes of the screen display; regardless of whether or not the display appears as if
   1454 the corresponding <i>rhs</i> text was entered, the effect of the command shall be as if the <i>lhs</i> text was entered.</p>
   1455 </blockquote>
   1456 <p class="tent">If only part of the <i>lhs</i> is entered, it is unspecified how long the editor will wait for additional, possibly
   1457 matching characters before treating the already entered characters as not matching the <i>lhs</i>.</p>
   1458 <p class="tent">The <i>rhs</i> characters shall themselves be subject to remapping, unless otherwise specified by the <b>remap</b>
   1459 edit option, except that if the characters in <i>lhs</i> occur as prefix characters in <i>rhs</i>, those characters shall not be
   1460 remapped.</p>
   1461 <p class="tent">On block-mode terminals, the mapping need not occur immediately (for example, it may occur after the terminal
   1462 transmits a group of characters to the system), but it shall achieve the same results as if it occurred immediately.</p>
   1463 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1464 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1465 <h5><a name="tag_20_40_13_25" id="tag_20_40_13_25"></a>Mark</h5>
   1466 <dl compact>
   1467 <dd></dd>
   1468 <dt><i>Synopsis</i>:</dt>
   1469 <dd>
   1470 <p class="tent"></p>
   1471 <pre>
   1472 <b>[</b><i>1addr</i><b>] </b><tt>ma</tt><b>[</b><tt>rk</tt><b>] </b><i>character
   1473 </i><b>[</b><i>1addr</i><b>] </b><tt>k </tt><i>character</i><tt>
   1474 </tt></pre></dd>
   1475 </dl>
   1476 <p class="tent">Implementations shall support <i>character</i> values of a single lowercase letter of the POSIX locale and the
   1477 backquote and single-quote characters; support of other characters is implementation-defined.</p>
   1478 <p class="tent">If executing the <a href="../utilities/vi.html"><i>vi</i></a> <b>m</b> command, set the specified mark to the
   1479 current line and 1-based numbered character referenced by the current column, if any; otherwise, column position 1.</p>
   1480 <p class="tent">Otherwise, set the specified mark to the specified line and 1-based numbered first non-&lt;blank&gt;
   1481 non-&lt;newline&gt; in the line, if any; otherwise, the last non-&lt;newline&gt; in the line, if any; otherwise, column position
   1482 1.</p>
   1483 <p class="tent">The mark shall remain associated with the line until the mark is reset or the line is deleted. If a deleted line is
   1484 restored by a subsequent <b>undo</b> command, any marks previously associated with the line, which have not been reset, shall be
   1485 restored as well. Any use of a mark not associated with a current line in the edit buffer shall be an error.</p>
   1486 <p class="tent">The marks <b>`</b> and <b>'</b> shall be set as described previously, immediately before the following events occur
   1487 in the editor:</p>
   1488 <ol>
   1489 <li class="tent">The use of <tt>'$'</tt> as an <i>ex</i> address</li>
   1490 <li class="tent">The use of a positive decimal number as an <i>ex</i> address</li>
   1491 <li class="tent">The use of a search command as an <i>ex</i> address</li>
   1492 <li class="tent">The use of a mark reference as an <i>ex</i> address</li>
   1493 <li class="tent">The use of the following open and visual mode commands: &lt;control&gt;-], <b>%</b>, <b>(</b>, <b>)</b>, <b>[</b>,
   1494 <b>]</b>, <b>{</b>, <b>}</b></li>
   1495 <li class="tent">The use of the following open and visual mode commands: <b>'</b>, <b>G</b>, <b>H</b>, <b>L</b>, <b>M</b>, <b>z</b>
   1496 if the current line will change as a result of the command</li>
   1497 <li class="tent">The use of the open and visual mode commands: <b>/</b>, <b>?</b>, <b>N</b>, <b>`</b>, <b>n</b> if the current line
   1498 or column will change as a result of the command</li>
   1499 <li class="tent">The use of the <i>ex</i> mode commands: <b>z</b>, <b>undo</b>, <b>global</b>, <b>v</b></li>
   1500 </ol>
   1501 <p class="tent">For rules 1., 2., 3., and 4., the <b>`</b> and <b>'</b> marks shall not be set if the <i>ex</i> command is parsed
   1502 as specified by rule 6.a. in <a href="#tag_20_40_13_03">Command Line Parsing in ex</a> .</p>
   1503 <p class="tent">For rules 5., 6., and 7., the <b>`</b> and <b>'</b> marks shall not be set if the commands are used as motion
   1504 commands in open and visual mode.</p>
   1505 <p class="tent">For rules 1., 2., 3., 4., 5., 6., 7., and 8., the <b>`</b> and <b>'</b> marks shall not be set if the command
   1506 fails.</p>
   1507 <p class="tent">The <b>`</b> and <b>'</b> marks shall be set as described previously, each time the contents of the edit buffer are
   1508 replaced (including the editing of the initial buffer), if in open or visual mode, or if in <b>ex</b> mode and the edit buffer is
   1509 not empty, before any commands or movements (including commands or movements specified by the <b>-c</b> or <b>-t</b> options or the
   1510 <b>+</b><i>command</i> argument) are executed on the edit buffer. If in open or visual mode, the marks shall be set as if executing
   1511 the <a href="../utilities/vi.html"><i>vi</i></a> <b>m</b> command; otherwise, as if executing the <i>ex</i> <b>mark</b>
   1512 command.</p>
   1513 <p class="tent">When changing from <b>ex</b> mode to open or visual mode, if the <b>`</b> and <b>'</b> marks are not already set,
   1514 the <b>`</b> and <b>'</b> marks shall be set as described previously.</p>
   1515 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1516 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1517 <h5><a name="tag_20_40_13_26" id="tag_20_40_13_26"></a>Move</h5>
   1518 <dl compact>
   1519 <dd></dd>
   1520 <dt><i>Synopsis</i>:</dt>
   1521 <dd>
   1522 <p class="tent"></p>
   1523 <pre>
   1524 <b>[</b><i>2addr</i><b>] </b><tt>m</tt><b>[</b><tt>ove</tt><b>] </b><i>1addr</i><tt> </tt><b>[</b><i>flags</i><b>]</b><tt>
   1525 </tt></pre></dd>
   1526 </dl>
   1527 <p class="tent">Move the specified lines after the specified destination line. A destination of line zero specifies that the lines
   1528 shall be placed at the beginning of the edit buffer. It shall be an error if the destination line is within the range of lines to
   1529 be moved.</p>
   1530 <p class="tent"><i>Current line</i>: Set to the last of the moved lines.</p>
   1531 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1532 <h5><a name="tag_20_40_13_27" id="tag_20_40_13_27"></a>Next</h5>
   1533 <dl compact>
   1534 <dd></dd>
   1535 <dt><i>Synopsis</i>:</dt>
   1536 <dd>
   1537 <p class="tent"></p>
   1538 <pre>
   1539 <tt>n</tt><b>[</b><tt>ext</tt><b>][</b><tt>!</tt><b>][</b><tt>+</tt><i>command</i><b>][</b><i>file </i><tt>...</tt><b>]</b><tt>
   1540 </tt></pre></dd>
   1541 </dl>
   1542 <p class="tent">If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete
   1543 write, it shall be an error, unless the file is successfully written as specified by the <b>autowrite</b> option.<br></p>
   1544 <p class="tent">If one or more files is specified:</p>
   1545 <ol>
   1546 <li class="tent">Set the argument list to the specified filenames.</li>
   1547 <li class="tent">Set the current argument list reference to be the first entry in the argument list.</li>
   1548 <li class="tent">Set the current pathname to the first filename specified.</li>
   1549 </ol>
   1550 <p class="tent">Otherwise:</p>
   1551 <ol>
   1552 <li class="tent">It shall be an error if there are no more filenames in the argument list after the filename currently
   1553 referenced.</li>
   1554 <li class="tent">Set the current pathname and the current argument list reference to the filename after the filename currently
   1555 referenced in the argument list.</li>
   1556 </ol>
   1557 <p class="tent">Replace the contents of the edit buffer with the contents of the file named by the current pathname. If for any
   1558 reason the contents of the file cannot be accessed, the edit buffer shall be empty.</p>
   1559 <p class="tent">This command shall be affected by the <b>autowrite</b> and <b>writeany</b> edit options.</p>
   1560 <p class="tent">The <b>+</b><i>command</i> option shall be &lt;blank&gt;-delimited; &lt;blank&gt; characters can be escaped by
   1561 preceding them with a &lt;backslash&gt; character. The <b>+</b><i>command</i> shall be interpreted as an <i>ex</i> command
   1562 immediately after the contents of the edit buffer have been replaced and the current line and column have been set.</p>
   1563 <p class="tent"><i>Current line</i>: Set as described for the <b>edit</b> command.</p>
   1564 <p class="tent"><i>Current column</i>: Set as described for the <b>edit</b> command.</p>
   1565 <h5><a name="tag_20_40_13_28" id="tag_20_40_13_28"></a>Number</h5>
   1566 <dl compact>
   1567 <dd></dd>
   1568 <dt><i>Synopsis</i>:</dt>
   1569 <dd>
   1570 <p class="tent"></p>
   1571 <pre>
   1572 <b>[</b><i>2addr</i><b>] </b><tt>nu</tt><b>[</b><tt>mber</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]
   1573 [</b><i>2addr</i><b>] </b><tt>#</tt><b>[</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1574 </tt></pre></dd>
   1575 </dl>
   1576 <p class="tent">These commands shall be equivalent to the <i>ex</i> command:</p>
   1577 <pre>
   1578 <b>[</b><i>2addr</i><b>] </b><tt>p</tt><b>[</b><tt>rint</tt><b>][</b><i>count</i><b>] </b><tt>#</tt><b>[</b><i>flags</i><b>]</b><tt>
   1579 </tt></pre>
   1580 <p class="tent">See <a href="#tag_20_40_13_31">Print</a> .</p>
   1581 <h5><a name="tag_20_40_13_29" id="tag_20_40_13_29"></a>Open</h5>
   1582 <dl compact>
   1583 <dd></dd>
   1584 <dt><i>Synopsis</i>:</dt>
   1585 <dd>
   1586 <p class="tent"></p>
   1587 <pre>
   1588 <b>[</b><i>1addr</i><b>] </b><tt>o</tt><b>[</b><tt>pen</tt><b>]</b><tt> /</tt><i>pattern</i><tt>/ </tt><b>[</b><i>flags</i><b>]</b><tt>
   1589 </tt></pre></dd>
   1590 </dl>
   1591 <p class="tent">This command need not be supported on block-mode terminals or terminals with insufficient capabilities. If standard
   1592 input, standard output, or standard error are not terminal devices, the results are unspecified.</p>
   1593 <p class="tent">Enter open mode.</p>
   1594 <p class="tent">The trailing delimiter can be omitted from <i>pattern</i> at the end of the command line. If <i>pattern</i> is
   1595 empty (for example, <tt>"//"</tt>) or not specified, the last regular expression used in the editor shall be used as the pattern.
   1596 The pattern can be delimited by &lt;slash&gt; characters (shown in the Synopsis), as well as any alphanumeric, or non-&lt;blank&gt;
   1597 other than &lt;backslash&gt;, &lt;vertical-line&gt;, &lt;newline&gt;, or double-quote.</p>
   1598 <p class="tent"><i>Current line</i>: Set to the specified line.</p>
   1599 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1600 <h5><a name="tag_20_40_13_30" id="tag_20_40_13_30"></a>Preserve</h5>
   1601 <dl compact>
   1602 <dd></dd>
   1603 <dt><i>Synopsis</i>:</dt>
   1604 <dd>
   1605 <p class="tent"></p>
   1606 <pre>
   1607 <tt>pre</tt><b>[</b><tt>serve</tt><b>]</b><tt>
   1608 </tt></pre></dd>
   1609 </dl>
   1610 <p class="tent">Save the edit buffer in a form that can later be recovered by using the <b>-r</b> option or by using the <i>ex</i>
   1611 <b>recover</b> command. After the file has been preserved, a mail message shall be sent to the user. This message shall be readable
   1612 by invoking the <a href="../utilities/mailx.html"><i>mailx</i></a> utility. The message shall contain the name of the file, the
   1613 time of preservation, and an <i>ex</i> command that could be used to recover the file. Additional information may be included in
   1614 the mail message.</p>
   1615 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1616 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1617 <h5><a name="tag_20_40_13_31" id="tag_20_40_13_31"></a>Print</h5>
   1618 <dl compact>
   1619 <dd></dd>
   1620 <dt><i>Synopsis</i>:</dt>
   1621 <dd>
   1622 <p class="tent"></p>
   1623 <pre>
   1624 <b>[</b><i>2addr</i><b>] </b><tt>p</tt><b>[</b><tt>rint</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1625 </tt></pre></dd>
   1626 </dl>
   1627 <p class="tent">Write the addressed lines. The behavior is unspecified if the number of columns on the display is less than the
   1628 number of columns required to write any single character in the lines being written.</p>
   1629 <p class="tent">Non-printable characters, except for the &lt;tab&gt;, shall be written as implementation-defined multi-character
   1630 sequences.</p>
   1631 <p class="tent">If the <b>#</b> flag is specified or the <b>number</b> edit option is set, each line shall be preceded by its line
   1632 number in the following format:</p>
   1633 <pre>
   1634 <tt>"%6dΔΔ", &lt;</tt><i>line number</i><tt>&gt;
   1635 </tt></pre>
   1636 <p class="tent">If the <b>l</b> flag is specified or the <b>list</b> edit option is set:</p>
   1637 <ol>
   1638 <li class="tent">The characters listed in XBD <a href="../basedefs/V1_chap05.html#tagtcjh_2"><i>Escape Sequences and Associated
   1639 Actions</i></a> shall be written as the corresponding escape sequence.</li>
   1640 <li class="tent">Non-printable characters not in XBD <a href="../basedefs/V1_chap05.html#tagtcjh_2"><i>Escape Sequences and
   1641 Associated Actions</i></a> shall be written as one three-digit octal number (with a preceding &lt;backslash&gt;) for each byte in
   1642 the character (most significant byte first).</li>
   1643 <li class="tent">The end of each line shall be marked with a <tt>'$'</tt>, and literal <tt>'$'</tt> characters within the line
   1644 shall be written with a preceding &lt;backslash&gt;.</li>
   1645 </ol>
   1646 <p class="tent">Long lines shall be folded; the length at which folding occurs is unspecified, but should be appropriate for the
   1647 output terminal, considering the number of columns of the terminal.</p>
   1648 <p class="tent">If a line is folded, and the <b>l</b> flag is not specified and the <b>list</b> edit option is not set, it is
   1649 unspecified whether a multi-column character at the folding position is separated; it shall not be discarded.</p>
   1650 <p class="tent"><i>Current line</i>: Set to the last written line.</p>
   1651 <p class="tent"><i>Current column</i>: Unchanged if the current line is unchanged; otherwise, set to non-&lt;blank&gt;.</p>
   1652 <h5><a name="tag_20_40_13_32" id="tag_20_40_13_32"></a>Put</h5>
   1653 <dl compact>
   1654 <dd></dd>
   1655 <dt><i>Synopsis</i>:</dt>
   1656 <dd>
   1657 <p class="tent"></p>
   1658 <pre>
   1659 <b>[</b><i>1addr</i><b>] </b><tt>pu</tt><b>[</b><tt>t</tt><b>][ </b><i>buffer</i><b>]</b><tt>
   1660 </tt></pre></dd>
   1661 </dl>
   1662 <p class="tent">Append text from the specified buffer (by default, the unnamed buffer) to the specified line; line zero specifies
   1663 that the text shall be placed at the beginning of the edit buffer. Each portion of a line in the buffer shall become a new line in
   1664 the edit buffer, regardless of the mode of the buffer.</p>
   1665 <p class="tent"><i>Current line</i>: Set to the last line entered into the edit buffer.</p>
   1666 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1667 <h5><a name="tag_20_40_13_33" id="tag_20_40_13_33"></a>Quit</h5>
   1668 <dl compact>
   1669 <dd></dd>
   1670 <dt><i>Synopsis</i>:</dt>
   1671 <dd>
   1672 <p class="tent"></p>
   1673 <pre>
   1674 <tt>q</tt><b>[</b><tt>uit</tt><b>][</b><tt>!</tt><b>]</b><tt>
   1675 </tt></pre></dd>
   1676 </dl>
   1677 <p class="tent">If no <tt>'!'</tt> is appended to the command name:</p>
   1678 <ol>
   1679 <li class="tent">If the edit buffer has been modified since the last complete write, it shall be an error.</li>
   1680 <li class="tent">If there are filenames in the argument list after the filename currently referenced, and the last command was not
   1681 a <b>quit</b>, <b>wq</b>, <b>xit</b>, or <b>ZZ</b> (see <a href="../utilities/vi.html#tag_20_146_13_87"><i>Exit</i></a> ) command,
   1682 it shall be an error.</li>
   1683 </ol>
   1684 <p class="tent">Otherwise, terminate the editing session.</p>
   1685 <h5><a name="tag_20_40_13_34" id="tag_20_40_13_34"></a>Read</h5>
   1686 <dl compact>
   1687 <dd></dd>
   1688 <dt><i>Synopsis</i>:</dt>
   1689 <dd>
   1690 <p class="tent"></p>
   1691 <pre>
   1692 <b>[</b><i>1addr</i><b>] </b><tt>r</tt><b>[</b><tt>ead</tt><b>][</b><tt>!</tt><b>][</b><i>file</i><b>]</b><tt>
   1693 </tt></pre></dd>
   1694 </dl>
   1695 <p class="tent">If <tt>'!'</tt> is not the first non-&lt;blank&gt; to follow the command name, a copy of the specified file shall
   1696 be appended into the edit buffer after the specified line; line zero specifies that the copy shall be placed at the beginning of
   1697 the edit buffer. The number of lines and bytes read shall be written. If no <i>file</i> is named, the current pathname shall be the
   1698 default. If there is no current pathname, then <i>file</i> shall become the current pathname. If there is no current pathname or
   1699 <i>file</i> operand, it shall be an error. Specifying a <i>file</i> that is not of type regular shall have unspecified results.</p>
   1700 <p class="tent">Otherwise, if <i>file</i> is preceded by <tt>'!'</tt>, the rest of the line after the <tt>'!'</tt> shall have
   1701 <tt>'%'</tt>, <tt>'#'</tt>, and <tt>'!'</tt> characters expanded as described in <a href="#tag_20_40_13_03">Command Line Parsing in
   1702 ex</a> .</p>
   1703 <p class="tent">The <i>ex</i> utility shall then pass two arguments to the program named by the shell edit option; the first shall
   1704 be <b>-c</b> and the second shall be the expanded arguments to the <b>read</b> command as a single argument. The standard input of
   1705 the program shall be set to the standard input of the <i>ex</i> program when it was invoked. The standard error and standard output
   1706 of the program shall be appended into the edit buffer after the specified line.</p>
   1707 <p class="tent">Each line in the copied file or program output (as delimited by &lt;newline&gt; characters or the end of the file
   1708 or output if it is not immediately preceded by a &lt;newline&gt;), shall be a separate line in the edit buffer. Any occurrences of
   1709 &lt;carriage-return&gt; and &lt;newline&gt; pairs in the output shall be treated as single &lt;newline&gt; characters.</p>
   1710 <p class="tent">The special meaning of the <tt>'!'</tt> following the <b>read</b> command can be overridden by escaping it with a
   1711 &lt;backslash&gt; character.</p>
   1712 <p class="tent"><i>Current line</i>: If no lines are added to the edit buffer, unchanged. Otherwise, if in open or visual mode, set
   1713 to the first line entered into the edit buffer. Otherwise, set to the last line entered into the edit buffer.</p>
   1714 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1715 <h5><a name="tag_20_40_13_35" id="tag_20_40_13_35"></a>Recover</h5>
   1716 <dl compact>
   1717 <dd></dd>
   1718 <dt><i>Synopsis</i>:</dt>
   1719 <dd>
   1720 <p class="tent"></p>
   1721 <pre>
   1722 <tt>rec</tt><b>[</b><tt>over</tt><b>][</b><tt>!</tt><b>] </b><i>file</i><tt>
   1723 </tt></pre></dd>
   1724 </dl>
   1725 <p class="tent">If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete
   1726 write, it shall be an error.</p>
   1727 <p class="tent">If no <i>file</i> operand is specified, then the current pathname shall be used. If there is no current pathname or
   1728 <i>file</i> operand, it shall be an error.</p>
   1729 <p class="tent">If no recovery information has previously been saved about <i>file</i>, the <b>recover</b> command shall behave
   1730 identically to the <b>edit</b> command, and an informational message to this effect shall be written.</p>
   1731 <p class="tent">Otherwise, set the current pathname to <i>file</i>, and replace the current contents of the edit buffer with the
   1732 recovered contents of <i>file</i>. If there are multiple instances of the file to be recovered, the one most recently saved shall
   1733 be recovered, and an informational message that there are previous versions of the file that can be recovered shall be written. The
   1734 editor shall behave as if the contents of the edit buffer have already been modified.</p>
   1735 <p class="tent"><i>Current file</i>: Set as described for the <b>edit</b> command.</p>
   1736 <p class="tent"><i>Current column</i>: Set as described for the <b>edit</b> command.</p>
   1737 <h5><a name="tag_20_40_13_36" id="tag_20_40_13_36"></a>Rewind</h5>
   1738 <dl compact>
   1739 <dd></dd>
   1740 <dt><i>Synopsis</i>:</dt>
   1741 <dd>
   1742 <p class="tent"></p>
   1743 <pre>
   1744 <tt>rew</tt><b>[</b><tt>ind</tt><b>][</b><tt>!</tt><b>]</b><tt>
   1745 </tt></pre></dd>
   1746 </dl>
   1747 <p class="tent">If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete
   1748 write, it shall be an error, unless the file is successfully written as specified by the <b>autowrite</b> option.</p>
   1749 <p class="tent">If the argument list is empty, it shall be an error.</p>
   1750 <p class="tent">The current argument list reference and the current pathname shall be set to the first filename in the argument
   1751 list.</p>
   1752 <p class="tent">Replace the contents of the edit buffer with the contents of the file named by the current pathname. If for any
   1753 reason the contents of the file cannot be accessed, the edit buffer shall be empty.</p>
   1754 <p class="tent">This command shall be affected by the <b>autowrite</b> and <b>writeany</b> edit options.</p>
   1755 <p class="tent"><i>Current line</i>: Set as described for the <b>edit</b> command.</p>
   1756 <p class="tent"><i>Current column</i>: Set as described for the <b>edit</b> command.</p>
   1757 <h5><a name="tag_20_40_13_37" id="tag_20_40_13_37"></a>Set</h5>
   1758 <dl compact>
   1759 <dd></dd>
   1760 <dt><i>Synopsis</i>:</dt>
   1761 <dd>
   1762 <p class="tent"></p>
   1763 <pre>
   1764 <tt>se</tt><b>[</b><tt>t</tt><b>][ </b><i>option</i><b>[</b><tt>=</tt><b>[</b><i>value</i><b>]]</b><tt> ...</tt><b>][ </b><tt>no</tt><i>option</i><tt> ...</tt><b>][ </b><i>option</i><tt>? ...</tt><b>][ </b><tt>all</tt><b>]</b><tt>
   1765 </tt></pre></dd>
   1766 </dl>
   1767 <p class="tent">When no arguments are specified, write the value of the <b>term</b> edit option and those options whose values have
   1768 been changed from the default settings; when the argument <i>all</i> is specified, write all of the option values.</p>
   1769 <p class="tent">Giving an option name followed by the character <tt>'?'</tt> shall cause the current value of that option to be
   1770 written. The <tt>'?'</tt> can be separated from the option name by zero or more &lt;blank&gt; characters. The <tt>'?'</tt> shall be
   1771 necessary only for Boolean valued options. Boolean options can be given values by the form <b>set</b> <i>option</i> to turn them on
   1772 or <b>set</b> <b>no</b><i>option</i> to turn them off; string and numeric options can be assigned by the form <b>set</b>
   1773 <i>option</i>=<i>value</i>. Any &lt;blank&gt; characters in strings can be included as is by preceding each &lt;blank&gt; with an
   1774 escaping &lt;backslash&gt;. More than one option can be set or listed by a single set command by specifying multiple arguments,
   1775 each separated from the next by one or more &lt;blank&gt; characters. Arguments can appear in any order and shall be processed in
   1776 the specified order.</p>
   1777 <p class="tent">See <a href="#tag_20_40_13_60">Edit Options in ex</a> for details about specific options.</p>
   1778 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1779 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1780 <h5><a name="tag_20_40_13_38" id="tag_20_40_13_38"></a>Shell</h5>
   1781 <dl compact>
   1782 <dd></dd>
   1783 <dt><i>Synopsis</i>:</dt>
   1784 <dd>
   1785 <p class="tent"></p>
   1786 <pre>
   1787 <tt>sh</tt><b>[</b><tt>ell</tt><b>]</b><tt>
   1788 </tt></pre></dd>
   1789 </dl>
   1790 <p class="tent">Invoke the program named in the <b>shell</b> edit option with the single argument <b>-i</b> (interactive mode).
   1791 Editing shall be resumed when the program exits.</p>
   1792 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1793 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1794 <h5><a name="tag_20_40_13_39" id="tag_20_40_13_39"></a>Source</h5>
   1795 <dl compact>
   1796 <dd></dd>
   1797 <dt><i>Synopsis</i>:</dt>
   1798 <dd>
   1799 <p class="tent"></p>
   1800 <pre>
   1801 <tt>so</tt><b>[</b><tt>urce</tt><b>] </b><i>file</i><tt>
   1802 </tt></pre></dd>
   1803 </dl>
   1804 <p class="tent">Read and execute <i>ex</i> commands from <i>file</i>. Lines in the file that are blank lines shall be ignored.</p>
   1805 <p class="tent"><i>Current line</i>: As specified for the individual <i>ex</i> commands.</p>
   1806 <p class="tent"><i>Current column</i>: As specified for the individual <i>ex</i> commands.</p>
   1807 <h5><a name="tag_20_40_13_40" id="tag_20_40_13_40"></a>Substitute</h5>
   1808 <dl compact>
   1809 <dd></dd>
   1810 <dt><i>Synopsis</i>:</dt>
   1811 <dd>
   1812 <p class="tent"></p>
   1813 <pre>
   1814 <b>[</b><i>2addr</i><b>] </b><tt>s</tt><b>[</b><tt>ubstitute</tt><b>][</b><tt>/</tt><i>pattern</i><tt>/</tt><i>repl</i><tt>/</tt><b>][</b><i>options</i><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1815 <br>
   1816 </tt><b>[</b><i>2addr</i><b>] </b><tt>&</tt><b>[</b><i>options</i><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1817 <br>
   1818 </tt><b>[</b><i>2addr</i><b>] </b><tt>~</tt><b>[</b><i>options</i><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1819 </tt></pre></dd>
   1820 </dl>
   1821 <p class="tent">Replace the first instance of the pattern <i>pattern</i> by the string <i>repl</i> on each specified line. (See
   1822 <a href="#tag_20_40_13_58">Regular Expressions in ex</a> and <a href="#tag_20_40_13_59">Replacement Strings in ex</a> .) Any
   1823 non-alphabetic, non-&lt;blank&gt; delimiter other than &lt;backslash&gt;, <tt>'|'</tt>, &lt;newline&gt;, or double-quote can be
   1824 used instead of <tt>'/'</tt>. Within the pattern, in certain circumstances the delimiter can be used as a literal character; see
   1825 <a href="#tag_20_40_13_58">Regular Expressions in ex</a> . Within the replacement, the delimiter shall not terminate the
   1826 replacement if it is the second character of an escape sequence (see XBD <a href="../basedefs/V1_chap09.html#tag_09_01"><i>9.1
   1827 Regular Expression Definitions</i></a> ) and the escaped delimiter shall be treated as that literal character in the replacement
   1828 (losing any special meaning it would have had if it was not used as the delimiter and was not escaped). It shall be an error if the
   1829 substitution fails on every addressed line.</p>
   1830 <p class="tent">The trailing delimiter can be omitted from <i>pattern</i> or from <i>repl</i> at the end of the command line. If
   1831 both <i>pattern</i> and <i>repl</i> are not specified or are empty (for example, <tt>"//"</tt>), the last <b>s</b> command shall be
   1832 repeated. If only <i>pattern</i> is not specified or is empty, the last regular expression used in the editor shall be used as the
   1833 pattern. If only <i>repl</i> is not specified or is empty, the pattern shall be replaced by nothing. If the entire replacement
   1834 pattern is <tt>'%'</tt>, the last replacement pattern to an <b>s</b> command shall be used.</p>
   1835 <p class="tent">Entering a &lt;carriage-return&gt; in <i>repl</i> (which requires an escaping &lt;backslash&gt; in <i>ex</i> mode
   1836 and an escaping &lt;control&gt;-V in open or <a href="../utilities/vi.html"><i>vi</i></a> mode) shall split the line at that point,
   1837 creating a new line in the edit buffer. The &lt;carriage-return&gt; shall be discarded.</p>
   1838 <p class="tent">If <i>options</i> includes the letter <tt>'g'</tt> (<b>global</b>), all non-overlapping instances of the pattern in
   1839 the line shall be replaced.</p>
   1840 <p class="tent">If <i>options</i> includes the letter <tt>'c'</tt> (<b>confirm</b>), then before each substitution the line shall
   1841 be written; the written line shall reflect all previous substitutions. On the following line, &lt;space&gt; characters shall be
   1842 written beneath the characters from the line that are before the <i>pattern</i> to be replaced, and <tt>'^'</tt> characters written
   1843 beneath the characters included in the <i>pattern</i> to be replaced. The <i>ex</i> utility shall then wait for a response from the
   1844 user. An affirmative response shall cause the substitution to be done, while any other input shall not make the substitution. An
   1845 affirmative response shall consist of a line with the affirmative response (as defined by the current locale) at the beginning of
   1846 the line. This line shall be subject to editing in the same way as the <i>ex</i> command line.</p>
   1847 <p class="tent">If interrupted (see the ASYNCHRONOUS EVENTS section), any modifications confirmed by the user shall be preserved in
   1848 the edit buffer after the interrupt.</p>
   1849 <p class="tent">If the remembered search direction is not set, the <b>s</b> command shall set it to forward.</p>
   1850 <p class="tent">In the second Synopsis, the <b>&</b> command shall repeat the previous substitution, as if the <b>&</b> command
   1851 were replaced by:</p>
   1852 <pre>
   1853 <tt>s/</tt><i>pattern</i><tt>/</tt><i>repl</i><tt>/
   1854 </tt></pre>
   1855 <p class="tent">where <i>pattern</i> and <i>repl</i> are as specified in the previous <b>s</b>, <b>&</b>, or <b>~</b> command.</p>
   1856 <p class="tent">In the third Synopsis, the <b>~</b> command shall repeat the previous substitution, as if the <tt>'~'</tt> were
   1857 replaced by:</p>
   1858 <pre>
   1859 <tt>s/</tt><i>pattern</i><tt>/</tt><i>repl</i><tt>/
   1860 </tt></pre>
   1861 <p class="tent">where <i>pattern</i> shall be the last regular expression specified to the editor, and <i>repl</i> shall be from
   1862 the previous substitution (including <b>&</b> and <b>~</b>) command.</p>
   1863 <p class="tent">These commands shall be affected by the <i>LC_MESSAGES</i> environment variable.</p>
   1864 <p class="tent"><i>Current line</i>: Set to the last line in which a substitution occurred, or, unchanged if no substitution
   1865 occurred.</p>
   1866 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1867 <h5><a name="tag_20_40_13_41" id="tag_20_40_13_41"></a>Suspend</h5>
   1868 <dl compact>
   1869 <dd></dd>
   1870 <dt><i>Synopsis</i>:</dt>
   1871 <dd>
   1872 <p class="tent"></p>
   1873 <pre>
   1874 <tt>su</tt><b>[</b><tt>spend</tt><b>][</b><tt>!</tt><b>]</b><tt>
   1875 st</tt><b>[</b><tt>op</tt><b>][</b><tt>!</tt><b>]</b><tt>
   1876 </tt></pre></dd>
   1877 </dl>
   1878 <p class="tent">Allow control to return to the invoking process; <i>ex</i> shall suspend itself as if it had received the SIGTSTP
   1879 signal. The suspension shall occur only if job control is enabled in the invoking shell (see the description of <a href=
   1880 "../utilities/V3_chap02.html#set"><i>set</i></a> <b>-m</b>).</p>
   1881 <p class="tent">These commands shall be affected by the <b>autowrite</b> and <b>writeany</b> edit options.</p>
   1882 <p class="tent">The current <b>susp</b> character (see <a href="../utilities/stty.html#"><i>stty</i></a> ) shall be equivalent to
   1883 the <b>suspend</b> command.</p>
   1884 <h5><a name="tag_20_40_13_42" id="tag_20_40_13_42"></a>Tag</h5>
   1885 <dl compact>
   1886 <dd></dd>
   1887 <dt><i>Synopsis</i>:</dt>
   1888 <dd>
   1889 <p class="tent"></p>
   1890 <pre>
   1891 <tt>ta</tt><b>[</b><tt>g</tt><b>][</b><tt>!</tt><b>] </b><i>tagstring</i><tt>
   1892 </tt></pre></dd>
   1893 </dl>
   1894 <p class="tent">The results are unspecified if the format of a tags file is not as specified by the <a href=
   1895 "../utilities/ctags.html"><i>ctags</i></a> utility (see <a href="../utilities/ctags.html#"><i>ctags</i></a> ) description.</p>
   1896 <p class="tent">The <b>tag</b> command shall search for <i>tagstring</i> in the tag files referred to by the <b>tag</b> edit
   1897 option, in the order they are specified, until a reference to <i>tagstring</i> is found. Files shall be searched from beginning to
   1898 end. If no reference is found, it shall be an error and an error message to this effect shall be written. If the reference is not
   1899 found, or if an error occurs while processing a file referred to in the <b>tag</b> edit option, it shall be an error, and an error
   1900 message shall be written at the first occurrence of such an error.</p>
   1901 <p class="tent">Otherwise, if the tags file contained a pattern, the pattern shall be treated as a regular expression used in the
   1902 editor; for example, for the purposes of the <b>s</b> command.</p>
   1903 <p class="tent">If the <i>tagstring</i> is in a file with a different name than the current pathname, set the current pathname to
   1904 the name of that file, and replace the contents of the edit buffer with the contents of that file. In this case, if no <tt>'!'</tt>
   1905 is appended to the command name, and the edit buffer has been modified since the last complete write, it shall be an error, unless
   1906 the file is successfully written as specified by the <b>autowrite</b> option.</p>
   1907 <p class="tent">This command shall be affected by the <b>autowrite</b>, <b>tag</b>, <b>taglength</b>, and <b>writeany</b> edit
   1908 options.</p>
   1909 <p class="tent"><i>Current line</i>: If the tags file contained a line number, set to that line number. If the line number is
   1910 larger than the last line in the edit buffer, an error message shall be written and the current line shall be set as specified for
   1911 the <b>edit</b> command.</p>
   1912 <p class="tent">If the tags file contained a pattern, set to the first occurrence of the pattern in the file. If no matching
   1913 pattern is found, an error message shall be written and the current line shall be set as specified for the <b>edit</b> command.</p>
   1914 <p class="tent"><i>Current column</i>: If the tags file contained a line-number reference and that line-number was not larger than
   1915 the last line in the edit buffer, or if the tags file contained a pattern and that pattern was found, set to non-&lt;blank&gt;.
   1916 Otherwise, set as specified for the <b>edit</b> command.</p>
   1917 <h5><a name="tag_20_40_13_43" id="tag_20_40_13_43"></a>Unabbreviate</h5>
   1918 <dl compact>
   1919 <dd></dd>
   1920 <dt><i>Synopsis</i>:</dt>
   1921 <dd>
   1922 <p class="tent"></p>
   1923 <pre>
   1924 <tt>una</tt><b>[</b><tt>bbrev</tt><b>] </b><i>lhs</i><tt>
   1925 </tt></pre></dd>
   1926 </dl>
   1927 <p class="tent">If <i>lhs</i> is not an entry in the current list of abbreviations (see <a href="#tag_20_40_13_11">Abbreviate</a>
   1928 ), it shall be an error. Otherwise, delete <i>lhs</i> from the list of abbreviations.</p>
   1929 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1930 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1931 <h5><a name="tag_20_40_13_44" id="tag_20_40_13_44"></a>Undo</h5>
   1932 <dl compact>
   1933 <dd></dd>
   1934 <dt><i>Synopsis</i>:</dt>
   1935 <dd>
   1936 <p class="tent"></p>
   1937 <pre>
   1938 <tt>u</tt><b>[</b><tt>ndo</tt><b>]</b><tt>
   1939 </tt></pre></dd>
   1940 </dl>
   1941 <p class="tent">Reverse the changes made by the last command that modified the contents of the edit buffer, including <b>undo</b>.
   1942 For this purpose, the <b>global</b>, <b>v</b>, <b>open</b>, and <b>visual</b> commands, and commands resulting from buffer
   1943 executions and mapped character expansions, are considered single commands.</p>
   1944 <p class="tent">If no action that can be undone preceded the <b>undo</b> command, it shall be an error.</p>
   1945 <p class="tent">If the <b>undo</b> command restores lines that were marked, the mark shall also be restored unless it was reset
   1946 subsequent to the deletion of the lines.</p>
   1947 <p class="tent"><i>Current line</i>:</p>
   1948 <ol>
   1949 <li class="tent">If lines are added or changed in the file, set to the first line added or changed.</li>
   1950 <li class="tent">Set to the line before the first line deleted, if it exists.</li>
   1951 <li class="tent">Set to 1 if the edit buffer is not empty.</li>
   1952 <li class="tent">Set to zero.</li>
   1953 </ol>
   1954 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   1955 <h5><a name="tag_20_40_13_45" id="tag_20_40_13_45"></a>Unmap</h5>
   1956 <dl compact>
   1957 <dd></dd>
   1958 <dt><i>Synopsis</i>:</dt>
   1959 <dd>
   1960 <p class="tent"></p>
   1961 <pre>
   1962 <tt>unm</tt><b>[</b><tt>ap</tt><b>][</b><tt>!</tt><b>] </b><i>lhs</i><tt>
   1963 </tt></pre></dd>
   1964 </dl>
   1965 <p class="tent">If <tt>'!'</tt> is appended to the command name, and if <i>lhs</i> is not an entry in the list of text input mode
   1966 map definitions, it shall be an error. Otherwise, delete <i>lhs</i> from the list of text input mode map definitions.</p>
   1967 <p class="tent">If no <tt>'!'</tt> is appended to the command name, and if <i>lhs</i> is not an entry in the list of command mode
   1968 map definitions, it shall be an error. Otherwise, delete <i>lhs</i> from the list of command mode map definitions.</p>
   1969 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1970 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1971 <h5><a name="tag_20_40_13_46" id="tag_20_40_13_46"></a>Version</h5>
   1972 <dl compact>
   1973 <dd></dd>
   1974 <dt><i>Synopsis</i>:</dt>
   1975 <dd>
   1976 <p class="tent"></p>
   1977 <pre>
   1978 <tt>ve</tt><b>[</b><tt>rsion</tt><b>]</b><tt>
   1979 </tt></pre></dd>
   1980 </dl>
   1981 <p class="tent">Write a message containing version information for the editor. The format of the message is unspecified.</p>
   1982 <p class="tent"><i>Current line</i>: Unchanged.</p>
   1983 <p class="tent"><i>Current column</i>: Unchanged.</p>
   1984 <h5><a name="tag_20_40_13_47" id="tag_20_40_13_47"></a>Visual</h5>
   1985 <dl compact>
   1986 <dd></dd>
   1987 <dt><i>Synopsis</i>:</dt>
   1988 <dd>
   1989 <p class="tent"></p>
   1990 <pre>
   1991 <b>[</b><i>1addr</i><b>] </b><tt>vi</tt><b>[</b><tt>sual</tt><b>][</b><i>type</i><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   1992 </tt></pre></dd>
   1993 </dl>
   1994 <p class="tent">If <i>ex</i> is currently in open or visual mode, the Synopsis and behavior of the visual command shall be the same
   1995 as the <b>edit</b> command, as specified by <a href="#tag_20_40_13_18">Edit</a> .</p>
   1996 <p class="tent">Otherwise, this command need not be supported on block-mode terminals or terminals with insufficient capabilities.
   1997 If standard input, standard output, or standard error are not terminal devices, the results are unspecified.</p>
   1998 <p class="tent">If <i>count</i> is specified, the value of the <b>window</b> edit option shall be set to <i>count</i> (as described
   1999 in <a href="#tag_20_40_13_93">window</a> ). If the <tt>'^'</tt> type character was also specified, the <b>window</b> edit option
   2000 shall be set before being used by the type character.</p>
   2001 <p class="tent">Enter visual mode. If <i>type</i> is not specified, it shall be as if a <i>type</i> of <tt>'+'</tt> was specified.
   2002 The <i>type</i> shall cause the following effects:</p>
   2003 <dl compact>
   2004 <dd></dd>
   2005 <dt><tt>+</tt></dt>
   2006 <dd>Place the beginning of the specified line at the top of the display.</dd>
   2007 <dt><tt>-</tt></dt>
   2008 <dd>Place the end of the specified line at the bottom of the display.</dd>
   2009 <dt><tt>.</tt></dt>
   2010 <dd>Place the beginning of the specified line in the middle of the display.</dd>
   2011 <dt><tt>^</tt></dt>
   2012 <dd>If the specified line is less than or equal to the value of the <b>window</b> edit option, set the line to 1; otherwise,
   2013 decrement the line by the value of the <b>window</b> edit option minus 1. Place the beginning of this line as close to the bottom
   2014 of the displayed lines as possible, while still displaying the value of the <b>window</b> edit option number of lines.</dd>
   2015 </dl>
   2016 <p class="tent"><i>Current line</i>: Set to the specified line.</p>
   2017 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   2018 <h5><a name="tag_20_40_13_48" id="tag_20_40_13_48"></a>Write</h5>
   2019 <dl compact>
   2020 <dd></dd>
   2021 <dt><i>Synopsis</i>:</dt>
   2022 <dd>
   2023 <p class="tent"></p>
   2024 <pre>
   2025 <b>[</b><i>2addr</i><b>] </b><tt>w</tt><b>[</b><tt>rite</tt><b>][</b><tt>!</tt><b>][</b><tt>&gt;&gt;</tt><b>][</b><i>file</i><b>]
   2026 [</b><i>2addr</i><b>] </b><tt>w</tt><b>[</b><tt>rite</tt><b>][</b><tt>!</tt><b>][</b><i>file</i><b>]
   2027 [</b><i>2addr</i><b>] </b><tt>wq</tt><b>[</b><tt>!</tt><b>][</b><tt>&gt;&gt;</tt><b>][</b><i>file</i><b>]</b><tt>
   2028 </tt></pre></dd>
   2029 </dl>
   2030 <p class="tent">If no lines are specified, the lines shall default to the entire file.</p>
   2031 <p class="tent">The command <b>wq</b> shall be equivalent to a <b>write</b> command followed by a <b>quit</b> command; <b>wq!</b>
   2032 shall be equivalent to <b>write!</b> followed by <b>quit</b>. In both cases, if the <b>write</b> command fails, the <b>quit</b>
   2033 shall not be attempted.</p>
   2034 <p class="tent">If the command name is not followed by one or more &lt;blank&gt; characters, or <i>file</i> is not preceded by a
   2035 <tt>'!'</tt> character, the <b>write</b> shall be to a file.</p>
   2036 <ol>
   2037 <li class="tent">If the <b>&gt;&gt;</b> argument is specified, and the file already exists, the lines shall be appended to the file
   2038 instead of replacing its contents. If the <b>&gt;&gt;</b> argument is specified, and the file does not already exist, it is
   2039 unspecified whether the write shall proceed as if the <b>&gt;&gt;</b> argument had not been specified or if the write shall
   2040 fail.</li>
   2041 <li class="tent">If the <b>readonly</b> edit option is set (see <a href="#tag_20_40_13_76">readonly</a> ), the <b>write</b> shall
   2042 fail.</li>
   2043 <li class="tent">If <i>file</i> is specified, and is not the current pathname, and the file exists, the <b>write</b> shall
   2044 fail.</li>
   2045 <li class="tent">If <i>file</i> is not specified, the current pathname shall be used. If there is no current pathname, the
   2046 <b>write</b> command shall fail.</li>
   2047 <li class="tent">If the current pathname is used, and the current pathname has been changed by the <b>file</b> or <b>read</b>
   2048 commands, and the file exists, the <b>write</b> shall fail. If the <b>write</b> is successful, subsequent <b>write</b>s shall not
   2049 fail for this reason (unless the current pathname is changed again).</li>
   2050 <li class="tent">If the whole edit buffer is not being written, and the file to be written exists, the <b>write</b> shall
   2051 fail.</li>
   2052 </ol>
   2053 <p class="tent">For rules 1., 2., 3., and 5., the <b>write</b> can be forced by appending the character <tt>'!'</tt> to the command
   2054 name.</p>
   2055 <p class="tent">For rules 2., 3., and 5., the <b>write</b> can be forced by setting the <b>writeany</b> edit option.</p>
   2056 <p class="tent">Additional, implementation-defined tests may cause the <b>write</b> to fail.</p>
   2057 <p class="tent">If the edit buffer is empty, a file without any contents shall be written.</p>
   2058 <p class="tent">An informational message shall be written noting the number of lines and bytes written.</p>
   2059 <p class="tent">Otherwise, if the command is followed by one or more &lt;blank&gt; characters, and the file is preceded by
   2060 <tt>'!'</tt>, the rest of the line after the <tt>'!'</tt> shall have <tt>'%'</tt>, <tt>'#'</tt>, and <tt>'!'</tt> characters
   2061 expanded as described in <a href="#tag_20_40_13_03">Command Line Parsing in ex</a> .</p>
   2062 <p class="tent">The <i>ex</i> utility shall then pass two arguments to the program named by the <b>shell</b> edit option; the first
   2063 shall be <b>-c</b> and the second shall be the expanded arguments to the <b>write</b> command as a single argument. The specified
   2064 lines shall be written to the standard input of the command. The standard error and standard output of the program, if any, shall
   2065 be written as described for the <b>print</b> command. If the last character in that output is not a &lt;newline&gt;, a
   2066 &lt;newline&gt; shall be written at the end of the output.</p>
   2067 <p class="tent">The special meaning of the <tt>'!'</tt> following the <b>write</b> command can be overridden by escaping it with a
   2068 &lt;backslash&gt; character.</p>
   2069 <p class="tent"><i>Current line</i>: Unchanged.</p>
   2070 <p class="tent"><i>Current column</i>: Unchanged.</p>
   2071 <h5><a name="tag_20_40_13_49" id="tag_20_40_13_49"></a>Write and Exit</h5>
   2072 <dl compact>
   2073 <dd></dd>
   2074 <dt><i>Synopsis</i>:</dt>
   2075 <dd>
   2076 <p class="tent"></p>
   2077 <pre>
   2078 <b>[</b><i>2addr</i><b>] </b><tt>x</tt><b>[</b><tt>it</tt><b>][</b><tt>!</tt><b>][</b><i>file</i><b>]</b><tt>
   2079 </tt></pre></dd>
   2080 </dl>
   2081 <p class="tent">If the edit buffer has not been modified since the last complete <b>write</b>, <b>xit</b> shall be equivalent to
   2082 the <b>quit</b> command, or if a <tt>'!'</tt> is appended to the command name, to <b>quit!</b>.</p>
   2083 <p class="tent">Otherwise, <b>xit</b> shall be equivalent to the <b>wq</b> command, or if a <tt>'!'</tt> is appended to the command
   2084 name, to <b>wq!</b>.</p>
   2085 <p class="tent"><i>Current line</i>: Unchanged.</p>
   2086 <p class="tent"><i>Current column</i>: Unchanged.</p>
   2087 <h5><a name="tag_20_40_13_50" id="tag_20_40_13_50"></a>Yank</h5>
   2088 <dl compact>
   2089 <dd></dd>
   2090 <dt><i>Synopsis</i>:</dt>
   2091 <dd>
   2092 <p class="tent"></p>
   2093 <pre>
   2094 <b>[</b><i>2addr</i><b>] </b><tt>ya</tt><b>[</b><tt>nk</tt><b>][ </b><i>buffer</i><b>][</b><i>count</i><b>]</b><tt>
   2095 </tt></pre></dd>
   2096 </dl>
   2097 <p class="tent">Copy the specified lines to the specified buffer (by default, the unnamed buffer), which shall become a line-mode
   2098 buffer.</p>
   2099 <p class="tent"><i>Current line</i>: Unchanged.</p>
   2100 <p class="tent"><i>Current column</i>: Unchanged.</p>
   2101 <h5><a name="tag_20_40_13_51" id="tag_20_40_13_51"></a>Adjust Window</h5>
   2102 <dl compact>
   2103 <dd></dd>
   2104 <dt><i>Synopsis</i>:</dt>
   2105 <dd>
   2106 <p class="tent"></p>
   2107 <pre>
   2108 <b>[</b><i>1addr</i><b>] </b><tt>z</tt><b>[</b><tt>!</tt><b>][</b><i>type </i><tt>...</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   2109 </tt></pre></dd>
   2110 </dl>
   2111 <p class="tent">If no line is specified, the current line shall be the default; if <i>type</i> is omitted as well, the current line
   2112 value shall first be incremented by 1. If incrementing the current line would cause it to be greater than the last line in the edit
   2113 buffer, it shall be an error.</p>
   2114 <p class="tent">If there are &lt;blank&gt; characters between the <i>type</i> argument and the preceding <b>z</b> command name or
   2115 optional <tt>'!'</tt> character, it shall be an error.</p>
   2116 <p class="tent">If <i>count</i> is specified, the value of the <b>window</b> edit option shall be set to <i>count</i> (as described
   2117 in <a href="#tag_20_40_13_93">window</a> ). If <i>count</i> is omitted, it shall default to 2 times the value of the <b>scroll</b>
   2118 edit option, or if <b>!</b> was specified, the number of lines in the display minus 1.</p>
   2119 <p class="tent">If <i>type</i> is omitted, then <i>count</i> lines starting with the specified line shall be written. Otherwise,
   2120 <i>count</i> lines starting with the line specified by the <i>type</i> argument shall be written.</p>
   2121 <p class="tent">The <i>type</i> argument shall change the lines to be written. The possible values of <i>type</i> are as
   2122 follows:</p>
   2123 <dl compact>
   2124 <dd></dd>
   2125 <dt><tt>-</tt></dt>
   2126 <dd>The specified line shall be decremented by the following value:
   2127 <pre>
   2128 <tt>(((number of '-' characters) x </tt><i>count</i><tt>) -1)
   2129 </tt></pre>
   2130 <p class="tent">If the calculation would result in a number less than 1, it shall be an error. Write lines from the edit buffer,
   2131 starting at the new value of line, until <i>count</i> lines or the last line in the edit buffer has been written.</p>
   2132 </dd>
   2133 <dt><tt>+</tt></dt>
   2134 <dd>The specified line shall be incremented by the following value:
   2135 <pre>
   2136 <tt>(((number of '+' characters) -1) x </tt><i>count</i><tt>) +1
   2137 </tt></pre>
   2138 <p class="tent">If the calculation would result in a number greater than the last line in the edit buffer, it shall be an error.
   2139 Write lines from the edit buffer, starting at the new value of line, until <i>count</i> lines or the last line in the edit buffer
   2140 has been written.</p>
   2141 </dd>
   2142 <dt><tt>=</tt>,<tt>.</tt></dt>
   2143 <dd>If more than a single <tt>'.'</tt> or <tt>'='</tt> is specified, it shall be an error. The following steps shall be taken:
   2144 <ol>
   2145 <li class="tent">If <i>count</i> is zero, nothing shall be written.</li>
   2146 <li class="tent">Write as many of the <i>N</i> lines before the current line in the edit buffer as exist. If <i>count</i> or
   2147 <tt>'!'</tt> was specified, <i>N</i> shall be:
   2148 <pre>
   2149 <tt>(</tt><i>count</i><tt> -1) /2
   2150 </tt></pre>
   2151 <p class="tent">Otherwise, <i>N</i> shall be:</p>
   2152 <pre>
   2153 <tt>(</tt><i>count</i><tt> -3) /2
   2154 </tt></pre>
   2155 <p class="tent">If <i>N</i> is a number less than 3, no lines shall be written.</p>
   2156 </li>
   2157 <li class="tent">If <tt>'='</tt> was specified as the type character, write a line consisting of the smaller of the number of
   2158 columns in the display divided by two, or 40 <tt>'-'</tt> characters.</li>
   2159 <li class="tent">Write the current line.</li>
   2160 <li class="tent">Repeat step 3.</li>
   2161 <li class="tent">Write as many of the <i>N</i> lines after the current line in the edit buffer as exist. <i>N</i> shall be defined
   2162 as in step 2. If <i>N</i> is a number less than 3, no lines shall be written. If <i>count</i> is less than 3, no lines shall be
   2163 written.</li>
   2164 </ol>
   2165 </dd>
   2166 <dt><tt>^</tt></dt>
   2167 <dd>The specified line shall be decremented by the following value:
   2168 <pre>
   2169 <tt>(((number of '^' characters) +1) x </tt><i>count</i><tt>) -1
   2170 </tt></pre>
   2171 <p class="tent">If the calculation would result in a number less than 1, it shall be an error. Write lines from the edit buffer,
   2172 starting at the new value of line, until <i>count</i> lines or the last line in the edit buffer has been written.</p>
   2173 </dd>
   2174 </dl>
   2175 <p class="tent"><i>Current line</i>: Set to the last line written, unless the type is <b>=</b>, in which case, set to the specified
   2176 line.</p>
   2177 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   2178 <h5><a name="tag_20_40_13_52" id="tag_20_40_13_52"></a>Escape</h5>
   2179 <dl compact>
   2180 <dd></dd>
   2181 <dt><i>Synopsis</i>:</dt>
   2182 <dd>
   2183 <p class="tent"></p>
   2184 <pre>
   2185 <tt>!</tt><i>command
   2186 </i><b>[</b><i>2addr</i><b>]</b><tt> !</tt><i>command</i><tt>
   2187 </tt></pre></dd>
   2188 </dl>
   2189 <p class="tent">The contents of the line after the <tt>'!'</tt> shall have <tt>'%'</tt>, <tt>'#'</tt>, and <tt>'!'</tt> characters
   2190 expanded as described in <a href="#tag_20_40_13_03">Command Line Parsing in ex</a> . If the expansion causes the text of the line
   2191 to change, it shall be redisplayed, preceded by a single <tt>'!'</tt> character.</p>
   2192 <p class="tent">The <i>ex</i> utility shall execute the program named by the <b>shell</b> edit option. It shall pass two arguments
   2193 to the program; the first shall be <b>-c</b>, and the second shall be the expanded arguments to the <b>!</b> command as a single
   2194 argument.</p>
   2195 <p class="tent">If no lines are specified, the standard input, standard output, and standard error of the program shall be set to
   2196 the standard input, standard output, and standard error of the <i>ex</i> program when it was invoked. In addition, a warning
   2197 message shall be written if the edit buffer has been modified since the last complete write, and the <b>warn</b> edit option is
   2198 set.</p>
   2199 <p class="tent">If lines are specified, they shall be passed to the program as standard input, and the standard output and standard
   2200 error of the program shall replace those lines in the edit buffer. Each line in the program output (as delimited by &lt;newline&gt;
   2201 characters or the end of the output if it is not immediately preceded by a &lt;newline&gt;), shall be a separate line in the edit
   2202 buffer. Any occurrences of &lt;carriage-return&gt; and &lt;newline&gt; pairs in the output shall be treated as single
   2203 &lt;newline&gt; characters. The specified lines shall be copied into the unnamed buffer before they are replaced, and the unnamed
   2204 buffer shall become a line-mode buffer.</p>
   2205 <p class="tent">If in <i>ex</i> mode, a single <tt>'!'</tt> character shall be written when the program completes.</p>
   2206 <p class="tent">This command shall be affected by the <b>shell</b> and <b>warn</b> edit options. If no lines are specified, this
   2207 command shall be affected by the <b>autowrite</b> and <b>writeany</b> edit options. If lines are specified, this command shall be
   2208 affected by the <b>autoprint</b> edit option.<br></p>
   2209 <p class="tent"><i>Current line</i>:</p>
   2210 <ol>
   2211 <li class="tent">If no lines are specified, unchanged.</li>
   2212 <li class="tent">Otherwise, set to the last line read in, if any lines are read in.</li>
   2213 <li class="tent">Otherwise, set to the line before the first line of the lines specified, if that line exists.</li>
   2214 <li class="tent">Otherwise, set to the first line of the edit buffer if the edit buffer is not empty.</li>
   2215 <li class="tent">Otherwise, set to zero.</li>
   2216 </ol>
   2217 <p class="tent"><i>Current column</i>: If no lines are specified, unchanged. Otherwise, set to non-&lt;blank&gt;.</p>
   2218 <h5><a name="tag_20_40_13_53" id="tag_20_40_13_53"></a>Shift Left</h5>
   2219 <dl compact>
   2220 <dd></dd>
   2221 <dt><i>Synopsis</i>:</dt>
   2222 <dd>
   2223 <p class="tent"></p>
   2224 <pre>
   2225 <b>[</b><i>2addr</i><b>]</b><tt> &lt;</tt><b>[</b><tt>&lt; ...</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   2226 </tt></pre></dd>
   2227 </dl>
   2228 <p class="tent">Shift the specified lines to the start of the line; the number of column positions to be shifted shall be the
   2229 number of command characters times the value of the <b>shiftwidth</b> edit option. Only leading &lt;blank&gt; characters shall be
   2230 deleted or changed into other &lt;blank&gt; characters in shifting; other characters shall not be affected.</p>
   2231 <p class="tent">Lines to be shifted shall be copied into the unnamed buffer, which shall become a line-mode buffer.</p>
   2232 <p class="tent">This command shall be affected by the <b>autoprint</b> edit option.</p>
   2233 <p class="tent"><i>Current line</i>: Set to the last line in the lines specified.</p>
   2234 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   2235 <h5><a name="tag_20_40_13_54" id="tag_20_40_13_54"></a>Shift Right</h5>
   2236 <dl compact>
   2237 <dd></dd>
   2238 <dt><i>Synopsis</i>:</dt>
   2239 <dd>
   2240 <p class="tent"></p>
   2241 <pre>
   2242 <b>[</b><i>2addr</i><b>]</b><tt> &gt;</tt><b>[</b><tt>&gt; ...</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b><tt>
   2243 </tt></pre></dd>
   2244 </dl>
   2245 <p class="tent">Shift the specified lines away from the start of the line; the number of column positions to be shifted shall be
   2246 the number of command characters times the value of the <b>shiftwidth</b> edit option. The shift shall be accomplished by adding
   2247 &lt;blank&gt; characters as a prefix to the line or changing leading &lt;blank&gt; characters into other &lt;blank&gt; characters.
   2248 Empty lines shall not be changed.</p>
   2249 <p class="tent">Lines to be shifted shall be copied into the unnamed buffer, which shall become a line-mode buffer.</p>
   2250 <p class="tent">This command shall be affected by the <b>autoprint</b> edit option.</p>
   2251 <p class="tent"><i>Current line</i>: Set to the last line in the lines specified.</p>
   2252 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   2253 <h5><a name="tag_20_40_13_55" id="tag_20_40_13_55"></a>&lt;control&gt;-D</h5>
   2254 <dl compact>
   2255 <dd></dd>
   2256 <dt><i>Synopsis</i>:</dt>
   2257 <dd>
   2258 <p class="tent"></p>
   2259 <pre>
   2260 <tt>&lt;control&gt;-D
   2261 </tt></pre></dd>
   2262 </dl>
   2263 <p class="tent">Write the next <i>n</i> lines, where <i>n</i> is the minimum of the values of the <b>scroll</b> edit option and the
   2264 number of lines after the current line in the edit buffer. If the current line is the last line of the edit buffer it shall be an
   2265 error.</p>
   2266 <p class="tent"><i>Current line</i>: Set to the last line written.</p>
   2267 <p class="tent"><i>Current column</i>: Set to non-&lt;blank&gt;.</p>
   2268 <h5><a name="tag_20_40_13_56" id="tag_20_40_13_56"></a>Write Line Number</h5>
   2269 <dl compact>
   2270 <dd></dd>
   2271 <dt><i>Synopsis</i>:</dt>
   2272 <dd>
   2273 <p class="tent"></p>
   2274 <pre>
   2275 <b>[</b><i>1addr</i><b>] </b><tt>= </tt><b>[</b><i>flags</i><b>]</b><tt>
   2276 </tt></pre></dd>
   2277 </dl>
   2278 <p class="tent">If <i>line</i> is not specified, it shall default to the last line in the edit buffer. Write the line number of the
   2279 specified line.</p>
   2280 <p class="tent"><i>Current line</i>: Unchanged.</p>
   2281 <p class="tent"><i>Current column</i>: Unchanged.</p>
   2282 <h5><a name="tag_20_40_13_57" id="tag_20_40_13_57"></a>Execute</h5>
   2283 <dl compact>
   2284 <dd></dd>
   2285 <dt><i>Synopsis</i>:</dt>
   2286 <dd>
   2287 <p class="tent"></p>
   2288 <pre>
   2289 <b>[</b><i>2addr</i><b>]</b><tt> @ </tt><i>buffer</i><tt>
   2290 </tt><b>[</b><i>2addr</i><b>]</b><tt> * </tt><i>buffer</i><tt>
   2291 </tt></pre></dd>
   2292 </dl>
   2293 <p class="tent">If no buffer is specified or is specified as <tt>'@'</tt> or <tt>'*'</tt>, the last buffer executed shall be used.
   2294 If no previous buffer has been executed, it shall be an error.</p>
   2295 <p class="tent">For each line specified by the addresses, set the current line (<tt>'.'</tt>) to the specified line, and execute
   2296 the contents of the named <i>buffer</i> (as they were at the time the <b>@</b> command was executed) as <i>ex</i> commands. For
   2297 each line of a line-mode buffer, and all but the last line of a character-mode buffer, the <i>ex</i> command parser shall behave as
   2298 if the line was terminated by a &lt;newline&gt;.</p>
   2299 <p class="tent">If an error occurs during this process, or a line specified by the addresses does not exist when the current line
   2300 would be set to it, or more than a single line was specified by the addresses, and the contents of the edit buffer are replaced
   2301 (for example, by the <i>ex</i> <b>:edit</b> command) an error message shall be written, and no more commands resulting from the
   2302 execution of this command shall be processed.</p>
   2303 <p class="tent"><i>Current line</i>: As specified for the individual <i>ex</i> commands.</p>
   2304 <p class="tent"><i>Current column</i>: As specified for the individual <i>ex</i> commands.</p>
   2305 <h5><a name="tag_20_40_13_58" id="tag_20_40_13_58"></a>Regular Expressions in ex</h5>
   2306 <p class="tent">The <i>ex</i> utility shall support regular expressions that are a superset of the basic regular expressions
   2307 described in XBD <a href="../basedefs/V1_chap09.html#tag_09_03"><i>9.3 Basic Regular Expressions</i></a> . A null regular
   2308 expression (<tt>"//"</tt>) shall be equivalent to the last regular expression encountered.</p>
   2309 <p class="tent">Regular expressions can be used in addresses to specify lines and, in some commands (for example, the
   2310 <b>substitute</b> command), to specify portions of a line to be substituted.</p>
   2311 <p class="tent">The start and end of a regular expression (RE) are marked by a delimiter character (although in some circumstances
   2312 the end delimiter can be omitted). In addresses, the delimiter is either &lt;slash&gt; or &lt;question-mark&gt;. In commands, other
   2313 characters can be used as the delimiter, as specified in the description of the command. Within the RE (as an <i>ex</i> extension
   2314 to the BRE syntax), the delimiter shall not terminate the RE if it is the second character of an escape sequence (see XBD <a href=
   2315 "../basedefs/V1_chap09.html#tag_09_01"><i>9.1 Regular Expression Definitions</i></a> ) and the escaped delimiter shall be treated
   2316 as that literal character in the RE (losing any special meaning it would have had if it was not used as the delimiter and was not
   2317 escaped). In addition, the delimiter character shall not terminate the RE when it appears within a bracket expression, and shall
   2318 have its normal meaning in the bracket expression. For example, the command <tt>"g%[%]%p"</tt> is equivalent to <tt>"g/[%]/p"</tt>,
   2319 and the command <tt>"s-[0-9]--g"</tt> is equivalent to <tt>"s/[0-9]//g"</tt>.</p>
   2320 <p class="tent">The following constructs can be used to enhance the basic regular expressions:</p>
   2321 <dl compact>
   2322 <dd></dd>
   2323 <dt><tt>\&lt;</tt></dt>
   2324 <dd>Match the beginning of a <i>word</i>. (See the definition of <i>word</i> at the beginning of <a href="#tag_20_40_13_10">Command
   2325 Descriptions in ex</a> .)</dd>
   2326 <dt><tt>\&gt;</tt></dt>
   2327 <dd>Match the end of a <i>word</i>.</dd>
   2328 <dt><tt>~</tt></dt>
   2329 <dd>Match the replacement part of the last <b>substitute</b> command. The &lt;tilde&gt; (<tt>'~'</tt>) character can be escaped in
   2330 a regular expression to become a normal character with no special meaning. The &lt;backslash&gt; shall be discarded.</dd>
   2331 </dl>
   2332 <p class="tent">When the editor option <b>magic</b> is not set, the only characters with special meanings shall be <tt>'^'</tt> at
   2333 the beginning of a pattern, <tt>'$'</tt> at the end of a pattern, and &lt;backslash&gt;. The characters <tt>'.'</tt>, <tt>'*'</tt>,
   2334 <tt>'['</tt>, and <tt>'~'</tt> shall be treated as ordinary characters unless preceded by a &lt;backslash&gt;; when preceded by a
   2335 &lt;backslash&gt; they shall regain their special meaning, or in the case of &lt;backslash&gt;, be handled as a single
   2336 &lt;backslash&gt;. &lt;backslash&gt; characters used to escape other characters shall be discarded.</p>
   2337 <h5><a name="tag_20_40_13_59" id="tag_20_40_13_59"></a>Replacement Strings in ex</h5>
   2338 <p class="tent">Certain characters and strings have special meaning in replacement strings when the character, or the first
   2339 character of the string, is unescaped.</p>
   2340 <p class="tent">The character <tt>'&amp;'</tt> (<tt>'\&amp;'</tt> if the editor option <b>magic</b> is not set) in the replacement
   2341 string shall stand for the text matched by the pattern to be replaced. The character <tt>'~'</tt> (<tt>'\~'</tt> if <b>magic</b> is
   2342 not set) shall be replaced by the replacement part of the previous <b>substitute</b> command. The sequence <tt>'\n'</tt>, where
   2343 <i>n</i> is an integer, shall be replaced by the text matched by the corresponding back-reference expression. If the corresponding
   2344 back-reference expression does not match, then the characters <tt>'\n'</tt> shall be replaced by the empty string.</p>
   2345 <p class="tent">The strings <tt>'\l'</tt>, <tt>'\u'</tt>, <tt>'\L'</tt>, and <tt>'\U'</tt> can be used to modify the case of
   2346 elements in the replacement string (using the <tt>'\&amp;'</tt> or <tt>"\"</tt>digit) notation. The string <tt>'\l'</tt>
   2347 (<tt>'\u'</tt>) shall cause the character that follows to be converted to lowercase (uppercase). The string <tt>'\L'</tt>
   2348 (<tt>'\U'</tt>) shall cause all characters subsequent to it to be converted to lowercase (uppercase) as they are inserted by the
   2349 substitution until the string <tt>'\e'</tt> or <tt>'\E'</tt>, or the end of the replacement string, is encountered.</p>
   2350 <p class="tent">Otherwise, any character following an unescaped &lt;backslash&gt; shall be treated as that literal character, and
   2351 the escaping &lt;backslash&gt; shall be discarded.</p>
   2352 <p class="tent">An example of case conversion with the <b>s</b> command is as follows:</p>
   2353 <pre>
   2354 <b>:</b><tt>p
   2355 </tt><b>The cat sat on the mat.
   2356 :</b><tt>s/\&lt;.at\&gt;/\u&amp;/gp
   2357 </tt><b>The Cat Sat on the Mat.
   2358 :</b><tt>s/S\(.*\)M/S\U\1\eM/p
   2359 </tt><b>The Cat SAT ON THE Mat.</b><tt>
   2360 </tt></pre>
   2361 <h5><a name="tag_20_40_13_60" id="tag_20_40_13_60"></a>Edit Options in ex</h5>
   2362 <p class="tent">The <i>ex</i> utility has a number of options that modify its behavior. These options have default settings, which
   2363 can be changed using the <b>set</b> command.</p>
   2364 <p class="tent">Options are Boolean unless otherwise specified.</p>
   2365 <h5><a name="tag_20_40_13_61" id="tag_20_40_13_61"></a>autoindent, ai</h5>
   2366 <p class="tent">[Default <i>unset</i>]</p>
   2367 <p class="tent">If <b>autoindent</b> is set, each line in input mode shall be indented (using first as many &lt;tab&gt; characters
   2368 as possible, as determined by the editor option <b>tabstop</b>, and then using &lt;space&gt; characters) to align with another
   2369 line, as follows:</p>
   2370 <ol>
   2371 <li class="tent">If in open or visual mode and the text input is part of a line-oriented command (see the EXTENDED DESCRIPTION in
   2372 <a href="../utilities/vi.html#"><i>vi</i></a> ), align to the first column.</li>
   2373 <li class="tent">Otherwise, if in open or visual mode, indentation for each line shall be set as follows:
   2374 <ol type="a">
   2375 <li class="tent">If a line was previously inserted as part of this command, it shall be set to the indentation of the last inserted
   2376 line by default, or as otherwise specified for the &lt;control&gt;-D character in <a href=
   2377 "../utilities/vi.html#tag_20_146_13_88"><i>Input Mode Commands in vi</i></a> .</li>
   2378 <li class="tent">Otherwise, it shall be set to the indentation of the previous current line, if any; otherwise, to the first
   2379 column.</li>
   2380 </ol>
   2381 </li>
   2382 <li class="tent">For the <i>ex</i> <b>a</b>, <b>i</b>, and <b>c</b> commands, indentation for each line shall be set as follows:
   2383 <ol type="a">
   2384 <li class="tent">If a line was previously inserted as part of this command, it shall be set to the indentation of the last inserted
   2385 line by default, or as otherwise specified for the <i>eof</i> character in <a href="#tag_20_40_13_05">Scroll</a> .</li>
   2386 <li class="tent">Otherwise, if the command is the <i>ex</i> <b>a</b> command, it shall be set to the line appended after, if any;
   2387 otherwise to the first column.</li>
   2388 <li class="tent">Otherwise, if the command is the <i>ex</i> <b>i</b> command, it shall be set to the line inserted before, if any;
   2389 otherwise to the first column.</li>
   2390 <li class="tent">Otherwise, if the command is the <i>ex</i> <b>c</b> command, it shall be set to the indentation of the line
   2391 replaced.</li>
   2392 </ol>
   2393 </li>
   2394 </ol>
   2395 <h5><a name="tag_20_40_13_62" id="tag_20_40_13_62"></a>autoprint, ap</h5>
   2396 <p class="tent">[Default <i>set</i>]</p>
   2397 <p class="tent">If <b>autoprint</b> is set, the current line shall be written after each <i>ex</i> command that modifies the
   2398 contents of the current edit buffer, and after each <b>tag</b> command for which the tag search pattern was found or tag line
   2399 number was valid, unless:</p>
   2400 <ol>
   2401 <li class="tent">The command was executed while in open or visual mode.</li>
   2402 <li class="tent">The command was executed as part of a <b>global</b> or <b>v</b> command or <b>@</b> buffer execution.</li>
   2403 <li class="tent">The command was the form of the <b>read</b> command that reads a file into the edit buffer.</li>
   2404 <li class="tent">The command was the <b>append</b>, <b>change</b>, or <b>insert</b> command.</li>
   2405 <li class="tent">The command was not terminated by a &lt;newline&gt;.</li>
   2406 <li class="tent">The current line shall be written by a flag specified to the command; for example, <b>delete #</b> shall write the
   2407 current line as specified for the flag modifier to the <b>delete</b> command, and not as specified by the <b>autoprint</b> edit
   2408 option.</li>
   2409 </ol>
   2410 <h5><a name="tag_20_40_13_63" id="tag_20_40_13_63"></a>autowrite, aw</h5>
   2411 <p class="tent">[Default <i>unset</i>]</p>
   2412 <p class="tent">If <b>autowrite</b> is set, and the edit buffer has been modified since it was last completely written to any file,
   2413 the contents of the edit buffer shall be written as if the <i>ex</i> <b>write</b> command had been specified without arguments,
   2414 before each command affected by the <b>autowrite</b> edit option is executed. Appending the character <tt>'!'</tt> to the command
   2415 name of any of the <i>ex</i> commands except <tt>'!'</tt> shall prevent the write. If the write fails, it shall be an error and the
   2416 command shall not be executed.</p>
   2417 <h5><a name="tag_20_40_13_64" id="tag_20_40_13_64"></a>beautify, bf</h5>
   2418 <p class="tent"><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
   2419 border="0"> [Default <i>unset</i>]</p>
   2420 <p class="tent">If <b>beautify</b> is set, all non-printable characters, other than &lt;tab&gt;, &lt;newline&gt;, and
   2421 &lt;form-feed&gt; characters, shall be discarded from text read in from files. <img src="../images/opt-end.gif" alt="[Option End]"
   2422 border="0"></p>
   2423 <h5><a name="tag_20_40_13_65" id="tag_20_40_13_65"></a>directory, dir</h5>
   2424 <p class="tent">[Default <i>implementation-defined</i>]</p>
   2425 <p class="tent">The value of this option specifies the directory in which the editor buffer is to be placed. If this directory is
   2426 not writable by the user, the editor shall quit.</p>
   2427 <h5><a name="tag_20_40_13_66" id="tag_20_40_13_66"></a>edcompatible, ed</h5>
   2428 <p class="tent">[Default <i>unset</i>]</p>
   2429 <p class="tent">Causes the presence of <b>g</b> and <b>c</b> suffixes on substitute commands to be remembered, and toggled by
   2430 repeating the suffixes.</p>
   2431 <h5><a name="tag_20_40_13_67" id="tag_20_40_13_67"></a>errorbells, eb</h5>
   2432 <p class="tent">[Default <i>unset</i>]</p>
   2433 <p class="tent">If the editor is in <i>ex</i> mode, and the terminal does not support a standout mode (such as inverse video), and
   2434 <b>errorbells</b> is set, error messages shall be preceded by alerting the terminal.</p>
   2435 <h5><a name="tag_20_40_13_68" id="tag_20_40_13_68"></a>exrc</h5>
   2436 <p class="tent">[Default <i>unset</i>]</p>
   2437 <p class="tent">If <b>exrc</b> is set, <i>ex</i> shall access any <b>.exrc</b> file in the current directory, as described in
   2438 <a href="#tag_20_40_13_01">Initialization in ex and vi</a> . If <b>exrc</b> is not set, <i>ex</i> shall ignore any <b>.exrc</b>
   2439 file in the current directory during initialization, unless the current directory is that named by the <i>HOME</i> environment
   2440 variable.</p>
   2441 <h5><a name="tag_20_40_13_69" id="tag_20_40_13_69"></a>ignorecase, ic</h5>
   2442 <p class="tent">[Default <i>unset</i>]</p>
   2443 <p class="tent">If <b>ignorecase</b> is set, characters that have uppercase and lowercase representations shall have those
   2444 representations considered as equivalent for purposes of regular expression comparison.</p>
   2445 <p class="tent">The <b>ignorecase</b> edit option shall affect all remembered regular expressions; for example, unsetting the
   2446 <b>ignorecase</b> edit option shall cause a subsequent <a href="../utilities/vi.html"><i>vi</i></a> <b>n</b> command to search for
   2447 the last basic regular expression in a case-sensitive fashion.</p>
   2448 <h5><a name="tag_20_40_13_70" id="tag_20_40_13_70"></a>list</h5>
   2449 <p class="tent">[Default <i>unset</i>]</p>
   2450 <p class="tent">If <b>list</b> is set, edit buffer lines written while in <i>ex</i> command mode shall be written as specified for
   2451 the <b>print</b> command with the <b>l</b> flag specified. In open or visual mode, each edit buffer line shall be displayed as
   2452 specified for the <i>ex</i> <b>print</b> command with the <b>l</b> flag specified. In open or visual text input mode, when the
   2453 cursor does not rest on any character in the line, it shall rest on the <tt>'$'</tt> marking the end of the line.</p>
   2454 <h5><a name="tag_20_40_13_71" id="tag_20_40_13_71"></a>magic</h5>
   2455 <p class="tent">[Default <i>set</i>]</p>
   2456 <p class="tent">If <b>magic</b> is set, modify the interpretation of characters in regular expressions and substitution replacement
   2457 strings (see <a href="#tag_20_40_13_58">Regular Expressions in ex</a> and <a href="#tag_20_40_13_59">Replacement Strings in ex</a>
   2458 ).</p>
   2459 <h5><a name="tag_20_40_13_72" id="tag_20_40_13_72"></a>mesg</h5>
   2460 <p class="tent">[Default <i>set</i>]</p>
   2461 <p class="tent">If <b>mesg</b> is set, the permission for others to use the <b>write</b> or <b>talk</b> commands to write to the
   2462 terminal shall be turned on while in open or visual mode. The shell-level command <a href="../utilities/mesg.html"><i>mesg</i></a>
   2463 <b>n</b> shall take precedence over any setting of the <i>ex</i> <b>mesg</b> option; that is, if <b>mesg y</b> was issued before
   2464 the editor started (or in a shell escape), such as:</p>
   2465 <pre>
   2466 <tt>:!mesg y
   2467 </tt></pre>
   2468 <p class="tent">the <b>mesg</b> option in <i>ex</i> shall suppress incoming messages, but the <b>mesg</b> option shall not enable
   2469 incoming messages if <b>mesg n</b> was issued.</p>
   2470 <h5><a name="tag_20_40_13_73" id="tag_20_40_13_73"></a>number, nu</h5>
   2471 <p class="tent">[Default <i>unset</i>]</p>
   2472 <p class="tent">If <b>number</b> is set, edit buffer lines written while in <i>ex</i> command mode shall be written with line
   2473 numbers, in the format specified by the <b>print</b> command with the <b>#</b> flag specified. In <i>ex</i> text input mode, each
   2474 line shall be preceded by the line number it will have in the file.</p>
   2475 <p class="tent">In open or visual mode, each edit buffer line shall be displayed with a preceding line number, in the format
   2476 specified by the <i>ex</i> <b>print</b> command with the <b>#</b> flag specified. This line number shall not be considered part of
   2477 the line for the purposes of evaluating the current column; that is, column position 1 shall be the first column position after the
   2478 format specified by the <b>print</b> command.</p>
   2479 <h5><a name="tag_20_40_13_74" id="tag_20_40_13_74"></a>paragraphs, para</h5>
   2480 <p class="tent">[Default in the POSIX locale <tt>IPLPPPQPP LIpplpipbp</tt>]</p>
   2481 <p class="tent">The <b>paragraphs</b> edit option shall define additional paragraph boundaries for the open and visual mode
   2482 commands. The <b>paragraphs</b> edit option can be set to a character string consisting of zero or more character pairs. It shall
   2483 be an error to set it to an odd number of characters.</p>
   2484 <h5><a name="tag_20_40_13_75" id="tag_20_40_13_75"></a>prompt</h5>
   2485 <p class="tent">[Default <i>set</i>]</p>
   2486 <p class="tent">If <b>prompt</b> is set, <i>ex</i> command mode input shall be prompted for with a &lt;colon&gt; (<tt>':'</tt>);
   2487 when unset, no prompt shall be written.</p>
   2488 <h5><a name="tag_20_40_13_76" id="tag_20_40_13_76"></a>readonly</h5>
   2489 <p class="tent">[Default <i>see text</i>]</p>
   2490 <p class="tent">If the <b>readonly</b> edit option is set, read-only mode shall be enabled (see <a href=
   2491 "#tag_20_40_13_48">Write</a> ). The <b>readonly</b> edit option shall be initialized to set if either of the following conditions
   2492 are true:</p>
   2493 <ul>
   2494 <li class="tent">The command-line option -R was specified.</li>
   2495 <li class="tent">Performing actions equivalent to the <a href="../functions/access.html"><i>access</i>()</a> function called with
   2496 the following arguments indicates that the file lacks write permission:
   2497 <ol>
   2498 <li class="tent">The current pathname is used as the <i>path</i> argument.</li>
   2499 <li class="tent">The constant <b>W_OK</b> is used as the <i>amode</i> argument.</li>
   2500 </ol>
   2501 </li>
   2502 </ul>
   2503 <p class="tent">The <b>readonly</b> edit option may be initialized to set for other, implementation-defined reasons. The
   2504 <b>readonly</b> edit option shall not be initialized to unset based on any special privileges of the user or process. The
   2505 <b>readonly</b> edit option shall be reinitialized each time that the contents of the edit buffer are replaced (for example, by an
   2506 <b>edit</b> or <b>next</b> command) unless the user has explicitly set it, in which case it shall remain set until the user
   2507 explicitly unsets it. Once unset, it shall again be reinitialized each time that the contents of the edit buffer are replaced.</p>
   2508 <h5><a name="tag_20_40_13_77" id="tag_20_40_13_77"></a>redraw</h5>
   2509 <p class="tent">[Default <i>unset</i>]</p>
   2510 <p class="tent">If <b>redraw</b> is set and the terminal is a type incapable of supporting open or visual modes, the editor shall
   2511 redraw the screen when necessary in order to update its contents. (Since this is likely to require a large amount of output to the
   2512 terminal, it is useful only at high transmission speeds.)</p>
   2513 <h5><a name="tag_20_40_13_78" id="tag_20_40_13_78"></a>remap</h5>
   2514 <p class="tent">[Default <i>set</i>]</p>
   2515 <p class="tent">If <b>remap</b> is set, map translation shall allow for maps defined in terms of other maps; translation shall
   2516 continue until a final product is obtained. If unset, only a one-step translation shall be done.</p>
   2517 <h5><a name="tag_20_40_13_79" id="tag_20_40_13_79"></a>report</h5>
   2518 <p class="tent">[Default 5]</p>
   2519 <p class="tent">The value of this <b>report</b> edit option specifies what number of lines being added, copied, deleted, or
   2520 modified in the edit buffer will cause an informational message to be written to the user. The following conditions shall cause an
   2521 informational message. The message shall contain the number of lines added, copied, deleted, or modified, but is otherwise
   2522 unspecified.</p>
   2523 <ul>
   2524 <li class="tent">An <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> editor command, other than <b>open</b>, <b>undo</b>,
   2525 or <b>visual</b>, that modifies at least the value of the <b>report</b> edit option number of lines, and which is not part of an
   2526 <i>ex</i> <b>global</b> or <b>v</b> command, or <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> buffer execution, shall
   2527 cause an informational message to be written.</li>
   2528 <li class="tent">An <i>ex</i> <b>yank</b> or <a href="../utilities/vi.html"><i>vi</i></a> <b>y</b> or <b>Y</b> command, that copies
   2529 at least the value of the <b>report</b> edit option plus 1 number of lines, and which is not part of an <i>ex</i> <b>global</b> or
   2530 <b>v</b> command, or <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> buffer execution, shall cause an informational
   2531 message to be written.</li>
   2532 <li class="tent">An <i>ex</i> <b>global</b>, <b>v</b>, <b>open</b>, <b>undo</b>, or <b>visual</b> command or <i>ex</i> or <a href=
   2533 "../utilities/vi.html"><i>vi</i></a> buffer execution, that adds or deletes a total of at least the value of the <b>report</b> edit
   2534 option number of lines, and which is not part of an <i>ex</i> <b>global</b> or <b>v</b> command, or <i>ex</i> or <a href=
   2535 "../utilities/vi.html"><i>vi</i></a> buffer execution, shall cause an informational message to be written. (For example, if 3 lines
   2536 were added and 8 lines deleted during an <i>ex</i> <b>visual</b> command, 5 would be the number compared against the <b>report</b>
   2537 edit option after the command completed.)</li>
   2538 </ul>
   2539 <h5><a name="tag_20_40_13_80" id="tag_20_40_13_80"></a>scroll, scr</h5>
   2540 <p class="tent">[Default (number of lines in the display -1)/2]</p>
   2541 <p class="tent">The value of the <b>scroll</b> edit option shall determine the number of lines scrolled by the <i>ex</i>
   2542 &lt;control&gt;-D and <b>z</b> commands. For the <a href="../utilities/vi.html"><i>vi</i></a> &lt;control&gt;-D and
   2543 &lt;control&gt;-U commands, it shall be the initial number of lines to scroll when no previous &lt;control&gt;-D or
   2544 &lt;control&gt;-U command has been executed.</p>
   2545 <h5><a name="tag_20_40_13_81" id="tag_20_40_13_81"></a>sections</h5>
   2546 <p class="tent">[Default in the POSIX locale <tt>NHSHH HUnhsh</tt>]</p>
   2547 <p class="tent">The <b>sections</b> edit option shall define additional section boundaries for the open and visual mode commands.
   2548 The <b>sections</b> edit option can be set to a character string consisting of zero or more character pairs; it shall be an error
   2549 to set it to an odd number of characters.</p>
   2550 <h5><a name="tag_20_40_13_82" id="tag_20_40_13_82"></a>shell, sh</h5>
   2551 <p class="tent">[Default from the environment variable <i>SHELL ]</i></p>
   2552 <p class="tent">The value of this option shall be a string. The default shall be taken from the <i>SHELL</i> environment variable.
   2553 If the <i>SHELL</i> environment variable is null or empty, the <a href="../utilities/sh.html"><i>sh</i></a> (see <a href=
   2554 "../utilities/sh.html#"><i>sh</i></a> ) utility shall be the default.</p>
   2555 <h5><a name="tag_20_40_13_83" id="tag_20_40_13_83"></a>shiftwidth, sw</h5>
   2556 <p class="tent">[Default 8]</p>
   2557 <p class="tent">The value of this option shall give the width in columns of an indentation level used during autoindentation and by
   2558 the shift commands (<b>&lt;</b> and <b>&gt;</b>).</p>
   2559 <h5><a name="tag_20_40_13_84" id="tag_20_40_13_84"></a>showmatch, sm</h5>
   2560 <p class="tent">[Default <i>unset</i>]</p>
   2561 <p class="tent">The functionality described for the <b>showmatch</b> edit option need not be supported on block-mode terminals or
   2562 terminals with insufficient capabilities.</p>
   2563 <p class="tent">If <b>showmatch</b> is set, in open or visual mode, when a <tt>')'</tt> or <tt>'}'</tt> is typed, if the matching
   2564 <tt>'('</tt> or <tt>'{'</tt> is currently visible on the display, the matching <tt>'('</tt> or <tt>'{'</tt> shall be flagged moving
   2565 the cursor to its location for an unspecified amount of time.</p>
   2566 <h5><a name="tag_20_40_13_85" id="tag_20_40_13_85"></a>showmode</h5>
   2567 <p class="tent">[Default <i>unset</i>]</p>
   2568 <p class="tent">If <b>showmode</b> is set, in open or visual mode, the current mode that the editor is in shall be displayed on the
   2569 last line of the display. Command mode and text input mode shall be differentiated; other unspecified modes and
   2570 implementation-defined information may be displayed.</p>
   2571 <h5><a name="tag_20_40_13_86" id="tag_20_40_13_86"></a>slowopen</h5>
   2572 <p class="tent">[Default <i>unset</i>]</p>
   2573 <p class="tent">If <b>slowopen</b> is set during open and visual text input modes, the editor shall not update portions of the
   2574 display other than those display line columns that display the characters entered by the user (see <a href=
   2575 "../utilities/vi.html#tag_20_146_13_88"><i>Input Mode Commands in vi</i></a> ).</p>
   2576 <h5><a name="tag_20_40_13_87" id="tag_20_40_13_87"></a>tabstop, ts</h5>
   2577 <p class="tent">[Default 8]</p>
   2578 <p class="tent">The value of this edit option shall specify the column boundary used by a &lt;tab&gt; in the display (see <a href=
   2579 "#tag_20_40_13_62">autoprint, ap</a> and <a href="../utilities/vi.html#tag_20_146_13_88"><i>Input Mode Commands in vi</i></a>
   2580 ).</p>
   2581 <h5><a name="tag_20_40_13_88" id="tag_20_40_13_88"></a>taglength, tl</h5>
   2582 <p class="tent">[Default zero]</p>
   2583 <p class="tent">The value of this edit option shall specify the maximum number of characters that are considered significant in the
   2584 user-specified tag name and in the tag name from the tags file. If the value is zero, all characters in both tag names shall be
   2585 significant.</p>
   2586 <h5><a name="tag_20_40_13_89" id="tag_20_40_13_89"></a>tags</h5>
   2587 <p class="tent">[Default <i>see text</i>]</p>
   2588 <p class="tent">The value of this edit option shall be a string of &lt;blank&gt;-delimited pathnames of files used by the
   2589 <b>tag</b> command. The default value is unspecified.</p>
   2590 <h5><a name="tag_20_40_13_90" id="tag_20_40_13_90"></a>term</h5>
   2591 <p class="tent">[Default from the environment variable <i>TERM ]</i></p>
   2592 <p class="tent">The value of this edit option shall be a string. The default shall be taken from the <i>TERM</i> variable in the
   2593 environment. If the <i>TERM</i> environment variable is empty or null, the default is unspecified. The editor shall use the value
   2594 of this edit option to determine the type of the display device.</p>
   2595 <p class="tent">The results are unspecified if the user changes the value of the term edit option after editor initialization.</p>
   2596 <h5><a name="tag_20_40_13_91" id="tag_20_40_13_91"></a>terse</h5>
   2597 <p class="tent">[Default <i>unset</i>]</p>
   2598 <p class="tent">If <b>terse</b> is set, error messages may be less verbose. However, except for this caveat, error messages are
   2599 unspecified. Furthermore, not all error messages need change for different settings of this option.</p>
   2600 <h5><a name="tag_20_40_13_92" id="tag_20_40_13_92"></a>warn</h5>
   2601 <p class="tent">[Default <i>set</i>]</p>
   2602 <p class="tent">If <b>warn</b> is set, and the contents of the edit buffer have been modified since they were last completely
   2603 written, the editor shall write a warning message before certain <b>!</b> commands (see <a href="#tag_20_40_13_52">Escape</a>
   2604 ).</p>
   2605 <h5><a name="tag_20_40_13_93" id="tag_20_40_13_93"></a>window</h5>
   2606 <p class="tent">[Default <i>see text</i>]</p>
   2607 <p class="tent">A value used in open and visual mode, by the &lt;control&gt;-B and &lt;control&gt;-F commands, and, in visual mode,
   2608 to specify the number of lines displayed when the screen is repainted.</p>
   2609 <p class="tent">If the <b>-w</b> command-line option is not specified, the default value shall be set to the value of the
   2610 <i>LINES</i> environment variable. If the <i>LINES</i> environment variable is empty or null, the default shall be the number of
   2611 lines in the display minus 1.</p>
   2612 <p class="tent">Setting the <b>window</b> edit option to zero or to a value greater than the number of lines in the display minus 1
   2613 (either explicitly or based on the <b>-w</b> option or the <i>LINES</i> environment variable) shall cause the <b>window</b> edit
   2614 option to be set to the number of lines in the display minus 1.</p>
   2615 <p class="tent">The baud rate of the terminal line may change the default in an implementation-defined manner.</p>
   2616 <h5><a name="tag_20_40_13_94" id="tag_20_40_13_94"></a>wrapmargin, wm</h5>
   2617 <p class="tent">[Default 0]</p>
   2618 <p class="tent">If the value of this edit option is zero, it shall have no effect.</p>
   2619 <p class="tent">If not in the POSIX locale, the effect of this edit option is implementation-defined.</p>
   2620 <p class="tent">Otherwise, it shall specify a number of columns from the ending margin of the terminal.</p>
   2621 <p class="tent">During open and visual text input modes, for each character for which any part of the character is displayed in a
   2622 column that is less than <b>wrapmargin</b> columns from the ending margin of the display line, the editor shall behave as
   2623 follows:</p>
   2624 <ol>
   2625 <li class="tent">If the character triggering this event is a &lt;blank&gt;, it, and all immediately preceding &lt;blank&gt;
   2626 characters on the current line entered during the execution of the current text input command, shall be discarded, and the editor
   2627 shall behave as if the user had entered a single &lt;newline&gt; instead. In addition, if the next user-entered character is a
   2628 &lt;space&gt;, it shall be discarded as well.</li>
   2629 <li class="tent">Otherwise, if there are one or more &lt;blank&gt; characters on the current line immediately preceding the last
   2630 group of inserted non-&lt;blank&gt; characters which was entered during the execution of the current text input command, the
   2631 &lt;blank&gt; characters shall be replaced as if the user had entered a single &lt;newline&gt; instead.</li>
   2632 </ol>
   2633 <p class="tent">If the <b>autoindent</b> edit option is set, and the events described in 1. or 2. are performed, any &lt;blank&gt;
   2634 characters at or after the cursor in the current line shall be discarded.</p>
   2635 <p class="tent">The ending margin shall be determined by the system or overridden by the user, as described for <i>COLUMNS</i> in
   2636 the ENVIRONMENT VARIABLES section and XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> .</p>
   2637 <h5><a name="tag_20_40_13_95" id="tag_20_40_13_95"></a>wrapscan, ws</h5>
   2638 <p class="tent">[Default <i>set</i>]</p>
   2639 <p class="tent">If <b>wrapscan</b> is set, searches (the <i>ex</i> <b>/</b> or <b>?</b> addresses, or open and visual mode
   2640 <b>/</b>, <b>?</b>, <b>N</b>, and <b>n</b> commands) shall wrap around the beginning or end of the edit buffer; when unset,
   2641 searches shall stop at the beginning or end of the edit buffer.</p>
   2642 <h5><a name="tag_20_40_13_96" id="tag_20_40_13_96"></a>writeany, wa</h5>
   2643 <p class="tent">[Default <i>unset</i>]</p>
   2644 <p class="tent">If <b>writeany</b> is set, some of the checks performed when executing the <i>ex</i> <b>write</b> commands shall be
   2645 inhibited, as described in editor option <b>autowrite</b>.</p>
   2646 </blockquote>
   2647 <h4 class="mansect"><a name="tag_20_40_14" id="tag_20_40_14"></a>EXIT STATUS</h4>
   2648 <blockquote>
   2649 <p>The following exit values shall be returned:</p>
   2650 <dl compact>
   2651 <dd></dd>
   2652 <dt>&nbsp;0</dt>
   2653 <dd>Successful completion.</dd>
   2654 <dt>&gt;0</dt>
   2655 <dd>An error occurred.</dd>
   2656 </dl>
   2657 </blockquote>
   2658 <h4 class="mansect"><a name="tag_20_40_15" id="tag_20_40_15"></a>CONSEQUENCES OF ERRORS</h4>
   2659 <blockquote>
   2660 <p>When any error is encountered and the standard input is not a terminal device file, in addition to the default requirements
   2661 described in <a href="../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description Defaults</i></a> , <i>ex</i> shall neither
   2662 write the file (if one has been opened) nor return to command or text input mode.</p>
   2663 <p class="tent">Otherwise, when an unrecoverable error is encountered, it shall be equivalent to a SIGHUP asynchronous event.</p>
   2664 <p class="tent">Otherwise, when an error is encountered, the editor shall behave as specified in <a href="#tag_20_40_13_03">Command
   2665 Line Parsing in ex</a> .</p>
   2666 </blockquote>
   2667 <hr>
   2668 <div class="box"><em>The following sections are informative.</em></div>
   2669 <h4 class="mansect"><a name="tag_20_40_16" id="tag_20_40_16"></a>APPLICATION USAGE</h4>
   2670 <blockquote>
   2671 <p>If a SIGSEGV signal is received while <i>ex</i> is saving a file, the file might not be successfully saved.</p>
   2672 <p class="tent">The <b>next</b> command can accept more than one file, so usage such as:</p>
   2673 <pre>
   2674 <tt>next `ls [abc]*`
   2675 </tt></pre>
   2676 <p class="tent">is valid; it would not be valid for the <b>edit</b> or <b>read</b> commands, for example, because they expect only
   2677 one file and unspecified results occur.</p>
   2678 <p class="tent">Unlike the <a href="../functions/system.html#"><i>system</i></a> function, <i>ex</i> does not pass <tt>"--"</tt>
   2679 between the <tt>"-c"</tt> argument and the command string, so that programs for which <b>-c</b> takes an option-argument can be
   2680 used in the <b>shell</b> edit option. Users who want to use an <b>escape</b> command to execute a utility whose name starts with
   2681 <tt>'-'</tt> or <tt>'+'</tt> need to provide a pathname for that utility that does not start with either of those characters, or
   2682 precede the utility name with a &lt;blank&gt; character.</p>
   2683 </blockquote>
   2684 <h4 class="mansect"><a name="tag_20_40_17" id="tag_20_40_17"></a>EXAMPLES</h4>
   2685 <blockquote>
   2686 <p>None.</p>
   2687 </blockquote>
   2688 <h4 class="mansect"><a name="tag_20_40_18" id="tag_20_40_18"></a>RATIONALE</h4>
   2689 <blockquote>
   2690 <p>The <i>ex</i>/<a href="../utilities/vi.html"><i>vi</i></a> specification is based on the historical practice found in the 4 BSD
   2691 and System V implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>.</p>
   2692 <p class="tent">A <i>restricted editor</i> (both the historical <i>red</i> utility and modifications to <i>ex</i>) were considered
   2693 and rejected for inclusion. Neither option provided the level of security that users might expect.</p>
   2694 <p class="tent">It is recognized that <i>ex</i> visual mode and related features would be difficult, if not impossible, to
   2695 implement satisfactorily on a block-mode terminal, or a terminal without any form of cursor addressing; thus, it is not a mandatory
   2696 requirement that such features should work on all terminals. It is the intention, however, that an <i>ex</i> implementation should
   2697 provide the full set of capabilities on all terminals capable of supporting them.</p>
   2698 <h5><a name="tag_20_40_18_01" id="tag_20_40_18_01"></a>Options</h5>
   2699 <p class="tent">The <b>-c</b> replacement for <b>+</b><i>command</i> was inspired by the <b>-e</b> option of <a href=
   2700 "../utilities/sed.html"><i>sed</i></a>. Historically, all such commands (see <b>edit</b> and <b>next</b> as well) were executed
   2701 from the last line of the edit buffer. This meant, for example, that <tt>"+/pattern"</tt> would fail unless the <b>wrapscan</b>
   2702 option was set. POSIX.1-2024 requires conformance to historical practice. The <b>+</b><i>command</i> option is no longer specified
   2703 by POSIX.1-2024 but may be present in some implementations. Historically, some implementations restricted the <i>ex</i> commands
   2704 that could be listed as part of the command line arguments. For consistency, POSIX.1-2024 does not permit these restrictions.</p>
   2705 <p class="tent">In historical implementations of the editor, the <b>-R</b> option (and the <b>readonly</b> edit option) only
   2706 prevented overwriting of files; appending to files was still permitted, mapping loosely into the <i>csh</i> <b>noclobber</b>
   2707 variable. Some implementations, however, have not followed this semantic, and <b>readonly</b> does not permit appending either.
   2708 POSIX.1-2024 follows the latter practice, believing that it is a more obvious and intuitive meaning of <b>readonly</b>.</p>
   2709 <p class="tent">The <b>-s</b> option suppresses all interactive user feedback and is useful for editing scripts in batch jobs. The
   2710 list of specific effects is historical practice. The terminal type &quot;incapable of supporting open and visual modes&quot; has
   2711 historically been named &quot;dumb&quot;.</p>
   2712 <p class="tent">The <b>-t</b> option was required because the <a href="../utilities/ctags.html"><i>ctags</i></a> utility appears in
   2713 POSIX.1-2024 and the option is available in all historical implementations of <i>ex</i>.</p>
   2714 <p class="tent">Historically, the <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> utilities accepted a <b>-x</b> option,
   2715 which did encryption based on the algorithm found in the historical <i>crypt</i> utility. The <b>-x</b> option for encryption, and
   2716 the associated <i>crypt</i> utility, were omitted because the algorithm used was not specifiable and the export control laws of
   2717 some nations make it difficult to export cryptographic technology. In addition, it did not historically provide the level of
   2718 security that users might expect.</p>
   2719 <h5><a name="tag_20_40_18_02" id="tag_20_40_18_02"></a>Standard Input</h5>
   2720 <p class="tent">An end-of-file condition is not equivalent to an end-of-file character. A common end-of-file character,
   2721 &lt;control&gt;-D, is historically an <i>ex</i> command.</p>
   2722 <p class="tent">There was no maximum line length in historical implementations of <i>ex</i>. Specifically, as it was parsed in
   2723 chunks, the addresses had a different maximum length than the filenames. Further, the maximum line buffer size was declared as
   2724 BUFSIZ, which was different lengths on different systems. This version selected the value of {LINE_MAX} to impose a reasonable
   2725 restriction on portable usage of <i>ex</i> and to aid test suite writers in their development of realistic tests that exercise this
   2726 limit.</p>
   2727 <h5><a name="tag_20_40_18_03" id="tag_20_40_18_03"></a>Input Files</h5>
   2728 <p class="tent">It was an explicit decision by the standard developers that a &lt;newline&gt; be added to any file lacking one. It
   2729 was believed that this feature of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> was relied on by users in order to
   2730 make text files lacking a trailing &lt;newline&gt; more portable. It is recognized that this will require a user-specified option
   2731 or extension for implementations that permit <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> to edit files of type other
   2732 than text if such files are not otherwise identified by the system. It was agreed that the ability to edit files of arbitrary type
   2733 can be useful, but it was not considered necessary to mandate that an <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a>
   2734 implementation be required to handle files other than text files.</p>
   2735 <p class="tent">The paragraph in the INPUT FILES section, &quot;By default, ...&quot;, is intended to close a long-standing security
   2736 problem in <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>; that of the &quot;modeline&quot; or &quot;modelines&quot; edit option. This
   2737 feature allows any line in the first or last five lines of the file containing the strings <tt>"ex:"</tt> or <tt>"vi:"</tt> (and,
   2738 apparently, <tt>"ei:"</tt> or <tt>"vx:"</tt>) to be a line containing editor commands, and <i>ex</i> interprets all the text up to
   2739 the next <tt>':'</tt> or &lt;newline&gt; as a command. Consider the consequences, for example, of an unsuspecting user using
   2740 <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> as the editor when replying to a mail message in which a line such
   2741 as:</p>
   2742 <pre>
   2743 <tt>ex:! rm -rf :
   2744 </tt></pre>
   2745 <p class="tent">appeared in the signature lines. The standard developers believed strongly that an editor should not by default
   2746 interpret any lines of a file. Vendors are strongly urged to delete this feature from their implementations of <i>ex</i> and
   2747 <a href="../utilities/vi.html"><i>vi</i></a>.</p>
   2748 <h5><a name="tag_20_40_18_04" id="tag_20_40_18_04"></a>Asynchronous Events</h5>
   2749 <p class="tent">The intention of the phrase &quot;complete write&quot; is that the entire edit buffer be written to stable storage. The
   2750 note regarding temporary files is intended for implementations that use temporary files to back edit buffers unnamed by the
   2751 user.</p>
   2752 <p class="tent">Historically, SIGQUIT was ignored by <i>ex</i>, but was the equivalent of the <b>Q</b> command in visual mode; that
   2753 is, it exited visual mode and entered <i>ex</i> mode. POSIX.1-2024 permits, but does not require, this behavior. Historically,
   2754 SIGINT was often used by <a href="../utilities/vi.html"><i>vi</i></a> users to terminate text input mode (&lt;control&gt;-C is
   2755 often easier to enter than &lt;ESC&gt;). Some implementations of <a href="../utilities/vi.html"><i>vi</i></a> alerted the terminal
   2756 on this event, and some did not. POSIX.1-2024 requires that SIGINT behave identically to &lt;ESC&gt;, and that the terminal not be
   2757 alerted.</p>
   2758 <p class="tent">Historically, suspending the <i>ex</i> editor during text input mode was similar to SIGINT, as completed lines were
   2759 retained, but any partial line discarded, and the editor returned to command mode. POSIX.1-2024 is silent on this issue;
   2760 implementations are encouraged to follow historical practice, where possible.</p>
   2761 <p class="tent">Historically, the <a href="../utilities/vi.html"><i>vi</i></a> editor did not treat SIGTSTP as an asynchronous
   2762 event, and it was therefore impossible to suspend the editor in visual text input mode. There are two major reasons for this. The
   2763 first is that SIGTSTP is a broadcast signal on UNIX systems, and the chain of events where the shell <a href=
   2764 "../utilities/V3_chap02.html#exec"><i>exec</i></a>s an application that then <a href=
   2765 "../utilities/V3_chap02.html#exec"><i>exec</i></a>s <a href="../utilities/vi.html"><i>vi</i></a> usually caused confusion for the
   2766 terminal state if SIGTSTP was delivered to the process group in the default manner. The second was that most implementations of the
   2767 UNIX <i>curses</i> package did not handle SIGTSTP safely, and the receipt of SIGTSTP at the wrong time would cause them to crash.
   2768 POSIX.1-2024 is silent on this issue; implementations are encouraged to treat suspension as an asynchronous event if possible.</p>
   2769 <p class="tent">Historically, modifications to the edit buffer made before SIGINT interrupted an operation were retained; that is,
   2770 anywhere from zero to all of the lines to be modified might have been modified by the time the SIGINT arrived. These changes were
   2771 not discarded by the arrival of SIGINT. POSIX.1-2024 permits this behavior, noting that the <b>undo</b> command is required to be
   2772 able to undo these partially completed commands.</p>
   2773 <p class="tent">The action taken for signals other than SIGINT, SIGCONT, SIGHUP, and SIGTERM is unspecified because some
   2774 implementations attempt to save the edit buffer in a useful state when other signals are received.</p>
   2775 <h5><a name="tag_20_40_18_05" id="tag_20_40_18_05"></a>Standard Error</h5>
   2776 <p class="tent">For <i>ex</i>/<a href="../utilities/vi.html"><i>vi</i></a>, diagnostic messages are those messages reported as a
   2777 result of a failed attempt to invoke <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a>, such as invalid options or
   2778 insufficient resources, or an abnormal termination condition. Diagnostic messages should not be confused with the error messages
   2779 generated by inappropriate or illegal user commands.</p>
   2780 <h5><a name="tag_20_40_18_06" id="tag_20_40_18_06"></a>Initialization in ex and vi</h5>
   2781 <p class="tent">If an <i>ex</i> command (other than <b>cd</b>, <b>chdir</b>, or <b>source</b>) has a filename argument, one or both
   2782 of the alternate and current pathnames will be set. Informally, they are set as follows:</p>
   2783 <ol>
   2784 <li class="tent">If the <i>ex</i> command is one that replaces the contents of the edit buffer, and it succeeds, the current
   2785 pathname will be set to the filename argument (the first filename argument in the case of the <b>next</b> command) and the
   2786 alternate pathname will be set to the previous current pathname, if there was one.</li>
   2787 <li class="tent">In the case of the file read/write forms of the <b>read</b> and <b>write</b> commands, if there is no current
   2788 pathname, the current pathname will be set to the filename argument.</li>
   2789 <li class="tent">Otherwise, the alternate pathname will be set to the filename argument.</li>
   2790 </ol>
   2791 <p class="tent">For example, <b>:edit foo</b> and <b>:recover foo</b>, when successful, set the current pathname, and, if there was
   2792 a previous current pathname, the alternate pathname. The commands <b>:write</b>, <b>!command</b>, and <b>:edit</b> set neither the
   2793 current or alternate pathnames. If the <b>:edit foo</b> command were to fail for some reason, the alternate pathname would be set.
   2794 The <b>read</b> and <b>write</b> commands set the alternate pathname to their <i>file</i> argument, unless the current pathname is
   2795 not set, in which case they set the current pathname to their <i>file</i> arguments. The alternate pathname was not historically
   2796 set by the <b>:source</b> command. POSIX.1-2024 requires conformance to historical practice. Implementations adding commands that
   2797 take filenames as arguments are encouraged to set the alternate pathname as described here.</p>
   2798 <p class="tent">Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> read the <b>.exrc</b> file in the
   2799 <i>$HOME</i> directory twice, if the editor was executed in the <i>$HOME</i> directory. POSIX.1-2024 prohibits this behavior.</p>
   2800 <p class="tent">Historically, the 4 BSD <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> read the <i>$HOME</i> and local
   2801 <b>.exrc</b> files if they were owned by the real ID of the user, or the <b>sourceany</b> option was set, regardless of other
   2802 considerations. This was a security problem because it is possible to put normal UNIX system commands inside a <b>.exrc</b> file.
   2803 POSIX.1-2024 does not specify the <b>sourceany</b> option, and historical implementations are encouraged to delete it.</p>
   2804 <p class="tent">The <b>.exrc</b> files must be owned by the real ID of the user, and not writable by anyone other than the owner.
   2805 The appropriate privileges exception is intended to permit users to acquire special privileges, but continue to use the
   2806 <b>.exrc</b> files in their home directories.</p>
   2807 <p class="tent">System V Release 3.2 and later <a href="../utilities/vi.html"><i>vi</i></a> implementations added the option
   2808 <b>[no]exrc</b>. The behavior is that local <b>.exrc</b> files are read-only if the <b>exrc</b> option is set. The default for the
   2809 <b>exrc</b> option was off, so by default, local <b>.exrc</b> files were not read. The problem this was intended to solve was that
   2810 System V permitted users to give away files, so there is no possible ownership or writeability test to ensure that the file is
   2811 safe. This is still a security problem on systems where users can give away files, but there is nothing additional that
   2812 POSIX.1-2024 can do. The implementation-defined exception is intended to permit groups to have local <b>.exrc</b> files that are
   2813 shared by users, by creating pseudo-users to own the shared files.</p>
   2814 <p class="tent">POSIX.1-2024 does not mention system-wide <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> start-up
   2815 files. While they exist in several implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>, they are not
   2816 present in any implementations considered historical practice by POSIX.1-2024. Implementations that have such files should use them
   2817 only if they are owned by the real user ID or an appropriate user (for example, root on UNIX systems) and if they are not writable
   2818 by any user other than their owner. System-wide start-up files should be read before the <i>EXINIT</i> variable,
   2819 <b>$HOME/.exrc</b>, or local <b>.exrc</b> files are evaluated.</p>
   2820 <p class="tent">Historically, any <i>ex</i> command could be entered in the <i>EXINIT</i> variable or the <b>.exrc</b> file,
   2821 although ones requiring that the edit buffer already contain lines of text generally caused historical implementations of the
   2822 editor to drop <b>core</b>. POSIX.1-2024 requires that any <i>ex</i> command be permitted in the <i>EXINIT</i> variable and
   2823 <b>.exrc</b> files, for simplicity of specification and consistency, although many of them will obviously fail under many
   2824 circumstances.</p>
   2825 <p class="tent">The initialization of the contents of the edit buffer uses the phrase &quot;the effect shall be&quot; with regard to
   2826 various <i>ex</i> commands. The intent of this phrase is that edit buffer contents loaded during the initialization phase not be
   2827 lost; that is, loading the edit buffer should fail if the <b>.exrc</b> file read in the contents of a file and did not subsequently
   2828 write the edit buffer. An additional intent of this phrase is to specify that the initial current line and column is set as
   2829 specified for the individual <i>ex</i> commands.</p>
   2830 <p class="tent">Historically, the <b>-t</b> option behaved as if the tag search were a <b>+</b><i>command</i>; that is, it was
   2831 executed from the last line of the file specified by the tag. This resulted in the search failing if the pattern was a forward
   2832 search pattern and the <b>wrapscan</b> edit option was not set. POSIX.1-2024 does not permit this behavior, requiring that the
   2833 search for the tag pattern be performed on the entire file, and, if not found, that the current line be set to a more reasonable
   2834 location in the file.</p>
   2835 <p class="tent">Historically, the empty edit buffer presented for editing when a file was not specified by the user was unnamed.
   2836 This is permitted by POSIX.1-2024; however, implementations are encouraged to provide users a temporary filename for this buffer
   2837 because it permits them the use of <i>ex</i> commands that use the current pathname during temporary edit sessions.</p>
   2838 <p class="tent">Historically, the file specified using the <b>-t</b> option was not part of the current argument list. This
   2839 practice is permitted by POSIX.1-2024; however, implementations are encouraged to include its name in the current argument list for
   2840 consistency.</p>
   2841 <p class="tent">Historically, the <b>-c</b> command was generally not executed until a file that already exists was edited.
   2842 POSIX.1-2024 requires conformance to this historical practice. Commands that could cause the <b>-c</b> command to be executed
   2843 include the <i>ex</i> commands <b>edit</b>, <b>next</b>, <b>recover</b>, <b>rewind</b>, and <b>tag</b>, and the <a href=
   2844 "../utilities/vi.html"><i>vi</i></a> commands &lt;control&gt;-^ and &lt;control&gt;-]. Historically, reading a file into an edit
   2845 buffer did not cause the <b>-c</b> command to be executed (even though it might set the current pathname) with the exception that
   2846 it did cause the <b>-c</b> command to be executed if: the editor was in <i>ex</i> mode, the edit buffer had no current pathname,
   2847 the edit buffer was empty, and no read commands had yet been attempted. For consistency and simplicity of specification,
   2848 POSIX.1-2024 does not permit this behavior.</p>
   2849 <p class="tent">Historically, the <b>-r</b> option was the same as a normal edit session if there was no recovery information
   2850 available for the file. This allowed users to enter:</p>
   2851 <pre>
   2852 <tt>vi -r *.c
   2853 </tt></pre>
   2854 <p class="tent">and recover whatever files were recoverable. In some implementations, recovery was attempted only on the first file
   2855 named, and the file was not entered into the argument list; in others, recovery was attempted for each file named. In addition,
   2856 some historical implementations ignored <b>-r</b> if <b>-t</b> was specified or did not support command line <i>file</i> arguments
   2857 with the <b>-t</b> option. For consistency and simplicity of specification, POSIX.1-2024 disallows these special cases, and
   2858 requires that recovery be attempted the first time each file is edited.</p>
   2859 <p class="tent">Historically, <a href="../utilities/vi.html"><i>vi</i></a> initialized the <b>`</b> and <b>'</b> marks, but
   2860 <i>ex</i> did not. This meant that if the first command in <i>ex</i> mode was <b>visual</b> or if an <i>ex</i> command was executed
   2861 first (for example, <a href="../utilities/vi.html"><i>vi</i></a> +10 <i>file</i>), <a href="../utilities/vi.html"><i>vi</i></a> was
   2862 entered without the marks being initialized. Because the standard developers believed the marks to be generally useful, and for
   2863 consistency and simplicity of specification, POSIX.1-2024 requires that they always be initialized if in open or visual mode, or if
   2864 in <i>ex</i> mode and the edit buffer is not empty. Not initializing it in <i>ex</i> mode if the edit buffer is empty is historical
   2865 practice; however, it has always been possible to set (and use) marks in empty edit buffers in open and visual mode edit
   2866 sessions.</p>
   2867 <h5><a name="tag_20_40_18_07" id="tag_20_40_18_07"></a>Addressing</h5>
   2868 <p class="tent">Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> accepted the additional addressing forms
   2869 <tt>'\/'</tt> and <tt>'\?'</tt>. They were equivalent to <tt>"//"</tt> and <tt>"??"</tt>, respectively. They are not required by
   2870 POSIX.1-2024, mostly because nobody can remember whether they ever did anything different historically.</p>
   2871 <p class="tent">Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> permitted an address of zero for several
   2872 commands, and permitted the <b>%</b> address in empty files for others. For consistency, POSIX.1-2024 requires support for the
   2873 former in the few commands where it makes sense, and disallows it otherwise. In addition, because POSIX.1-2024 requires that
   2874 <b>%</b> be logically equivalent to <tt>"1,$"</tt>, it is also supported where it makes sense and disallowed otherwise.</p>
   2875 <p class="tent">Historically, the <b>%</b> address could not be followed by further addresses. For consistency and simplicity of
   2876 specification, POSIX.1-2024 requires that additional addresses be supported.</p>
   2877 <p class="tent">All of the following are valid <i>addresses</i>:</p>
   2878 <dl compact>
   2879 <dd></dd>
   2880 <dt><tt>+++</tt></dt>
   2881 <dd>Three lines after the current line.</dd>
   2882 <dt><tt>/</tt><i>re</i><tt>/-</tt></dt>
   2883 <dd>One line before the next occurrence of <i>re</i>.</dd>
   2884 <dt><tt>-2</tt></dt>
   2885 <dd>Two lines before the current line.</dd>
   2886 <dt><tt>3&nbsp;----&nbsp;2</tt></dt>
   2887 <dd>Line one (note intermediate negative address).</dd>
   2888 <dt><tt>1&nbsp;2&nbsp;3</tt></dt>
   2889 <dd>Line six.</dd>
   2890 </dl>
   2891 <p class="tent">Any number of addresses can be provided to commands taking addresses; for example, <tt>"1,2,3,4,5p"</tt> prints
   2892 lines 4 and 5, because two is the greatest valid number of addresses accepted by the <b>print</b> command. This, in combination
   2893 with the &lt;semicolon&gt; delimiter, permits users to create commands based on ordered patterns in the file. For example, the
   2894 command <b>3;/foo/;+2print</b> will display the first line after line 3 that contains the pattern <i>foo</i>, plus the next two
   2895 lines. Note that the address <b>3;</b> must be evaluated before being discarded because the search origin for the <b>/foo/</b>
   2896 command depends on this.</p>
   2897 <p class="tent">Historically, values could be added to addresses by including them after one or more &lt;blank&gt; characters; for
   2898 example, <b>3&nbsp;-&nbsp;5p</b> wrote the seventh line of the file, and <b>/foo/&nbsp;5</b> was the same as <b>/foo/+5</b>.
   2899 However, only absolute values could be added; for example, <b>5&nbsp;/foo/</b> was an error. POSIX.1-2024 requires conformance to
   2900 historical practice. Address offsets are separately specified from addresses because they could historically be provided to visual
   2901 mode search commands.</p>
   2902 <p class="tent">Historically, any missing addresses defaulted to the current line. This was true for leading and trailing
   2903 &lt;comma&gt;-delimited addresses, and for trailing &lt;semicolon&gt;-delimited addresses. For consistency, POSIX.1-2024 requires
   2904 it for leading &lt;semicolon&gt; addresses as well.</p>
   2905 <p class="tent">Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> accepted the <tt>'^'</tt> character as
   2906 both an address and as a flag offset for commands. In both cases it was identical to the <tt>'-'</tt> character. POSIX.1-2024 does
   2907 not require or prohibit this behavior.</p>
   2908 <p class="tent">Historically, the enhancements to basic regular expressions could be used in addressing; for example, <tt>'~'</tt>,
   2909 <tt>'\&lt;'</tt>, and <tt>'\&gt;'</tt>. POSIX.1-2024 requires conformance to historical practice; that is, that regular expression
   2910 usage be consistent, and that regular expression enhancements be supported wherever regular expressions are used.</p>
   2911 <h5><a name="tag_20_40_18_08" id="tag_20_40_18_08"></a>Command Line Parsing in ex</h5>
   2912 <p class="tent">Historical <i>ex</i> command parsing was even more complex than that described here. POSIX.1-2024 requires the
   2913 subset of the command parsing that the standard developers believed was documented and that users could reasonably be expected to
   2914 use in a portable fashion, and that was historically consistent between implementations. (The discarded functionality is obscure,
   2915 at best.) Historical implementations will require changes in order to comply with POSIX.1-2024; however, users are not expected to
   2916 notice any of these changes. Most of the complexity in <i>ex</i> parsing is to handle three special termination cases:</p>
   2917 <ol>
   2918 <li class="tent">The <b>!</b>, <b>global</b>, <b>v</b>, and the filter versions of the <b>read</b> and <b>write</b> commands are
   2919 delimited by &lt;newline&gt; characters (they can contain &lt;vertical-line&gt; characters that are usually shell pipes).</li>
   2920 <li class="tent">The <b>ex</b>, <b>edit</b>, <b>next</b>, and <b>visual</b> in open and visual mode commands all take <i>ex</i>
   2921 commands, optionally containing &lt;vertical-line&gt; characters, as their first arguments.</li>
   2922 <li class="tent">The <b>s</b> command takes a regular expression as its first argument, and uses the delimiting characters to
   2923 delimit the command.</li>
   2924 </ol>
   2925 <p class="tent">Historically, &lt;vertical-line&gt; characters in the <b>+</b><i>command</i> argument of the <b>ex</b>,
   2926 <b>edit</b>, <b>next</b>, <b>vi</b>, and <b>visual</b> commands, and in the <i>pattern</i> and <i>replacement</i> parts of the
   2927 <b>s</b> command, did not delimit the command, and in the filter cases for <b>read</b> and <b>write</b>, and the <b>!</b>,
   2928 <b>global</b>, and <b>v</b> commands, they did not delimit the command at all. For example, the following commands are all
   2929 valid:</p>
   2930 <pre>
   2931 <b>:</b><tt>edit +25 | s/abc/ABC/ file.c
   2932 </tt><b>:</b><tt>s/ | /PIPE/
   2933 </tt><b>:</b><tt>read !spell % | columnate
   2934 </tt><b>:</b><tt>global/pattern/p | l
   2935 </tt><b>:</b><tt>s/a/b/ | s/c/d | set
   2936 </tt></pre>
   2937 <p class="tent">Historically, empty or &lt;blank&gt; filled lines in <b>.exrc</b> files and <b>source</b>d files (as well as
   2938 <i>EXINIT</i> variables and <i>ex</i> command scripts) were treated as default commands; that is, <b>print</b> commands.
   2939 POSIX.1-2024 specifically requires that they be ignored when encountered in <b>.exrc</b> and <b>source</b>d files to eliminate a
   2940 common source of new user error.</p>
   2941 <p class="tent">Historically, <i>ex</i> commands with multiple adjacent (or &lt;blank&gt;-separated) vertical lines were handled
   2942 oddly when executed from <i>ex</i> mode. For example, the command <b>|||</b> &lt;carriage-return&gt;, when the cursor was on line
   2943 1, displayed lines 2, 3, and 5 of the file. In addition, the command <b>|</b> would only display the line after the next line,
   2944 instead of the next two lines. The former worked more logically when executed from <a href="../utilities/vi.html"><i>vi</i></a>
   2945 mode, and displayed lines 2, 3, and 4. POSIX.1-2024 requires the <a href="../utilities/vi.html"><i>vi</i></a> behavior; that is, a
   2946 single default command and line number increment for each command separator, and trailing &lt;newline&gt; characters after
   2947 &lt;vertical-line&gt; separators are discarded.</p>
   2948 <p class="tent">Historically, <i>ex</i> permitted a single extra &lt;colon&gt; as a leading command character; for example,
   2949 <b>:g/pattern/:p</b> was a valid command. POSIX.1-2024 generalizes this to require that any number of leading &lt;colon&gt;
   2950 characters be stripped.</p>
   2951 <p class="tent">Historically, any prefix of the <b>delete</b> command could be followed without intervening &lt;blank&gt;
   2952 characters by a flag character because in the command <b>d&nbsp;p</b>, <i>p</i> is interpreted as the buffer <i>p</i>. POSIX.1-2024
   2953 requires conformance to historical practice.</p>
   2954 <p class="tent">Historically, the <b>k</b> command could be followed by the mark name without intervening &lt;blank&gt; characters.
   2955 POSIX.1-2024 requires conformance to historical practice.</p>
   2956 <p class="tent">Historically, the <b>s</b> command could be immediately followed by flag and option characters; for example,
   2957 <b>s/e/E/|s|sgc3p</b> was a valid command. However, flag characters could not stand alone; for example, the commands <b>sp</b> and
   2958 <b>s&nbsp;l</b> would fail, while the command <b>sgp</b> and <b>s&nbsp;gl</b> would succeed. (Obviously, the <tt>'#'</tt> flag
   2959 character was used as a delimiter character if it followed the command.) Another issue was that option characters had to precede
   2960 flag characters even when the command was fully specified; for example, the command <b>s/e/E/pg</b> would fail, while the command
   2961 <b>s/e/E/gp</b> would succeed. POSIX.1-2024 requires conformance to historical practice.</p>
   2962 <p class="tent">Historically, the first command name that had a prefix matching the input from the user was the executed command;
   2963 for example, <b>ve</b>, <b>ver</b>, and <b>vers</b> all executed the <b>version</b> command. Commands were in a specific order,
   2964 however, so that <b>a</b> matched <b>append</b>, not <b>abbreviate</b>. POSIX.1-2024 requires conformance to historical practice.
   2965 The restriction on command search order for implementations with extensions is to avoid the addition of commands such that the
   2966 historical prefixes would fail to work portably.</p>
   2967 <p class="tent">Historical implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> did not correctly handle
   2968 multiple <i>ex</i> commands, separated by &lt;vertical-line&gt; characters, that entered or exited visual mode or the editor.
   2969 Because implementations of <a href="../utilities/vi.html"><i>vi</i></a> exist that do not exhibit this failure mode, POSIX.1-2024
   2970 does not permit it.</p>
   2971 <p class="tent">The requirement that alphabetic command names consist of all following alphabetic characters up to the next
   2972 non-alphabetic character means that alphabetic command names must be separated from their arguments by one or more non-alphabetic
   2973 characters, normally a &lt;blank&gt; or <tt>'!'</tt> character, except as specified for the exceptions, the <b>delete</b>,
   2974 <b>k</b>, and <b>s</b> commands.</p>
   2975 <p class="tent">Historically, the repeated execution of the <i>ex</i> default <b>print</b> commands (&lt;control&gt;-D, <i>eof</i>,
   2976 &lt;newline&gt;, &lt;carriage-return&gt;) erased any prompting character and displayed the next lines without scrolling the
   2977 terminal; that is, immediately below any previously displayed lines. This provided a cleaner presentation of the lines in the file
   2978 for the user. POSIX.1-2024 does not require this behavior because it may be impossible in some situations; however, implementations
   2979 are strongly encouraged to provide this semantic if possible.</p>
   2980 <p class="tent">Historically, it was possible to change files in the middle of a command, and have the rest of the command executed
   2981 in the new file; for example:</p>
   2982 <pre>
   2983 <tt>:edit +25 file.c | s/abc/ABC/ | 1
   2984 </tt></pre>
   2985 <p class="tent">was a valid command, and the substitution was attempted in the newly edited file. POSIX.1-2024 requires conformance
   2986 to historical practice. The following commands are examples that exercise the <i>ex</i> parser:</p>
   2987 <pre>
   2988 <tt>echo 'foo | bar' &gt; file1; echo 'foo/bar' &gt; file2;
   2989 vi
   2990 :edit +1 | s/|/PIPE/ | w file1 | e file2 | 1 | s/\//SLASH/ | wq
   2991 </tt></pre>
   2992 <p class="tent">Historically, there was no protection in editor implementations to avoid <i>ex</i> <b>global</b>, <b>v</b>,
   2993 <b>@</b>, or <b>*</b> commands changing edit buffers during execution of their associated commands. Because this would almost
   2994 invariably result in catastrophic failure of the editor, and implementations exist that do exhibit these problems, POSIX.1-2024
   2995 requires that changing the edit buffer during a <b>global</b> or <b>v</b> command, or during a <b>@</b> or <b>*</b> command for
   2996 which there will be more than a single execution, be an error. Implementations supporting multiple edit buffers simultaneously are
   2997 strongly encouraged to apply the same semantics to switching between buffers as well.</p>
   2998 <p class="tent">The <i>ex</i> command quoting required by POSIX.1-2024 is a superset of the quoting in historical implementations
   2999 of the editor. For example, it was not historically possible to escape a &lt;blank&gt; in a filename; for example,
   3000 <b>:edit&nbsp;foo\\\&nbsp;bar</b> would report that too many filenames had been entered for the edit command, and there was no
   3001 method of escaping a &lt;blank&gt; in the first argument of an <b>edit</b>, <b>ex</b>, <b>next</b>, or <b>visual</b> command at
   3002 all. POSIX.1-2024 extends historical practice, requiring that quoting behavior be made consistent across all <i>ex</i> commands,
   3003 except for the <b>map</b>, <b>unmap</b>, <b>abbreviate</b>, and <b>unabbreviate</b> commands, which historically used
   3004 &lt;control&gt;-V instead of &lt;backslash&gt; characters for quoting. For those four commands, POSIX.1-2024 requires conformance
   3005 to historical practice.</p>
   3006 <p class="tent">Backslash quoting in <i>ex</i> is non-intuitive. &lt;backslash&gt;-escapes are ignored unless they escape a special
   3007 character; for example, when performing <i>file</i> argument expansion, the string <tt>"\\%"</tt> is equivalent to <tt>'\%'</tt>,
   3008 not <tt>"\&lt;</tt><i>current&nbsp;pathname</i><tt>&gt;"</tt>. This can be confusing for users because &lt;backslash&gt; is usually
   3009 one of the characters that causes shell expansion to be performed, and therefore shell quoting rules must be taken into
   3010 consideration. Generally, quoting characters are only considered if they escape a special character, and a quoting character must
   3011 be provided for each layer of parsing for which the character is special. As another example, only a single &lt;backslash&gt; is
   3012 necessary for the <tt>'\l'</tt> sequence in substitute replacement patterns, because the character <tt>'l'</tt> is not special to
   3013 any parsing layer above it.</p>
   3014 <p class="tent">&lt;control&gt;-V quoting in <i>ex</i> is slightly different from backslash quoting. In the four commands where
   3015 &lt;control&gt;-V quoting applies (<b>abbreviate</b>, <b>unabbreviate</b>, <b>map</b>, and <b>unmap</b>), any character may be
   3016 escaped by a &lt;control&gt;-V whether it would have a special meaning or not. POSIX.1-2024 requires conformance to historical
   3017 practice.</p>
   3018 <p class="tent">Historical implementations of the editor did not require delimiters within character classes to be escaped; for
   3019 example, the command <b>:s/[/]//</b> on the string <tt>"xxx/yyy"</tt> would delete the <tt>'/'</tt> from the string. POSIX.1-2024
   3020 disallows this historical practice for consistency and because it places a large burden on implementations by requiring that
   3021 knowledge of regular expressions be built into the editor parser.</p>
   3022 <p class="tent">Historically, quoting &lt;newline&gt; characters in <i>ex</i> commands was handled inconsistently. In most cases,
   3023 the &lt;newline&gt; character always terminated the command, regardless of any preceding escape character, because
   3024 &lt;backslash&gt; characters did not escape &lt;newline&gt; characters for most <i>ex</i> commands. However, some <i>ex</i>
   3025 commands (for example, <b>s</b>, <b>map</b>, and <b>abbreviation</b>) permitted &lt;newline&gt; characters to be escaped (although
   3026 in the case of <b>map</b> and <b>abbreviation</b>, &lt;control&gt;-V characters escaped them instead of &lt;backslash&gt;
   3027 characters). This was true in not only the command line, but also <b>.exrc</b> and <b>source</b>d files. For example, the
   3028 command:</p>
   3029 <pre>
   3030 <tt>map = foo&lt;control-V&gt;&lt;newline&gt;bar
   3031 </tt></pre>
   3032 <p class="tent">would succeed, although it was sometimes difficult to get the &lt;control&gt;-V and the inserted &lt;newline&gt;
   3033 passed to the <i>ex</i> parser. For consistency and simplicity of specification, POSIX.1-2024 requires that it be possible to
   3034 escape &lt;newline&gt; characters in <i>ex</i> commands at all times, using &lt;backslash&gt; characters for most <i>ex</i>
   3035 commands, and using &lt;control&gt;-V characters for the <b>map</b> and <b>abbreviation</b> commands. For example, the command
   3036 <b>print</b>&lt;newline&gt;<b>list</b> is required to be parsed as the single command <b>print</b>&lt;newline&gt;<b>list</b>. While
   3037 this differs from historical practice, POSIX.1-2024 developers believed it unlikely that any script or user depended on the
   3038 historical behavior.</p>
   3039 <p class="tent">Historically, an error in a command specified using the <b>-c</b> option did not cause the rest of the <b>-c</b>
   3040 commands to be discarded. POSIX.1-2024 disallows this for consistency with mapped keys, the <b>@</b>, <b>global</b>, <b>source</b>,
   3041 and <b>v</b> commands, the <i>EXINIT</i> environment variable, and the <b>.exrc</b> files.</p>
   3042 <h5><a name="tag_20_40_18_09" id="tag_20_40_18_09"></a>Input Editing in ex</h5>
   3043 <p class="tent">One of the common uses of the historical <i>ex</i> editor is over slow network connections. Editors that run in
   3044 canonical mode can require far less traffic to and from, and far less processing on, the host machine, as well as more easily
   3045 supporting block-mode terminals. For these reasons, POSIX.1-2024 requires that <i>ex</i> be implemented using canonical mode input
   3046 processing, as was done historically.</p>
   3047 <p class="tent">POSIX.1-2024 does not require the historical 4 BSD input editing characters &quot;word erase&quot; or &quot;literal next&quot;. For
   3048 this reason, it is unspecified how they are handled by <i>ex</i>, although they must have the required effect. Implementations that
   3049 resolve them after the line has been ended using a &lt;newline&gt; or &lt;control&gt;-M character, and implementations that rely on
   3050 the underlying system terminal support for this processing, are both conforming. Implementations are strongly urged to use the
   3051 underlying system functionality, if at all possible, for compatibility with other system text input interfaces.</p>
   3052 <p class="tent">Historically, when the <i>eof</i> character was used to decrement the <b>autoindent</b> level, the cursor moved to
   3053 display the new end of the <b>autoindent</b> characters, but did not move the cursor to a new line, nor did it erase the
   3054 &lt;control&gt;-D character from the line. POSIX.1-2024 does not specify that the cursor remain on the same line or that the rest
   3055 of the line is erased; however, implementations are strongly encouraged to provide the best possible user interface; that is, the
   3056 cursor should remain on the same line, and any &lt;control&gt;-D character on the line should be erased.</p>
   3057 <p class="tent">POSIX.1-2024 does not require the historical 4 BSD input editing character &quot;reprint&quot;, traditionally
   3058 &lt;control&gt;-R, which redisplayed the current input from the user. For this reason, and because the functionality cannot be
   3059 implemented after the line has been terminated by the user, POSIX.1-2024 makes no requirements about this functionality.
   3060 Implementations are strongly urged to make this historical functionality available, if possible.</p>
   3061 <p class="tent">Historically, &lt;control&gt;-Q did not perform a literal next function in <i>ex</i>, as it did in <a href=
   3062 "../utilities/vi.html"><i>vi</i></a>. POSIX.1-2024 requires conformance to historical practice to avoid breaking historical
   3063 <i>ex</i> scripts and <b>.exrc</b> files.</p>
   3064 <h5><a name="tag_20_40_18_10" id="tag_20_40_18_10"></a>eof</h5>
   3065 <p class="tent">Whether the <i>eof</i> character immediately modifies the <b>autoindent</b> characters in the prompt is left
   3066 unspecified so that implementations can conform in the presence of systems that do not support this functionality. Implementations
   3067 are encouraged to modify the line and redisplay it immediately, if possible.</p>
   3068 <p class="tent">The specification of the handling of the <i>eof</i> character differs from historical practice only in that
   3069 <i>eof</i> characters are not discarded if they follow normal characters in the text input. Historically, they were always
   3070 discarded.</p>
   3071 <h5><a name="tag_20_40_18_11" id="tag_20_40_18_11"></a>Command Descriptions in ex</h5>
   3072 <p class="tent">Historically, several commands (for example, <b>global</b>, <b>v</b>, <b>visual</b>, <b>s</b>, <b>write</b>,
   3073 <b>wq</b>, <b>yank</b>, <b>!</b>, <b>&lt;</b>, <b>&gt;</b>, <b>&</b>, and <b>~</b>) were executable in empty files (that is, the
   3074 default address(es) were 0), or permitted explicit addresses of 0 (for example, 0 was a valid address, or 0,0 was a valid range).
   3075 Addresses of 0, or command execution in an empty file, make sense only for commands that add new text to the edit buffer or write
   3076 commands (because users may wish to write empty files). POSIX.1-2024 requires this behavior for such commands and disallows it
   3077 otherwise, for consistency and simplicity of specification.</p>
   3078 <p class="tent">A count to an <i>ex</i> command has been historically corrected to be no greater than the last line in a file; for
   3079 example, in a five-line file, the command <b>1,6print</b> would fail, but the command <b>1print300</b> would succeed. POSIX.1-2024
   3080 requires conformance to historical practice.</p>
   3081 <p class="tent">Historically, the use of flags in <i>ex</i> commands could be obscure. General historical practice was as described
   3082 by POSIX.1-2024, but there were some special cases. For instance, the <b>list</b>, <b>number</b>, and <b>print</b> commands ignored
   3083 trailing address offsets; for example, <b>3p&nbsp;+++#</b> would display line 3, and 3 would be the current line after the
   3084 execution of the command. The <b>open</b> and <b>visual</b> commands ignored both the trailing offsets and the trailing flags.
   3085 Also, flags specified to the <b>open</b> and <b>visual</b> commands interacted badly with the <b>list</b> edit option, and setting
   3086 and then unsetting it during the open/visual session would cause <a href="../utilities/vi.html"><i>vi</i></a> to stop displaying
   3087 lines in the specified format. For consistency and simplicity of specification, POSIX.1-2024 does not permit any of these
   3088 exceptions to the general rule.</p>
   3089 <p class="tent">POSIX.1-2024 uses the word <i>copy</i> in several places when discussing buffers. This is not intended to imply
   3090 implementation.</p>
   3091 <p class="tent">Historically, <i>ex</i> users could not specify numeric buffers because of the ambiguity this would cause; for
   3092 example, in the command <b>3&nbsp;delete&nbsp;2</b>, it is unclear whether 2 is a buffer name or a <i>count</i>. POSIX.1-2024
   3093 requires conformance to historical practice by default, but does not preclude extensions.</p>
   3094 <p class="tent">Historically, the contents of the unnamed buffer were frequently discarded after commands that did not explicitly
   3095 affect it; for example, when using the <b>edit</b> command to switch files. For consistency and simplicity of specification,
   3096 POSIX.1-2024 does not permit this behavior.</p>
   3097 <p class="tent">The <i>ex</i> utility did not historically have access to the numeric buffers, and, furthermore, deleting lines in
   3098 <i>ex</i> did not modify their contents. For example, if, after doing a delete in <a href="../utilities/vi.html"><i>vi</i></a>, the
   3099 user switched to <i>ex</i>, did another delete, and then switched back to <a href="../utilities/vi.html"><i>vi</i></a>, the
   3100 contents of the numeric buffers would not have changed. POSIX.1-2024 requires conformance to historical practice. Numeric buffers
   3101 are described in the <i>ex</i> utility in order to confine the description of buffers to a single location in POSIX.1-2024.</p>
   3102 <p class="tent">The metacharacters that trigger shell expansion in <i>file</i> arguments match historical practice, as does the
   3103 method for doing shell expansion. Implementations wishing to provide users with the flexibility to alter the set of metacharacters
   3104 are encouraged to provide a <b>shellmeta</b> string edit option.</p>
   3105 <p class="tent">Historically, <i>ex</i> commands executed from <a href="../utilities/vi.html"><i>vi</i></a> refreshed the screen
   3106 when it did not strictly need to do so; for example, <b>:!date&nbsp;&gt;&nbsp;/dev/null</b> does not require a screen refresh
   3107 because the output of the UNIX <a href="../utilities/date.html"><i>date</i></a> command requires only a single line of the screen.
   3108 POSIX.1-2024 requires that the screen be refreshed if it has been overwritten, but makes no requirements as to how an
   3109 implementation should make that determination. Implementations may prompt and refresh the screen regardless.</p>
   3110 <h5><a name="tag_20_40_18_12" id="tag_20_40_18_12"></a>Abbreviate</h5>
   3111 <p class="tent">Historical practice was that characters that were entered as part of an abbreviation replacement were subject to
   3112 <b>map</b> expansions, the <b>showmatch</b> edit option, further abbreviation expansions, and so on; that is, they were logically
   3113 pushed onto the terminal input queue, and were not a simple replacement. POSIX.1-2024 requires conformance to historical practice.
   3114 Historical practice was that whenever a non-word character (that had not been escaped by a &lt;control&gt;-V) was entered after a
   3115 word character, <a href="../utilities/vi.html"><i>vi</i></a> would check for abbreviations. The check was based on the type of the
   3116 character entered before the word character of the word/non-word pair that triggered the check. The word character of the
   3117 word/non-word pair that triggered the check and all characters entered before the trigger pair that were of that type were included
   3118 in the check, with the exception of &lt;blank&gt; characters, which always delimited the abbreviation.</p>
   3119 <p class="tent">This means that, for the abbreviation to work, the <i>lhs</i> must end with a word character, there can be no
   3120 transitions from word to non-word characters (or <i>vice versa</i>) other than between the last and next-to-last characters in the
   3121 <i>lhs</i>, and there can be no &lt;blank&gt; characters in the <i>lhs</i>. In addition, because of the historical quoting rules,
   3122 it was impossible to enter a literal &lt;control&gt;-V in the <i>lhs</i>. POSIX.1-2024 requires conformance to historical practice.
   3123 Historical implementations did not inform users when abbreviations that could never be used were entered; implementations are
   3124 strongly encouraged to do so.<br></p>
   3125 <p class="tent">For example, the following abbreviations will work:</p>
   3126 <pre>
   3127 <tt>:ab (p  REPLACE
   3128 :ab p   REPLACE
   3129 :ab ((p REPLACE
   3130 </tt></pre>
   3131 <p class="tent">The following abbreviations will not work:</p>
   3132 <pre>
   3133 <tt>:ab (   REPLACE
   3134 :ab (pp REPLACE
   3135 </tt></pre>
   3136 <p class="tent">Historical practice is that words on the <a href="../utilities/vi.html"><i>vi</i></a> colon command line were
   3137 subject to abbreviation expansion, including the arguments to the <b>abbrev</b> (and more interestingly) the <b>unabbrev</b>
   3138 command. Because there are implementations that do not do abbreviation expansion for the first argument to those commands, this is
   3139 permitted, but not required, by POSIX.1-2024. However, the following sequence:</p>
   3140 <pre>
   3141 <tt>:ab foo bar
   3142 :ab foo baz
   3143 </tt></pre>
   3144 <p class="tent">resulted in the addition of an abbreviation of <tt>"baz"</tt> for the string <tt>"bar"</tt> in historical
   3145 <i>ex</i>/<a href="../utilities/vi.html"><i>vi</i></a>, and the sequence:</p>
   3146 <pre>
   3147 <tt>:ab foo1 bar
   3148 :ab foo2 bar
   3149 :unabbreviate foo2
   3150 </tt></pre>
   3151 <p class="tent">deleted the abbreviation <tt>"foo1"</tt>, not <tt>"foo2"</tt>. These behaviors are not permitted by POSIX.1-2024
   3152 because they clearly violate the expectations of the user.</p>
   3153 <p class="tent">It was historical practice that &lt;control&gt;-V, not &lt;backslash&gt;, characters be interpreted as escaping
   3154 subsequent characters in the <b>abbreviate</b> command. POSIX.1-2024 requires conformance to historical practice; however, it
   3155 should be noted that an abbreviation containing a &lt;blank&gt; will never work.</p>
   3156 <h5><a name="tag_20_40_18_13" id="tag_20_40_18_13"></a>Append</h5>
   3157 <p class="tent">Historically, any text following a &lt;vertical-line&gt; command separator after an <b>append</b>, <b>change</b>,
   3158 or <b>insert</b> command became part of the insert text. For example, in the command:</p>
   3159 <pre>
   3160 <tt>:g/pattern/append|stuff1
   3161 </tt></pre>
   3162 <p class="tent">a line containing the text <tt>"stuff1"</tt> would be appended to each line matching pattern. It was also
   3163 historically valid to enter:</p>
   3164 <pre>
   3165 <tt>:append|stuff1
   3166 stuff2
   3167 .
   3168 </tt></pre>
   3169 <p class="tent">and the text on the <i>ex</i> command line would be appended along with the text inserted after it. There was an
   3170 historical bug, however, that the user had to enter two terminating lines (the <tt>'.'</tt> lines) to terminate text input mode in
   3171 this case. POSIX.1-2024 requires conformance to historical practice, but disallows the historical need for multiple terminating
   3172 lines.</p>
   3173 <h5><a name="tag_20_40_18_14" id="tag_20_40_18_14"></a>Change</h5>
   3174 <p class="tent">See the RATIONALE for the <b>append</b> command. Historical practice for cursor positioning after the change
   3175 command when no text is input, is as described in POSIX.1-2024. However, one System V implementation is known to have been modified
   3176 such that the cursor is positioned on the first address specified, and not on the line before the first address. POSIX.1-2024
   3177 disallows this modification for consistency.</p>
   3178 <p class="tent">Historically, the <b>change</b> command did not support buffer arguments, although some implementations allow the
   3179 specification of an optional buffer. This behavior is neither required nor disallowed by POSIX.1-2024.</p>
   3180 <h5><a name="tag_20_40_18_15" id="tag_20_40_18_15"></a>Change Directory</h5>
   3181 <p class="tent">A common extension in <i>ex</i> implementations is to use the elements of a <b>cdpath</b> edit option as prefix
   3182 directories for <i>path</i> arguments to <b>chdir</b> that are relative pathnames and that do not have <tt>'.'</tt> or
   3183 <tt>".."</tt> as their first component. Elements in the <b>cdpath</b> edit option are &lt;colon&gt;-separated. The initial value of
   3184 the <b>cdpath</b> edit option is the value of the shell <i>CDPATH</i> environment variable. This feature was not included in
   3185 POSIX.1-2024 because it does not exist in any of the implementations considered historical practice.</p>
   3186 <h5><a name="tag_20_40_18_16" id="tag_20_40_18_16"></a>Copy</h5>
   3187 <p class="tent">Historical implementations of <i>ex</i> permitted copies to lines inside of the specified range; for example,
   3188 <b>:2,5copy3</b> was a valid command. POSIX.1-2024 requires conformance to historical practice.</p>
   3189 <h5><a name="tag_20_40_18_17" id="tag_20_40_18_17"></a>Delete</h5>
   3190 <p class="tent">POSIX.1-2024 requires support for the historical parsing of a <b>delete</b> command followed by flags, without any
   3191 intervening &lt;blank&gt; characters. For example:</p>
   3192 <dl compact>
   3193 <dd></dd>
   3194 <dt><b>1dp</b></dt>
   3195 <dd>Deletes the first line and prints the line that was second.</dd>
   3196 <dt><b>1delep</b></dt>
   3197 <dd>As for <b>1dp</b>.</dd>
   3198 <dt><b>1d</b></dt>
   3199 <dd>Deletes the first line, saving it in buffer <i>p</i>.</dd>
   3200 <dt><b>1d&nbsp;p1l</b></dt>
   3201 <dd>(Pee-one-ell.) Deletes the first line, saving it in buffer <i>p</i>, and listing the line that was second.</dd>
   3202 </dl>
   3203 <h5><a name="tag_20_40_18_18" id="tag_20_40_18_18"></a>Edit</h5>
   3204 <p class="tent">Historically, any <i>ex</i> command could be entered as a <b>+</b><i>command</i> argument to the <b>edit</b>
   3205 command, although some (for example, <b>insert</b> and <b>append</b>) were known to confuse historical implementations. For
   3206 consistency and simplicity of specification, POSIX.1-2024 requires that any command be supported as an argument to the <b>edit</b>
   3207 command.</p>
   3208 <p class="tent">Historically, the command argument was executed with the current line set to the last line of the file, regardless
   3209 of whether the <b>edit</b> command was executed from visual mode or not. POSIX.1-2024 requires conformance to historical
   3210 practice.</p>
   3211 <p class="tent">Historically, the <b>+</b><i>command</i> specified to the <b>edit</b> and <b>next</b> commands was delimited by the
   3212 first &lt;blank&gt;, and there was no way to quote them. For consistency, POSIX.1-2024 requires that the usual <i>ex</i> backslash
   3213 quoting be provided.</p>
   3214 <p class="tent">Historically, specifying the <b>+</b><i>command</i> argument to the edit command required a filename to be
   3215 specified as well; for example, <b>:edit&nbsp;+100</b> would always fail. For consistency and simplicity of specification,
   3216 POSIX.1-2024 does not permit this usage to fail for that reason.</p>
   3217 <p class="tent">Historically, only the cursor position of the last file edited was remembered by the editor. POSIX.1-2024 requires
   3218 that this be supported; however, implementations are permitted to remember and restore the cursor position for any file previously
   3219 edited.</p>
   3220 <h5><a name="tag_20_40_18_19" id="tag_20_40_18_19"></a>File</h5>
   3221 <p class="tent">Historical versions of the <i>ex</i> editor <b>file</b> command displayed a current line and number of lines in the
   3222 edit buffer of 0 when the file was empty, while the <a href="../utilities/vi.html"><i>vi</i></a> &lt;control&gt;-G command
   3223 displayed a current line and number of lines in the edit buffer of 1 in the same situation. POSIX.1-2024 does not permit this
   3224 discrepancy, instead requiring that a message be displayed indicating that the file is empty.</p>
   3225 <h5><a name="tag_20_40_18_20" id="tag_20_40_18_20"></a>Global</h5>
   3226 <p class="tent">The two-pass operation of the <b>global</b> and <b>v</b> commands is not intended to imply implementation, only the
   3227 required result of the operation.</p>
   3228 <p class="tent">The current line and column are set as specified for the individual <i>ex</i> commands. This requirement is
   3229 cumulative; that is, the current line and column must track across all the commands executed by the <b>global</b> or <b>v</b>
   3230 commands.</p>
   3231 <h5><a name="tag_20_40_18_21" id="tag_20_40_18_21"></a>Insert</h5>
   3232 <p class="tent">See the RATIONALE for the <b>append</b> command.</p>
   3233 <p class="tent">Historically, <b>insert</b> could not be used with an address of zero; that is, not when the edit buffer was empty.
   3234 POSIX.1-2024 requires that this command behave consistently with the <b>append</b> command.</p>
   3235 <h5><a name="tag_20_40_18_22" id="tag_20_40_18_22"></a>Join</h5>
   3236 <p class="tent">The action of the <b>join</b> command in relation to the special characters is only defined for the POSIX locale
   3237 because the correct amount of white space after a period varies; in Japanese none is required, in French only a single space, and
   3238 so on.</p>
   3239 <h5><a name="tag_20_40_18_23" id="tag_20_40_18_23"></a>List</h5>
   3240 <p class="tent">The historical output of the <b>list</b> command was potentially ambiguous. The standard developers believed
   3241 correcting this to be more important than adhering to historical practice, and POSIX.1-2024 requires unambiguous output.</p>
   3242 <h5><a name="tag_20_40_18_24" id="tag_20_40_18_24"></a>Map</h5>
   3243 <p class="tent">Historically, command mode maps only applied to command names; for example, if the character <tt>'x'</tt> was
   3244 mapped to <tt>'y'</tt>, the command <b>fx</b> searched for the <tt>'x'</tt> character, not the <tt>'y'</tt> character. POSIX.1-2024
   3245 requires this behavior. Historically, entering &lt;control&gt;-V as the first character of a <a href=
   3246 "../utilities/vi.html"><i>vi</i></a> command was an error. Several implementations have extended the semantics of <a href=
   3247 "../utilities/vi.html"><i>vi</i></a> such that &lt;control&gt;-V means that the subsequent command character is not mapped. This is
   3248 permitted, but not required, by POSIX.1-2024. Regardless, using &lt;control&gt;-V to escape the second or later character in a
   3249 sequence of characters that might match a <b>map</b> command, or any character in text input mode, is historical practice, and
   3250 stops the entered keys from matching a map. POSIX.1-2024 requires conformance to historical practice.</p>
   3251 <p class="tent">Historical implementations permitted digits to be used as a <b>map</b> command <i>lhs</i>, but then ignored the
   3252 map. POSIX.1-2024 requires that the mapped digits not be ignored.</p>
   3253 <p class="tent">The historical implementation of the <b>map</b> command did not permit <b>map</b> commands that were more than a
   3254 single character in length if the first character was printable. This behavior is permitted, but not required, by POSIX.1-2024.</p>
   3255 <p class="tent">Historically, mapped characters were remapped unless the <b>remap</b> edit option was not set, or the prefix of the
   3256 mapped characters matched the mapping characters; for example, in the <b>map</b>:</p>
   3257 <pre>
   3258 <tt>:map ab abcd
   3259 </tt></pre>
   3260 <p class="tent">the characters <tt>"ab"</tt> were used as is and were not remapped, but the characters <tt>"cd"</tt> were mapped if
   3261 appropriate. This can cause infinite loops in the <a href="../utilities/vi.html"><i>vi</i></a> mapping mechanisms. POSIX.1-2024
   3262 requires conformance to historical practice, and that such loops be interruptible.</p>
   3263 <p class="tent">Text input maps had the same problems with expanding the <i>lhs</i> for the <i>ex</i> <b>map!</b> and <b>unmap!</b>
   3264 command as did the <i>ex</i> <b>abbreviate</b> and <b>unabbreviate</b> commands. See the RATIONALE for the <i>ex</i>
   3265 <b>abbreviate</b> command. POSIX.1-2024 requires similar modification of some historical practice for the <b>map</b> and
   3266 <b>unmap</b> commands, as described for the <b>abbreviate</b> and <b>unabbreviate</b> commands.</p>
   3267 <p class="tent">Historically, <b>map</b>s that were subsets of other <b>map</b>s behaved differently depending on the order in
   3268 which they were defined. For example:</p>
   3269 <pre>
   3270 <tt>:map! ab     short
   3271 :map! abc    long
   3272 </tt></pre>
   3273 <p class="tent">would always translate the characters <tt>"ab"</tt> to <tt>"short"</tt>, regardless of how fast the characters
   3274 <tt>"abc"</tt> were entered. If the entry order was reversed:</p>
   3275 <pre>
   3276 <tt>:map! abc    long
   3277 :map! ab     short
   3278 </tt></pre>
   3279 <p class="tent">the characters <tt>"ab"</tt> would cause the editor to pause, waiting for the completing <tt>'c'</tt> character,
   3280 and the characters might never be mapped to <tt>"short"</tt>. For consistency and simplicity of specification, POSIX.1-2024
   3281 requires that the shortest match be used at all times.</p>
   3282 <p class="tent">The length of time the editor spends waiting for the characters to complete the <i>lhs</i> is unspecified because
   3283 the timing capabilities of systems are often inexact and variable, and it may depend on other factors such as the speed of the
   3284 connection. The time should be long enough for the user to be able to complete the sequence, but not long enough for the user to
   3285 have to wait. Some implementations of <a href="../utilities/vi.html"><i>vi</i></a> have added a <b>keytime</b> option, which
   3286 permits users to set the number of 0,1 seconds the editor waits for the completing characters. Because mapped terminal function and
   3287 cursor keys tend to start with an &lt;ESC&gt; character, and &lt;ESC&gt; is the key ending <a href=
   3288 "../utilities/vi.html"><i>vi</i></a> text input mode, <b>map</b>s starting with &lt;ESC&gt; characters are generally exempted from
   3289 this timeout period, or, at least timed out differently.</p>
   3290 <h5><a name="tag_20_40_18_25" id="tag_20_40_18_25"></a>Mark</h5>
   3291 <p class="tent">Historically, users were able to set the &quot;previous context&quot; marks explicitly. In addition, the <i>ex</i> commands
   3292 <tt>''</tt> and <tt>'`</tt> and the <a href="../utilities/vi.html"><i>vi</i></a> commands <tt>''</tt>, <tt>``</tt>, <tt>`'</tt>,
   3293 and <tt>'`</tt> all referred to the same mark. In addition, the previous context marks were not set if the command, with which the
   3294 address setting the mark was associated, failed. POSIX.1-2024 requires conformance to historical practice. Historically, if marked
   3295 lines were deleted, the mark was also deleted, but would reappear if the change was undone. POSIX.1-2024 requires conformance to
   3296 historical practice.</p>
   3297 <p class="tent">The description of the special events that set the <b>`</b> and <b>'</b> marks matches historical practice. For
   3298 example, historically the command <b>/a/,/b/</b> did not set the <b>`</b> and <b>'</b> marks, but the command <b>/a/,/b/delete</b>
   3299 did.</p>
   3300 <h5><a name="tag_20_40_18_26" id="tag_20_40_18_26"></a>Next</h5>
   3301 <p class="tent">Historically, any <i>ex</i> command could be entered as a <b>+</b><i>command</i> argument to the <b>next</b>
   3302 command, although some (for example, <b>insert</b> and <b>append</b>) were known to confuse historical implementations.
   3303 POSIX.1-2024 requires that any command be permitted and that it behave as specified. The <b>next</b> command can accept more than
   3304 one file, so usage such as:</p>
   3305 <pre>
   3306 <tt>next `ls [abc] `
   3307 </tt></pre>
   3308 <p class="tent">is valid; it need not be valid for the <b>edit</b> or <b>read</b> commands, for example, because they expect only
   3309 one filename.</p>
   3310 <p class="tent">Historically, the <b>next</b> command behaved differently from the <b>:rewind</b> command in that it ignored the
   3311 force flag if the <b>autowrite</b> flag was set. For consistency, POSIX.1-2024 does not permit this behavior.</p>
   3312 <p class="tent">Historically, the <b>next</b> command positioned the cursor as if the file had never been edited before,
   3313 regardless. POSIX.1-2024 does not permit this behavior, for consistency with the <b>edit</b> command.</p>
   3314 <p class="tent">Implementations wanting to provide a counterpart to the <b>next</b> command that edited the previous file have used
   3315 the command <b>prev[ious],</b> which takes no <i>file</i> argument. POSIX.1-2024 does not require this command.</p>
   3316 <h5><a name="tag_20_40_18_27" id="tag_20_40_18_27"></a>Open</h5>
   3317 <p class="tent">Historically, the <b>open</b> command would fail if the <b>open</b> edit option was not set. POSIX.1-2024 does not
   3318 mention the <b>open</b> edit option and does not require this behavior. Some historical implementations do not permit entering open
   3319 mode from open or visual mode, only from <i>ex</i> mode. For consistency, POSIX.1-2024 does not permit this behavior.</p>
   3320 <p class="tent">Historically, entering open mode from the command line (that is, <a href="../utilities/vi.html"><i>vi</i></a>
   3321 <b>+open</b>) resulted in anomalous behaviors; for example, the <i>ex</i> file and <a href=
   3322 "../utilities/V3_chap02.html#set"><i>set</i></a> commands, and the <a href="../utilities/vi.html"><i>vi</i></a> command
   3323 &lt;control&gt;-G did not work. For consistency, POSIX.1-2024 does not permit this behavior.</p>
   3324 <p class="tent">Historically, the <b>open</b> command only permitted <tt>'/'</tt> characters to be used as the search pattern
   3325 delimiter. For consistency, POSIX.1-2024 requires that the search delimiters used by the <b>s</b>, <b>global</b>, and <b>v</b>
   3326 commands be accepted as well.</p>
   3327 <h5><a name="tag_20_40_18_28" id="tag_20_40_18_28"></a>Preserve</h5>
   3328 <p class="tent">The <b>preserve</b> command does not historically cause the file to be considered unmodified for the purposes of
   3329 future commands that may exit the editor. POSIX.1-2024 requires conformance to historical practice.</p>
   3330 <p class="tent">Historical documentation stated that mail was not sent to the user when preserve was executed; however, historical
   3331 implementations did send mail in this case. POSIX.1-2024 requires conformance to the historical implementations.</p>
   3332 <h5><a name="tag_20_40_18_29" id="tag_20_40_18_29"></a>Print</h5>
   3333 <p class="tent">The writing of NUL by the <b>print</b> command is not specified as a special case because the standard developers
   3334 did not want to require <i>ex</i> to support NUL characters. Historically, characters were displayed using the ARPA standard
   3335 mappings, which are as follows:</p>
   3336 <ol>
   3337 <li class="tent">Printable characters are left alone.</li>
   3338 <li class="tent">Control characters less than \177 are represented as <tt>'^'</tt> followed by the character offset from the
   3339 <tt>'@'</tt> character in the ASCII map; for example, \007 is represented as <tt>'^G'</tt>.</li>
   3340 <li class="tent">\177 is represented as <tt>'^'</tt> followed by <tt>'?'</tt>.</li>
   3341 </ol>
   3342 <p class="tent">The display of characters having their eighth bit set was less standard. Existing implementations use hex (0x00),
   3343 octal (\000), and a meta-bit display. (The latter displayed bytes that had their eighth bit set as the two characters <tt>"M-"</tt>
   3344 followed by the seven-bit display as described above.) The latter probably has the best claim to historical practice because it was
   3345 used for the <b>-v</b> option of 4 BSD and 4 BSD-derived versions of the <a href="../utilities/cat.html"><i>cat</i></a> utility
   3346 since 1980.</p>
   3347 <p class="tent">No specific display format is required by POSIX.1-2024.</p>
   3348 <p class="tent">Explicit dependence on the ASCII character set has been avoided where possible, hence the use of the phrase an
   3349 &quot;implementation-defined multi-character sequence&quot; for the display of non-printable characters in preference to the historical
   3350 usage of, for instance, <tt>"^I"</tt> for the &lt;tab&gt;. Implementations are encouraged to conform to historical practice in the
   3351 absence of any strong reason to diverge.</p>
   3352 <p class="tent">Historically, all <i>ex</i> commands beginning with the letter <tt>'p'</tt> could be entered using capitalized
   3353 versions of the commands; for example, <b>P[rint]</b>, <b>Pre[serve]</b>, and <b>Pu[t]</b> were all valid command names.
   3354 POSIX.1-2024 permits, but does not require, this historical practice because capital forms of the commands are used by some
   3355 implementations for other purposes.</p>
   3356 <h5><a name="tag_20_40_18_30" id="tag_20_40_18_30"></a>Put</h5>
   3357 <p class="tent">Historically, an <i>ex</i> <b>put</b> command, executed from open or visual mode, was the same as the open or
   3358 visual mode <b>P</b> command, if the buffer was named and was cut in character mode, and the same as the <b>p</b> command if the
   3359 buffer was named and cut in line mode. If the unnamed buffer was the source of the text, the entire line from which the text was
   3360 taken was usually <b>put</b>, and the buffer was handled as if in line mode, but it was possible to get extremely anomalous
   3361 behavior. In addition, using the <b>Q</b> command to switch into <i>ex</i> mode, and then doing a <b>put</b> often resulted in
   3362 errors as well, such as appending text that was unrelated to the (supposed) contents of the buffer. For consistency and simplicity
   3363 of specification, POSIX.1-2024 does not permit these behaviors. All <i>ex</i> <b>put</b> commands are required to operate in line
   3364 mode, and the contents of the buffers are not altered by changing the mode of the editor.</p>
   3365 <h5><a name="tag_20_40_18_31" id="tag_20_40_18_31"></a>Read</h5>
   3366 <p class="tent">Historically, an <i>ex</i> <b>read</b> command executed from open or visual mode, executed in an empty file, left
   3367 an empty line as the first line of the file. For consistency and simplicity of specification, POSIX.1-2024 does not permit this
   3368 behavior. Historically, a <b>read</b> in open or visual mode from a program left the cursor at the last line read in, not the
   3369 first. For consistency, POSIX.1-2024 does not permit this behavior.</p>
   3370 <p class="tent">Historical implementations of <i>ex</i> were unable to undo <b>read</b> commands that read from the output of a
   3371 program. For consistency, POSIX.1-2024 does not permit this behavior.</p>
   3372 <p class="tent">Historically, the <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> message after a successful <b>read</b>
   3373 or <b>write</b> command specified &quot;characters&quot;, not &quot;bytes&quot;. POSIX.1-2024 requires that the number of bytes be displayed, not
   3374 the number of characters, because it may be difficult in multi-byte implementations to determine the number of characters read.
   3375 Implementations are encouraged to clarify the message displayed to the user.</p>
   3376 <p class="tent">Historically, reads were not permitted on files other than type regular, except that FIFO files could be read
   3377 (probably only because they did not exist when <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> were originally written).
   3378 Because the historical <i>ex</i> evaluated <b>read!</b> and <b>read&nbsp;!</b> equivalently, there can be no optional way to force
   3379 the read. POSIX.1-2024 permits, but does not require, this behavior.</p>
   3380 <h5><a name="tag_20_40_18_32" id="tag_20_40_18_32"></a>Recover</h5>
   3381 <p class="tent">Some historical implementations of the editor permitted users to recover the edit buffer contents from a previous
   3382 edit session, and then exit without saving those contents (or explicitly discarding them). The intent of POSIX.1-2024 in requiring
   3383 that the edit buffer be treated as already modified is to prevent this user error.</p>
   3384 <h5><a name="tag_20_40_18_33" id="tag_20_40_18_33"></a>Rewind</h5>
   3385 <p class="tent">Historical implementations supported the <b>rewind</b> command when the user was editing the first file in the
   3386 list; that is, the file that the <b>rewind</b> command would edit. POSIX.1-2024 requires conformance to historical practice.</p>
   3387 <h5><a name="tag_20_40_18_34" id="tag_20_40_18_34"></a>Substitute</h5>
   3388 <p class="tent">Historically, <i>ex</i> accepted an <b>r</b> option to the <b>s</b> command. The effect of the <b>r</b> option was
   3389 to use the last regular expression used in any command as the pattern, the same as the <b>~</b> command. The <b>r</b> option is not
   3390 required by POSIX.1-2024. Historically, the <b>c</b> and <b>g</b> options were toggled; for example, the command <b>:s/abc/def/</b>
   3391 was the same as <b>s/abc/def/ccccgggg</b>. For simplicity of specification, POSIX.1-2024 does not permit this behavior.</p>
   3392 <p class="tent">The tilde command is often used to replace the last search RE. For example, in the sequence:</p>
   3393 <pre>
   3394 <tt>s/red/blue/
   3395 /green
   3396 ~
   3397 </tt></pre>
   3398 <p class="tent">the <b>~</b> command is equivalent to:</p>
   3399 <pre>
   3400 <tt>s/green/blue/
   3401 </tt></pre>
   3402 <p class="tent">Historically, <i>ex</i> accepted all of the following forms:</p>
   3403 <pre>
   3404 <tt>s/abc/def/
   3405 s/abc/def
   3406 s/abc/
   3407 s/abc
   3408 </tt></pre>
   3409 <p class="tent">POSIX.1-2024 requires conformance to this historical practice.</p>
   3410 <p class="tent">The <b>s</b> command presumes that the <tt>'^'</tt> character only occupies a single column in the display. Much of
   3411 the <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> specification presumes that the &lt;space&gt; only occupies a single
   3412 column in the display. There are no known character sets for which this is not true.</p>
   3413 <p class="tent">Historically, the final column position for the substitute commands was based on previous column movements; a
   3414 search for a pattern followed by a substitution would leave the column position unchanged, while a 0 command followed by a
   3415 substitution would change the column position to the first non-&lt;blank&gt;. For consistency and simplicity of specification,
   3416 POSIX.1-2024 requires that the final column position always be set to the first non-&lt;blank&gt;.</p>
   3417 <h5><a name="tag_20_40_18_35" id="tag_20_40_18_35"></a>Set</h5>
   3418 <p class="tent">Historical implementations redisplayed all of the options for each occurrence of the <b>all</b> keyword.
   3419 POSIX.1-2024 permits, but does not require, this behavior.</p>
   3420 <h5><a name="tag_20_40_18_36" id="tag_20_40_18_36"></a>Tag</h5>
   3421 <p class="tent">No requirement is made as to where <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> shall look for the
   3422 file referenced by the tag entry. Historical practice has been to look for the path found in the <b>tags</b> file, based on the
   3423 current directory. A useful extension found in some implementations is to look based on the directory containing the tags file that
   3424 held the entry, as well. No requirement is made as to which reference for the tag in the tags file is used. This is deliberate, in
   3425 order to permit extensions such as multiple entries in a tags file for a tag.</p>
   3426 <p class="tent">Because users often specify many different tags files, some of which need not be relevant or exist at any
   3427 particular time, POSIX.1-2024 requires that error messages about problem tags files be displayed only if the requested tag is not
   3428 found, and then, only once for each time that the <b>tag</b> edit option is changed.</p>
   3429 <p class="tent">The requirement that the current edit buffer be unmodified is only necessary if the file indicated by the tag entry
   3430 is not the same as the current file (as defined by the current pathname). Historically, the file would be reloaded if the filename
   3431 had changed, as well as if the filename was different from the current pathname. For consistency and simplicity of specification,
   3432 POSIX.1-2024 does not permit this behavior, requiring that the name be the only factor in the decision.</p>
   3433 <p class="tent">Historically, <a href="../utilities/vi.html"><i>vi</i></a> only searched for tags in the current file from the
   3434 current cursor to the end of the file, and therefore, if the <b>wrapscan</b> option was not set, tags occurring before the current
   3435 cursor were not found. POSIX.1-2024 considers this a bug, and implementations are required to search for the first occurrence in
   3436 the file, regardless.</p>
   3437 <h5><a name="tag_20_40_18_37" id="tag_20_40_18_37"></a>Undo</h5>
   3438 <p class="tent">The <b>undo</b> description deliberately uses the word &quot;modified&quot;. The <b>undo</b> command is not intended to
   3439 undo commands that replace the contents of the edit buffer, such as <b>edit</b>, <b>next</b>, <b>tag</b>, or <b>recover</b>.</p>
   3440 <p class="tent">Cursor positioning after the <b>undo</b> command was inconsistent in the historical <a href=
   3441 "../utilities/vi.html"><i>vi</i></a>, sometimes attempting to restore the original cursor position (<b>global</b>, <b>undo</b>, and
   3442 <b>v</b> commands), and sometimes, in the presence of maps, placing the cursor on the last line added or changed instead of the
   3443 first. POSIX.1-2024 requires a simplified behavior for consistency and simplicity of specification.</p>
   3444 <h5><a name="tag_20_40_18_38" id="tag_20_40_18_38"></a>Version</h5>
   3445 <p class="tent">The <b>version</b> command cannot be exactly specified since there is no widely-accepted definition of what the
   3446 version information should contain. Implementations are encouraged to do something reasonably intelligent.</p>
   3447 <h5><a name="tag_20_40_18_39" id="tag_20_40_18_39"></a>Write</h5>
   3448 <p class="tent">Historically, the <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> message after a successful <b>read</b>
   3449 or <b>write</b> command specified &quot;characters&quot;, not &quot;bytes&quot;. POSIX.1-2024 requires that the number of bytes be displayed, not
   3450 the number of characters because it may be difficult in multi-byte implementations to determine the number of characters written.
   3451 Implementations are encouraged to clarify the message displayed to the user.</p>
   3452 <p class="tent">Implementation-defined tests are permitted so that implementations can make additional checks; for example, for
   3453 locks or file modification times.</p>
   3454 <p class="tent">Historically, attempting to append to a nonexistent file caused an error. It has been left unspecified in
   3455 POSIX.1-2024 to permit implementations to let the <b>write</b> succeed, so that the append semantics are similar to those of the
   3456 historical <i>csh</i>.</p>
   3457 <p class="tent">Historical <a href="../utilities/vi.html"><i>vi</i></a> permitted empty edit buffers to be written. However, since
   3458 the way <a href="../utilities/vi.html"><i>vi</i></a> got around dealing with &quot;empty&quot; files was to always have a line in the edit
   3459 buffer, no matter what, it wrote them as files of a single, empty line. POSIX.1-2024 does not permit this behavior.</p>
   3460 <p class="tent">Historically, <i>ex</i> restored standard output and standard error to their values as of when <i>ex</i> was
   3461 invoked, before writes to programs were performed. This could disturb the terminal configuration as well as be a security issue for
   3462 some terminals. POSIX.1-2024 does not permit this, requiring that the program output be captured and displayed as if by the
   3463 <i>ex</i> <b>print</b> command.</p>
   3464 <h5><a name="tag_20_40_18_40" id="tag_20_40_18_40"></a>Adjust Window</h5>
   3465 <p class="tent">Historically, the line count was set to the value of the <b>scroll</b> option if the type character was
   3466 end-of-file. This feature was broken on most historical implementations long ago, however, and is not documented anywhere. For this
   3467 reason, POSIX.1-2024 is resolutely silent.</p>
   3468 <p class="tent">Historically, the <b>z</b> command was &lt;blank&gt;-sensitive and <b>z&nbsp;+</b> and <b>z&nbsp;-</b> did
   3469 different things than <b>z+</b> and <b>z-</b> because the type could not be distinguished from a flag. (The commands
   3470 <b>z&nbsp;.</b> and <b>z&nbsp;=</b> were historically invalid.) POSIX.1-2024 requires conformance to this historical practice.</p>
   3471 <p class="tent">Historically, the <b>z</b> command was further &lt;blank&gt;-sensitive in that the <i>count</i> could not be
   3472 &lt;blank&gt;-delimited; for example, the commands <b>z=&nbsp;5</b> and <b>z-&nbsp;5</b> were also invalid. Because the
   3473 <i>count</i> is not ambiguous with respect to either the type character or the flags, this is not permitted by POSIX.1-2024.</p>
   3474 <h5><a name="tag_20_40_18_41" id="tag_20_40_18_41"></a>Escape</h5>
   3475 <p class="tent">Historically, <i>ex</i> filter commands only read the standard output of the commands, letting standard error
   3476 appear on the terminal as usual. The <a href="../utilities/vi.html"><i>vi</i></a> utility, however, read both standard output and
   3477 standard error. POSIX.1-2024 requires the latter behavior for both <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>, for
   3478 consistency.</p>
   3479 <p class="tent">In Issue 8 the <a href="../functions/system.html#"><i>system</i></a> function was changed to require that the POSIX
   3480 shell be invoked with <tt>"sh"</tt>, <tt>"-c"</tt>, <tt>"--"</tt>, and <i>command</i> arguments to make it easier to execute
   3481 programs with &lt;hyphen-minus&gt; (<tt>'-'</tt>) or &lt;plus-sign&gt; (<tt>'+'</tt>) as the first character of the program's
   3482 filename. A similar request to have the <i>ex</i> <b>escape</b> command do the same was not accepted. Unlike <a href=
   3483 "../functions/system.html"><i>system</i>()</a> (which always invokes a POSIX shell), <i>ex</i> invokes the program named by the
   3484 <b>shell</b> edit option. For example, the <i>csh</i> and <i>tcsh</i> shells that are frequently used as login shells do not
   3485 recognize <tt>"--"</tt> after <tt>"-c"</tt> as an end-of-options indicator. The program need not even be one that recognizes any
   3486 POSIX shell command line syntax. Some users invoke shell scripts to process lines that are being supplied to the specified utility.
   3487 These utilities know that they will be given <tt>"-c"</tt> as a first argument and just ignore it. Any utilities used in this
   3488 manner would have to be modified to skip over another argument (the <tt>"--"</tt>) to find the desired argument.</p>
   3489 <h5><a name="tag_20_40_18_42" id="tag_20_40_18_42"></a>Shift Left and Shift Right</h5>
   3490 <p class="tent">Historically, it was possible to add shift characters to increase the effect of the command; for example,
   3491 <b>&lt;&lt;&lt;</b> outdented (or <b>&gt;&gt;&gt;</b> indented) the lines 3 levels of indentation instead of the default 1.
   3492 POSIX.1-2024 requires conformance to historical practice.</p>
   3493 <h5><a name="tag_20_40_18_43" id="tag_20_40_18_43"></a>&lt;control&gt;-D</h5>
   3494 <p class="tent">Historically, the &lt;control&gt;-D command erased the prompt, providing the user with an unbroken presentation of
   3495 lines from the edit buffer. This is not required by POSIX.1-2024; implementations are encouraged to provide it if possible.
   3496 Historically, the &lt;control&gt;-D command took, and then ignored, a <i>count</i>. POSIX.1-2024 does not permit this behavior.</p>
   3497 <h5><a name="tag_20_40_18_44" id="tag_20_40_18_44"></a>Write Line Number</h5>
   3498 <p class="tent">Historically, the <i>ex</i> <b>=</b> command, when executed in <i>ex</i> mode in an empty edit buffer, reported 0,
   3499 and from open or visual mode, reported 1. For consistency and simplicity of specification, POSIX.1-2024 does not permit this
   3500 behavior.</p>
   3501 <h5><a name="tag_20_40_18_45" id="tag_20_40_18_45"></a>Execute</h5>
   3502 <p class="tent">Historically, <i>ex</i> did not correctly handle the inclusion of text input commands (that is, <b>append</b>,
   3503 <b>insert</b>, and <b>change</b>) in executed buffers. POSIX.1-2024 does not permit this exclusion for consistency.</p>
   3504 <p class="tent">Historically, the logical contents of the buffer being executed did not change if the buffer itself were modified
   3505 by the commands being executed; that is, buffer execution did not support self-modifying code. POSIX.1-2024 requires conformance to
   3506 historical practice.</p>
   3507 <p class="tent">Historically, the <b>@</b> command took a range of lines, and the <b>@</b> buffer was executed once per line, with
   3508 the current line (<tt>'.'</tt>) set to each specified line. POSIX.1-2024 requires conformance to historical practice.</p>
   3509 <p class="tent">Some historical implementations did not notice if errors occurred during buffer execution. This, coupled with the
   3510 ability to specify a range of lines for the <i>ex</i> <b>@</b> command, makes it trivial to cause them to drop <b>core</b>.
   3511 POSIX.1-2024 requires that implementations stop buffer execution if any error occurs, if the specified line doesn't exist, or if
   3512 the contents of the edit buffer itself are replaced (for example, the buffer executes the <i>ex</i> <b>:edit</b> command).</p>
   3513 <h5><a name="tag_20_40_18_46" id="tag_20_40_18_46"></a>Regular Expressions in ex</h5>
   3514 <p class="tent">Historical practice is that the characters in the replacement part of the last <b>s</b> command—that is, those
   3515 matched by entering a <tt>'~'</tt> in the regular expression—were not further expanded by the regular expression engine. So, if the
   3516 characters contained the string <tt>"a.,"</tt> they would match <tt>'a'</tt> followed by <tt>".,"</tt> and not <tt>'a'</tt>
   3517 followed by any character. POSIX.1-2024 requires conformance to historical practice.</p>
   3518 <h5><a name="tag_20_40_18_47" id="tag_20_40_18_47"></a>Edit Options in ex</h5>
   3519 <p class="tent">The following paragraphs describe the historical behavior of some edit options that were not, for whatever reason,
   3520 included in POSIX.1-2024. Implementations are strongly encouraged to only use these names if the functionality described here is
   3521 fully supported.</p>
   3522 <dl compact>
   3523 <dd></dd>
   3524 <dt><b>extended</b></dt>
   3525 <dd>The <b>extended</b> edit option has been used in some implementations of <a href="../utilities/vi.html"><i>vi</i></a> to
   3526 provide extended regular expressions instead of basic regular expressions This option was omitted from POSIX.1-2024 because it is
   3527 not widespread historical practice.</dd>
   3528 <dt><b>flash</b></dt>
   3529 <dd>The <b>flash</b> edit option historically caused the screen to flash instead of beeping on error. This option was omitted from
   3530 POSIX.1-2024 because it is not found in some historical implementations.</dd>
   3531 <dt><b>hardtabs</b></dt>
   3532 <dd>The <b>hardtabs</b> edit option historically defined the number of columns between hardware tab settings. This option was
   3533 omitted from POSIX.1-2024 because it was believed to no longer be generally useful.</dd>
   3534 <dt><b>modeline</b></dt>
   3535 <dd>The <b>modeline</b> (sometimes named <b>modelines</b>) edit option historically caused <i>ex</i> or <a href=
   3536 "../utilities/vi.html"><i>vi</i></a> to read the five first and last lines of the file for editor commands. This option is a
   3537 security problem, and vendors are strongly encouraged to delete it from historical implementations.</dd>
   3538 <dt><b>open</b></dt>
   3539 <dd>The <b>open</b> edit option historically disallowed the <i>ex</i> <b>open</b> and <b>visual</b> commands. This edit option was
   3540 omitted because these commands are required by POSIX.1-2024.</dd>
   3541 <dt><b>optimize</b></dt>
   3542 <dd>The <b>optimize</b> edit option historically expedited text throughput by setting the terminal to not do automatic
   3543 &lt;carriage-return&gt; characters when printing more than one logical line of output. This option was omitted from POSIX.1-2024
   3544 because it was intended for terminals without addressable cursors, which are rarely, if ever, still used.</dd>
   3545 <dt><b>ruler</b></dt>
   3546 <dd>The <b>ruler</b> edit option has been used in some implementations of <a href="../utilities/vi.html"><i>vi</i></a> to present a
   3547 current row/column ruler for the user. This option was omitted from POSIX.1-2024 because it is not widespread historical
   3548 practice.</dd>
   3549 <dt><b>sourceany</b></dt>
   3550 <dd>The <b>sourceany</b> edit option historically caused <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> to source
   3551 start-up files that were owned by users other than the user running the editor. This option is a security problem, and vendors are
   3552 strongly encouraged to remove it from their implementations.</dd>
   3553 <dt><b>timeout</b></dt>
   3554 <dd>The <b>timeout</b> edit option historically enabled the (now standard) feature of only waiting for a short period before
   3555 returning keys that could be part of a macro. This feature was omitted from POSIX.1-2024 because its behavior is now standard, it
   3556 is not widely useful, and it was rarely documented.</dd>
   3557 <dt><b>verbose</b></dt>
   3558 <dd>The <b>verbose</b> edit option has been used in some implementations of <a href="../utilities/vi.html"><i>vi</i></a> to cause
   3559 <a href="../utilities/vi.html"><i>vi</i></a> to output error messages for common errors; for example, attempting to move the cursor
   3560 past the beginning or end of the line instead of only alerting the screen. (The historical <a href=
   3561 "../utilities/vi.html"><i>vi</i></a> only alerted the terminal and presented no message for such errors. The historical editor
   3562 option <b>terse</b> did not select when to present error messages, it only made existing error messages more or less verbose.) This
   3563 option was omitted from POSIX.1-2024 because it is not widespread historical practice; however, implementors are encouraged to use
   3564 it if they wish to provide error messages for naive users.</dd>
   3565 <dt><b>wraplen</b></dt>
   3566 <dd>The <b>wraplen</b> edit option has been used in some implementations of <a href="../utilities/vi.html"><i>vi</i></a> to specify
   3567 an automatic margin measured from the left margin instead of from the right margin. This is useful when multiple screen sizes are
   3568 being used to edit a single file. This option was omitted from POSIX.1-2024 because it is not widespread historical practice;
   3569 however, implementors are encouraged to use it if they add this functionality.</dd>
   3570 </dl>
   3571 <h5><a name="tag_20_40_18_48" id="tag_20_40_18_48"></a>autoindent, ai</h5>
   3572 <p class="tent">Historically, the command <b>0a</b> did not do any autoindentation, regardless of the current indentation of line
   3573 1. POSIX.1-2024 requires that any indentation present in line 1 be used.</p>
   3574 <h5><a name="tag_20_40_18_49" id="tag_20_40_18_49"></a>autoprint, ap</h5>
   3575 <p class="tent">Historically, the <b>autoprint</b> edit option was not completely consistent or based solely on modifications to
   3576 the edit buffer. Exceptions were the <b>read</b> command (when reading from a file, but not from a filter), the <b>append</b>,
   3577 <b>change</b>, <b>insert</b>, <b>global</b>, and <b>v</b> commands, all of which were not affected by <b>autoprint</b>, and the
   3578 <b>tag</b> command, which was affected by <b>autoprint</b>. POSIX.1-2024 requires conformance to historical practice.</p>
   3579 <p class="tent">Historically, the <b>autoprint</b> option only applied to the last of multiple commands entered using
   3580 &lt;vertical-line&gt; delimiters; for example, <b>delete</b> &lt;newline&gt; was affected by <b>autoprint</b>, but
   3581 <b>delete|version</b> &lt;newline&gt; was not. POSIX.1-2024 requires conformance to historical practice.</p>
   3582 <h5><a name="tag_20_40_18_50" id="tag_20_40_18_50"></a>autowrite, aw</h5>
   3583 <p class="tent">Appending the <tt>'!'</tt> character to the <i>ex</i> <b>next</b> command to avoid performing an automatic write
   3584 was not supported in historical implementations. POSIX.1-2024 requires that the behavior match the other <i>ex</i> commands for
   3585 consistency.</p>
   3586 <h5><a name="tag_20_40_18_51" id="tag_20_40_18_51"></a>ignorecase, ic</h5>
   3587 <p class="tent">Historical implementations of case-insensitive matching (the <b>ignorecase</b> edit option) lead to
   3588 counter-intuitive situations when uppercase characters were used in range expressions. Historically, the process was as
   3589 follows:</p>
   3590 <ol>
   3591 <li class="tent">Take a line of text from the edit buffer.</li>
   3592 <li class="tent">Convert uppercase to lowercase in text line.</li>
   3593 <li class="tent">Convert uppercase to lowercase in regular expressions, except in character class specifications.</li>
   3594 <li class="tent">Match regular expressions against text.</li>
   3595 </ol>
   3596 <p class="tent">This would mean that, with <b>ignorecase</b> in effect, the text:</p>
   3597 <pre>
   3598 <tt>The cat sat on the mat
   3599 </tt></pre>
   3600 <p class="tent">would be matched by</p>
   3601 <pre>
   3602 <tt>/^the/
   3603 </tt></pre>
   3604 <p class="tent">but not by:</p>
   3605 <pre>
   3606 <tt>/^[A-Z]he/
   3607 </tt></pre>
   3608 <p class="tent">For consistency with other commands implementing regular expressions, POSIX.1-2024 does not permit this
   3609 behavior.</p>
   3610 <h5><a name="tag_20_40_18_52" id="tag_20_40_18_52"></a>paragraphs, para</h5>
   3611 <p class="tent">The ISO&nbsp;POSIX-2:1993 standard made the default <b>paragraphs</b> and <b>sections</b> edit options
   3612 implementation-defined, arguing they were historically oriented to the UNIX system <i>troff</i> text formatter, and a &quot;portable
   3613 user&quot; could use the <b>{</b>, <b>}</b>, <b>[[</b>, <b>]]</b>, <b>(</b>, and <b>)</b> commands in open or visual mode and have the
   3614 cursor stop in unexpected places. POSIX.1-2024 specifies their values in the POSIX locale because the unusual grouping (they only
   3615 work when grouped into two characters at a time) means that they cannot be used for general-purpose movement, regardless.</p>
   3616 <h5><a name="tag_20_40_18_53" id="tag_20_40_18_53"></a>readonly</h5>
   3617 <p class="tent">Implementations are encouraged to provide the best possible information to the user as to the read-only status of
   3618 the file, with the exception that they should not consider the current special privileges of the process. This provides users with
   3619 a safety net because they must force the overwrite of read-only files, even when running with additional privileges.</p>
   3620 <p class="tent">The <b>readonly</b> edit option specification largely conforms to historical practice. The only difference is that
   3621 historical implementations did not notice that the user had set the <b>readonly</b> edit option in cases where the file was already
   3622 marked read-only for some reason, and would therefore reinitialize the <b>readonly</b> edit option the next time the contents of
   3623 the edit buffer were replaced. This behavior is disallowed by POSIX.1-2024.</p>
   3624 <h5><a name="tag_20_40_18_54" id="tag_20_40_18_54"></a>report</h5>
   3625 <p class="tent">The requirement that lines copied to a buffer interact differently than deleted lines is historical practice. For
   3626 example, if the <b>report</b> edit option is set to 3, deleting 3 lines will cause a report to be written, but 4 lines must be
   3627 copied before a report is written.</p>
   3628 <p class="tent">The requirement that the <i>ex</i> <b>global</b>, <b>v</b>, <b>open</b>, <b>undo</b>, and <b>visual</b> commands
   3629 present reports based on the total number of lines added or deleted during the command execution, and that commands executed by the
   3630 <b>global</b> and <b>v</b> commands not present reports, is historical practice. POSIX.1-2024 extends historical practice by
   3631 requiring that buffer execution be treated similarly. The reasons for this are two-fold. Historically, only the report by the last
   3632 command executed from the buffer would be seen by the user, as each new report would overwrite the last. In addition, the standard
   3633 developers believed that buffer execution had more in common with <b>global</b> and <b>v</b> commands than it did with other
   3634 <i>ex</i> commands, and should behave similarly, for consistency and simplicity of specification.</p>
   3635 <h5><a name="tag_20_40_18_55" id="tag_20_40_18_55"></a>showmatch, sm</h5>
   3636 <p class="tent">The length of time the cursor spends on the matching character is unspecified because the timing capabilities of
   3637 systems are often inexact and variable. The time should be long enough for the user to notice, but not long enough for the user to
   3638 become annoyed. Some implementations of <a href="../utilities/vi.html"><i>vi</i></a> have added a <b>matchtime</b> option that
   3639 permits users to set the number of 0,1 second intervals the cursor pauses on the matching character.</p>
   3640 <h5><a name="tag_20_40_18_56" id="tag_20_40_18_56"></a>showmode</h5>
   3641 <p class="tent">The <b>showmode</b> option has been used in some historical implementations of <i>ex</i> and <a href=
   3642 "../utilities/vi.html"><i>vi</i></a> to display the current editing mode when in open or visual mode. The editing modes have
   3643 generally included &quot;command&quot; and &quot;input&quot;, and sometimes other modes such as &quot;replace&quot; and &quot;change&quot;. The string was usually
   3644 displayed on the bottom line of the screen at the far right-hand corner. In addition, a preceding <tt>'*'</tt> character often
   3645 denoted whether the contents of the edit buffer had been modified. The latter display has sometimes been part of the
   3646 <b>showmode</b> option, and sometimes based on another option. This option was not available in the 4 BSD historical implementation
   3647 of <a href="../utilities/vi.html"><i>vi</i></a>, but was viewed as generally useful, particularly to novice users, and is required
   3648 by POSIX.1-2024.</p>
   3649 <p class="tent">The <b>smd</b> shorthand for the <b>showmode</b> option was not present in all historical implementations of the
   3650 editor. POSIX.1-2024 requires it, for consistency.</p>
   3651 <p class="tent">Not all historical implementations of the editor displayed a mode string for command mode, differentiating command
   3652 mode from text input mode by the absence of a mode string. POSIX.1-2024 permits this behavior for consistency with historical
   3653 practice, but implementations are encouraged to provide a display string for both modes.</p>
   3654 <h5><a name="tag_20_40_18_57" id="tag_20_40_18_57"></a>slowopen</h5>
   3655 <p class="tent">Historically, the <b>slowopen</b> option was automatically set if the terminal baud rate was less than 1200 baud,
   3656 or if the baud rate was 1200 baud and the <b>redraw</b> option was not set. The <b>slowopen</b> option had two effects. First, when
   3657 inserting characters in the middle of a line, characters after the cursor would not be pushed ahead, but would appear to be
   3658 overwritten. Second, when creating a new line of text, lines after the current line would not be scrolled down, but would appear to
   3659 be overwritten. In both cases, ending text input mode would cause the screen to be refreshed to match the actual contents of the
   3660 edit buffer. Finally, terminals that were sufficiently intelligent caused the editor to ignore the <b>slowopen</b> option.
   3661 POSIX.1-2024 permits most historical behavior, extending historical practice to require <b>slowopen</b> behaviors if the edit
   3662 option is set by the user.</p>
   3663 <h5><a name="tag_20_40_18_58" id="tag_20_40_18_58"></a>tags</h5>
   3664 <p class="tent">The default path for tags files is left unspecified as implementations may have their own <b>tags</b>
   3665 implementations that do not correspond to the historical ones. The default <b>tags</b> option value should probably at least
   3666 include the file <b>./tags</b>.</p>
   3667 <h5><a name="tag_20_40_18_59" id="tag_20_40_18_59"></a>term</h5>
   3668 <p class="tent">Historical implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> ignored changes to the
   3669 <b>term</b> edit option after the initial terminal information was loaded. This is permitted by POSIX.1-2024; however,
   3670 implementations are encouraged to permit the user to modify their terminal type at any time.</p>
   3671 <h5><a name="tag_20_40_18_60" id="tag_20_40_18_60"></a>terse</h5>
   3672 <p class="tent">Historically, the <b>terse</b> edit option optionally provided a shorter, less descriptive error message, for some
   3673 error messages. This is permitted, but not required, by POSIX.1-2024. Historically, most common visual mode errors (for example,
   3674 trying to move the cursor past the end of a line) did not result in an error message, but simply alerted the terminal.
   3675 Implementations wishing to provide messages for novice users are urged to do so based on the <b>edit</b> option <b>verbose</b>, and
   3676 not <b>terse</b>.</p>
   3677 <h5><a name="tag_20_40_18_61" id="tag_20_40_18_61"></a>window</h5>
   3678 <p class="tent">In historical implementations, the default for the <b>window</b> edit option was based on the baud rate as
   3679 follows:</p>
   3680 <ol>
   3681 <li class="tent">If the baud rate was less than 1200, the <b>edit</b> option <b>w300</b> set the window value; for example, the
   3682 line:
   3683 <pre>
   3684 <tt>set w300=12
   3685 </tt></pre>
   3686 <p class="tent">would set the window option to 12 if the baud rate was less than 1200.</p>
   3687 </li>
   3688 <li class="tent">If the baud rate was equal to 1200, the <b>edit</b> option <b>w1200</b> set the window value.</li>
   3689 <li class="tent">If the baud rate was greater than 1200, the <b>edit</b> option <b>w9600</b> set the window value.</li>
   3690 </ol>
   3691 <p class="tent">The <b>w300</b>, <b>w1200</b>, and <b>w9600</b> options do not appear in POSIX.1-2024 because of their dependence
   3692 on specific baud rates.</p>
   3693 <p class="tent">In historical implementations, the size of the window displayed by various commands was related to, but not
   3694 necessarily the same as, the <b>window</b> edit option. For example, the size of the window was set by the <i>ex</i> command
   3695 <b>visual 10</b>, but it did not change the value of the <b>window</b> edit option. However, changing the value of the
   3696 <b>window</b> edit option did change the number of lines that were displayed when the screen was repainted. POSIX.1-2024 does not
   3697 permit this behavior in the interests of consistency and simplicity of specification, and requires that all commands that change
   3698 the number of lines that are displayed do it by setting the value of the <b>window</b> edit option.</p>
   3699 <h5><a name="tag_20_40_18_62" id="tag_20_40_18_62"></a>wrapmargin, wm</h5>
   3700 <p class="tent">Historically, the <b>wrapmargin</b> option did not affect maps inserting characters that also had associated
   3701 <i>count</i>s; for example <b>:map&nbsp;K&nbsp;5aABC&nbsp;DEF</b>. Unfortunately, there are widely used maps that depend on this
   3702 behavior. For consistency and simplicity of specification, POSIX.1-2024 does not permit this behavior.</p>
   3703 <p class="tent">Historically, <b>wrapmargin</b> was calculated using the column display width of all characters on the screen. For
   3704 example, an implementation using <tt>"^I"</tt> to represent &lt;tab&gt; characters when the <b>list</b> edit option was set, where
   3705 <tt>'^'</tt> and <tt>'I'</tt> each took up a single column on the screen, would calculate the <b>wrapmargin</b> based on a value of
   3706 2 for each &lt;tab&gt;. The <b>number</b> edit option similarly changed the effective length of the line as well. POSIX.1-2024
   3707 requires conformance to historical practice.</p>
   3708 <p class="tent">Earlier versions of this standard allowed for implementations with bytes other than eight bits, but this has been
   3709 modified in this version.</p>
   3710 </blockquote>
   3711 <h4 class="mansect"><a name="tag_20_40_19" id="tag_20_40_19"></a>FUTURE DIRECTIONS</h4>
   3712 <blockquote>
   3713 <p>If this utility is directed to create a new directory entry that contains any bytes that have the encoded value of a
   3714 &lt;newline&gt; character, implementations are encouraged to treat this as an error. A future version of this standard may require
   3715 implementations to treat this as an error.</p>
   3716 </blockquote>
   3717 <h4 class="mansect"><a name="tag_20_40_20" id="tag_20_40_20"></a>SEE ALSO</h4>
   3718 <blockquote>
   3719 <p><a href="../utilities/V3_chap02.html#tag_19_09_01_04"><i>2.9.1.4 Command Search and Execution</i></a> , <a href=
   3720 "../utilities/ctags.html#"><i>ctags</i></a> , <a href="../utilities/ed.html#"><i>ed</i></a> , <a href=
   3721 "../utilities/sed.html#"><i>sed</i></a> , <a href="../utilities/sh.html#"><i>sh</i></a> , <a href=
   3722 "../utilities/stty.html#"><i>stty</i></a> , <a href="../utilities/vi.html#"><i>vi</i></a></p>
   3723 <p class="tent">XBD <a href="../basedefs/V1_chap05.html#tagtcjh_2"><i>Escape Sequences and Associated Actions</i></a> , <a href=
   3724 "../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href="../basedefs/V1_chap09.html#tag_09_03"><i>9.3
   3725 Basic Regular Expressions</i></a> , <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
   3726 <p class="tent">XSH <a href="../functions/access.html#"><i>access</i></a></p>
   3727 </blockquote>
   3728 <h4 class="mansect"><a name="tag_20_40_21" id="tag_20_40_21"></a>CHANGE HISTORY</h4>
   3729 <blockquote>
   3730 <p>First released in Issue 2.</p>
   3731 </blockquote>
   3732 <h4 class="mansect"><a name="tag_20_40_22" id="tag_20_40_22"></a>Issue 5</h4>
   3733 <blockquote>
   3734 <p>The FUTURE DIRECTIONS section is added.</p>
   3735 </blockquote>
   3736 <h4 class="mansect"><a name="tag_20_40_23" id="tag_20_40_23"></a>Issue 6</h4>
   3737 <blockquote>
   3738 <p>This utility is marked as part of the User Portability Utilities option.</p>
   3739 <p class="tent">The obsolescent SYNOPSIS is removed, removing the <b>+</b><i>command</i> and <b>-</b> options.<br></p>
   3740 <p class="tent">The following new requirements on POSIX implementations derive from alignment with the Single UNIX
   3741 Specification:</p>
   3742 <ul>
   3743 <li class="tent">In the <b>map</b> command description, the sequence <b>#</b><i>digit</i> is added.</li>
   3744 <li class="tent">The <b>directory</b>, <b>edcompatible</b>, <b>redraw</b>, and <b>slowopen</b> edit options are added.</li>
   3745 </ul>
   3746 <p class="tent">The <i>ex</i> utility is extensively changed for alignment with the IEEE&nbsp;P1003.2b draft standard. This
   3747 includes changes as a result of the IEEE PASC Interpretations 1003.2 #31, #38, #49, #50, #51, #52, #55, #56, #57, #61, #62, #63,
   3748 #64, #65, and #78.</p>
   3749 <p class="tent">The <b>-l</b> option is removed.</p>
   3750 <p class="tent">IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;1-2002, item XCU/TC1/D6/23 is applied, correcting a URL.</p>
   3751 <p class="tent">IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;2-2004, item XCU/TC2/D6/8 is applied, making an editorial correction in the
   3752 EXTENDED DESCRIPTION.</p>
   3753 <p class="tent">IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;2-2004, item XCU/TC2/D6/9 is applied, removing text describing behavior on
   3754 systems with bytes consisting of more than eight bits.</p>
   3755 </blockquote>
   3756 <h4 class="mansect"><a name="tag_20_40_24" id="tag_20_40_24"></a>Issue 7</h4>
   3757 <blockquote>
   3758 <p>Austin Group Interpretation 1003.1-2001 #027 is applied, clarifying the behavior if an operand is <tt>'-'</tt>.</p>
   3759 <p class="tent">Austin Group Interpretation 1003.1-2001 #036 is applied, clarifying the behavior for BREs.</p>
   3760 <p class="tent">Austin Group Interpretation 1003.1-2001 #121 is applied, clarifying the <i>ex</i> <b>write</b> command.</p>
   3761 <p class="tent">Austin Group Interpretation 1003.1-2001 #156 is applied.</p>
   3762 <p class="tent">SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
   3763 <p class="tent">POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0093 [584] is applied.</p>
   3764 </blockquote>
   3765 <h4 class="mansect"><a name="tag_20_40_25" id="tag_20_40_25"></a>Issue 8</h4>
   3766 <blockquote>
   3767 <p>Austin Group Defect 251 is applied, encouraging implementations to disallow the creation of filenames containing any bytes that
   3768 have the encoded value of a &lt;newline&gt; character.</p>
   3769 <p class="tent">Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
   3770 <p class="tent">Austin Group Defect 1185 is applied, changing the SIGCONT entry in ASYNCHRONOUS EVENTS and adding a SIGWINCH
   3771 entry.</p>
   3772 <p class="tent">Austin Group Defect 1251 is applied, clarifying the <b>set</b> command, changing &quot;addr&quot; to &quot;2addr&quot; in the
   3773 <b>!</b> command synopsis, and adding spaces in some synopsis lines.</p>
   3774 <p class="tent">Austin Group Defect 1281 is applied, changing the description of the <b>substitute</b> command to clarify that it
   3775 is an error if the substitution fails on every addressed line.</p>
   3776 <p class="tent">Austin Group Defect 1298 is applied, changing the CONSEQUENCES OF ERRORS section.</p>
   3777 <p class="tent">Austin Group Defect 1378 is applied, changing the description of the <i>LC_MESSAGES</i> environment variable.</p>
   3778 <p class="tent">Austin Group Defect 1529 is applied, changing the synopsis of the <b>escape</b> command and adding related
   3779 paragraphs to the APPLICATION USAGE and RATIONALE sections.</p>
   3780 <p class="tent">Austin Group Defect 1642 is applied, changing the description of the <b>redraw</b> edit option.</p>
   3781 <p class="tent">Austin Group Defect 1662 is applied, clarifying requirements relating to delimiters in addresses and in <b>s</b>
   3782 commands.</p>
   3783 </blockquote>
   3784 <div class="box"><em>End of informative text.</em></div>
   3785 <hr>
   3786 <p>&nbsp;</p>
   3787 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
   3788 <hr size="2" noshade>
   3789 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
   3790 POSIX™ is a Trademark of The IEEE.<br>
   3791 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
   3792 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
   3793 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
   3794 ]</font></center>
   3795 <hr size="2" noshade>
   3796 <div class="NAVHEADER">
   3797 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
   3798 <tr class="nav">
   3799 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/env.html" accesskey="P">&lt;&lt;&lt;
   3800 Previous</a></td>
   3801 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
   3802 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/expand.html" accesskey="N">Next
   3803 &gt;&gt;&gt;</a></td>
   3804 </tr>
   3805 </table>
   3806 <hr align="left" width="100%"></div>
   3807 </body>
   3808 </html>