5215 lines
250 KiB
HTML
5215 lines
250 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>ex</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="ex"></a> <a name="tag_04_45"></a><!-- ex -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_45_01"></a>NAME</h4>
|
|
|
|
<blockquote>ex - text editor</blockquote>
|
|
|
|
<h4><a name="tag_04_45_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[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>][</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="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<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
|
|
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
|
|
<a href="vi.html"><i>vi</i></a> .</p>
|
|
|
|
<p>This section uses the term <i>edit buffer</i> to describe the current working text. No specific implementation is implied by
|
|
this term. All editing changes are performed on the edit buffer, and no changes to it shall affect any file until an editor command
|
|
writes the file.</p>
|
|
|
|
<p>Certain terminals do not have all the capabilities necessary to support the complete <i>ex</i> definition, such as the
|
|
full-screen editing commands ( <i>visual mode</i> or <i>open mode</i>). When these commands cannot be supported on such terminals,
|
|
this condition shall not produce an error message such as "not an editor command" or report a syntax error. The implementation
|
|
may either accept the commands and produce results on the screen that are the result of an unsuccessful attempt to meet the
|
|
requirements of this volume of IEEE Std 1003.1-2001 or report an error describing the terminal-related deficiency.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>ex</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
|
|
|
|
<p>The following options shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>-c </b> <i>command</i></dt>
|
|
|
|
<dd>Specify an initial command to be executed in the first edit buffer loaded from an existing file (see the EXTENDED DESCRIPTION
|
|
section). Implementations may support more than a single <b>-c</b> option. In such implementations, the specified commands shall be
|
|
executed in the order specified on the command line.</dd>
|
|
|
|
<dt><b>-r</b></dt>
|
|
|
|
<dd>Recover the named files (see the EXTENDED DESCRIPTION section). Recovery information for a file shall be saved during an editor
|
|
or system crash (for example, when the editor is terminated by a signal which the editor can catch), or after the use of an
|
|
<i>ex</i> <b>preserve</b> command.
|
|
|
|
<p>A <i>crash</i> in this context is an unexpected failure of the system or utility that requires restarting the failed system or
|
|
utility. A system crash implies that any utilities running at the time also crash. In the case of an editor or system crash, the
|
|
number of changes to the edit buffer (since the most recent <b>preserve</b> command) that will be recovered is unspecified.</p>
|
|
|
|
<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,
|
|
and any <b>.exrc</b> files shall be ignored; a list of all recoverable files available to the invoking user shall be written, and
|
|
the editor shall exit normally without further action.</p>
|
|
</dd>
|
|
|
|
<dt><b>-R</b></dt>
|
|
|
|
<dd>Set <b>readonly</b> edit option.</dd>
|
|
|
|
<dt><b>-s</b></dt>
|
|
|
|
<dd>Prepare <i>ex</i> for batch use by taking the following actions:
|
|
|
|
<ul>
|
|
<li>
|
|
<p>Suppress writing prompts and informational (but not diagnostic) messages.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Ignore the value of <i>TERM</i> and any implementation default terminal type and assume the terminal is a type incapable of
|
|
supporting open or visual modes; see the <b>visual</b> command and the description of <a href="vi.html"><i>vi</i></a> .</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Suppress the use of the <i>EXINIT</i> environment variable and the reading of any <b>.exrc</b> file; see the EXTENDED
|
|
DESCRIPTION section.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Suppress autoindentation, ignoring the value of the <b>autoindent</b> edit option.</p>
|
|
</li>
|
|
</ul>
|
|
</dd>
|
|
|
|
<dt><b>-t </b> <i>tagstring</i></dt>
|
|
|
|
<dd>Edit the file containing the specified <i>tagstring</i>; see <a href="ctags.html"><i>ctags</i></a> . The tags 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 also
|
|
provides a conforming implementation of <a href="../utilities/ctags.html"><i>ctags</i></a>; otherwise, the use of <b>-t</b>
|
|
produces undefined results. On any system, it shall be an error to specify more than a single <b>-t</b> option.</dd>
|
|
|
|
<dt><b>-v</b></dt>
|
|
|
|
<dd>Begin in visual mode (see <a href="vi.html"><i>vi</i></a> ).</dd>
|
|
|
|
<dt><b>-w </b> <i>size</i></dt>
|
|
|
|
<dd>Set the value of the <i>window</i> editor option to <i>size</i>.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operand shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>file</i></dt>
|
|
|
|
<dd>A pathname of a file to be edited.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard input consists of a series of commands and input text, as described in the EXTENDED DESCRIPTION section. The
|
|
implementation may limit each line of standard input to a length of {LINE_MAX}.</p>
|
|
|
|
<p>If the standard input is not a terminal device, it shall be as if the <b>-s</b> option had been specified.</p>
|
|
|
|
<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,
|
|
it shall be equivalent to a SIGHUP asynchronous event.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<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
|
|
{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
|
|
trailing <newline>. The editing of other forms of files may optionally be allowed by <i>ex</i> implementations.</p>
|
|
|
|
<p>The <b>.exrc</b> files and source files shall be text files consisting of <i>ex</i> commands; see the EXTENDED DESCRIPTION
|
|
section.</p>
|
|
|
|
<p>By default, the editor shall read lines from the files to be edited without interpreting any of those lines as any form of
|
|
editor command.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>ex</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>COLUMNS</i></dt>
|
|
|
|
<dd>Override the system-selected horizontal screen size. See the Base Definitions volume of IEEE Std 1003.1-2001, <a
|
|
href="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a> for valid values and results when it is unset or null.</dd>
|
|
|
|
<dt><i>EXINIT</i></dt>
|
|
|
|
<dd>Determine a list of <i>ex</i> commands that are executed on editor start-up. See the EXTENDED DESCRIPTION section for more
|
|
details of the initialization phase.</dd>
|
|
|
|
<dt><i>HOME</i></dt>
|
|
|
|
<dd>Determine a pathname of a directory that shall be searched for an editor start-up file named <b>.exrc</b>; see the EXTENDED
|
|
DESCRIPTION section.</dd>
|
|
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_COLLATE</i></dt>
|
|
|
|
<dd><br>
|
|
Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements within regular
|
|
expressions.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments and input files), the behavior of character classes within regular expressions, the
|
|
classification of characters as uppercase or lowercase letters, the case conversion of letters, and the detection of word
|
|
boundaries.</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
|
|
error.</dd>
|
|
|
|
<dt><i>LINES</i></dt>
|
|
|
|
<dd>Override the system-selected vertical screen size, used as the number of lines in a screenful and the vertical screen size in
|
|
visual mode. See the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8,
|
|
Environment Variables</a> for valid values and results when it is unset or null.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
|
|
<dt><i>PATH</i></dt>
|
|
|
|
<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>,
|
|
and <b>write</b>, and the open and visual mode command <b>!</b>; see the description of command search and execution in <a href=
|
|
"xcu_chap02.html#tag_02_09_01_01"><i>Command Search and Execution</i></a> .</dd>
|
|
|
|
<dt><i>SHELL</i></dt>
|
|
|
|
<dd>Determine the preferred command line interpreter for use as the default value of the <b>shell</b> edit option.</dd>
|
|
|
|
<dt><i>TERM</i></dt>
|
|
|
|
<dd>Determine the name of the terminal type. If this variable is unset or null, an unspecified default terminal type shall be
|
|
used.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following term is used in this and following sections to specify command and asynchronous event actions:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>complete write</i></dt>
|
|
|
|
<dd><br>
|
|
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
|
|
saving of the edit buffer caused by the user executing the <i>ex</i> <b>preserve</b> command. Writing the contents of the edit
|
|
buffer to a temporary file that will be removed when the editor exits shall not be considered a complete write.</dd>
|
|
</dl>
|
|
|
|
<p>The following actions shall be taken upon receipt of signals:</p>
|
|
|
|
<dl compact>
|
|
<dt>SIGINT</dt>
|
|
|
|
<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
|
|
shall exit with a non-zero exit status.
|
|
|
|
<p>Otherwise, if executing an open or visual text input mode command, <i>ex</i> in receipt of SIGINT shall behave identically to
|
|
its receipt of the <ESC> character.</p>
|
|
|
|
<p>Otherwise:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If executing an <i>ex</i> text input mode command, all input lines that have been completely entered shall be resolved into the
|
|
edit buffer, and any partially entered line shall be discarded.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If there is a currently executing command, it shall be aborted and a message displayed. Unless otherwise specified by the
|
|
<i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> command descriptions, it is unspecified whether any lines modified by the
|
|
executing command appear modified, or as they were before being modified by the executing command, in the buffer.</p>
|
|
|
|
<p>If the currently executing command was a motion command, its associated command shall be discarded.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If in open or visual command mode, the terminal shall be alerted.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The editor shall then return to command mode.</p>
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
|
|
<dt>SIGCONT</dt>
|
|
|
|
<dd>The screen shall be refreshed if in open or visual mode.</dd>
|
|
|
|
<dt>SIGHUP</dt>
|
|
|
|
<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
|
|
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
|
|
return to command or text input mode, and shall terminate with a non-zero exit status.</dd>
|
|
|
|
<dt>SIGTERM</dt>
|
|
|
|
<dd>Refer to SIGHUP.</dd>
|
|
</dl>
|
|
|
|
<p>The action taken for all other signals is unspecified.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard output shall be used only for writing prompts to the user, for informational messages, and for writing lines from
|
|
the file.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>The output from <i>ex</i> shall be text files.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>Only the <i>ex</i> mode of the editor is described in this section. See <a href="vi.html"><i>vi</i></a> for additional editing
|
|
capabilities available in <i>ex</i>.</p>
|
|
|
|
<p>When an error occurs, <i>ex</i> shall write a message. If the terminal supports a standout mode (such as inverse video), the
|
|
message shall be written in standout mode. If the terminal does not support a standout mode, and the edit option <b>errorbells</b>
|
|
is set, an alert action shall precede the error message.</p>
|
|
|
|
<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.
|
|
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
|
|
re-entered) by typing a period ( <tt>'.'</tt> ) alone at the beginning of a line.</p>
|
|
|
|
<h5><a name="tag_04_45_13_01"></a>Initialization in ex and vi</h5>
|
|
|
|
<p>The following symbols are used in this and following sections to specify locations in the edit buffer:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>alternate and current pathnames</i></dt>
|
|
|
|
<dd><br>
|
|
Two pathnames, named <i>current</i> and <i>alternate</i>, are maintained by the editor. Any <i>ex</i> commands that take filenames
|
|
as arguments shall set them as follows:
|
|
|
|
<ol>
|
|
<li>
|
|
<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>
|
|
<b>tag</b> command replaces the contents of the edit buffer.</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<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
|
|
file indicated by the tag, and the alternate pathname shall be set to the previous value of the current pathname.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, the alternate pathname shall be set to the <i>file</i> argument.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If a <i>file</i> argument is specified to the <i>ex</i> <b>next</b> command:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>If the command replaces the contents of the edit buffer, the current pathname shall be set to the first <i>file</i> argument,
|
|
and the alternate pathname shall be set to the previous value of the current pathname.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<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
|
|
<i>file</i> argument, and the alternate pathname shall be set to the previous value of the current pathname.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<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
|
|
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>
|
|
<b>xit</b> command:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>If the current pathname has no value, the current pathname shall be set to the <i>file</i> argument.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, the alternate pathname shall be set to the <i>file</i> argument.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>If the alternate pathname is set to the previous value of the current pathname when the current pathname had no previous value,
|
|
then the alternate pathname shall have no value as a result.</p>
|
|
</dd>
|
|
|
|
<dt><i>current line</i></dt>
|
|
|
|
<dd><br>
|
|
The line of the edit buffer referenced by the cursor. Each command description specifies the current line after the command has
|
|
been executed, as the <i>current line value</i>. When the edit buffer contains no lines, the current line shall be zero; see <a
|
|
href="#tag_04_45_13_02">Addressing in ex</a> .</dd>
|
|
|
|
<dt><i>current column</i></dt>
|
|
|
|
<dd><br>
|
|
The current display line column occupied by the cursor. (The columns shall be numbered beginning at 1.) Each command description
|
|
specifies the current column after the command has been executed, as the <i>current column</i> value. This column is an
|
|
<i>ideal</i> column that is remembered over the lifetime of the editor. The actual display line column upon which the cursor rests
|
|
may be different from the current column; see the cursor positioning discussion in <a href="vi.html#tag_04_167_13_02"><i>Command
|
|
Descriptions in vi</i></a> .</dd>
|
|
|
|
<dt><i>set to non-<blank></i></dt>
|
|
|
|
<dd><br>
|
|
A description for a current column value, meaning that the current column shall be set to the last display line column on which is
|
|
displayed any part of the first non- <blank> of the line. If the line has no non- <blank> non- <newline>s, the
|
|
current column shall be set to the last display line column on which is displayed any part of the last non- <newline> in the
|
|
line. If the line is empty, the current column shall be set to column position 1.</dd>
|
|
</dl>
|
|
|
|
<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
|
|
edit buffer may be limited to the number of characters that will fit in the display. If either limit is exceeded during editing, an
|
|
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
|
|
the edit session may be terminated.</p>
|
|
|
|
<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
|
|
complete write, it shall be equivalent to a SIGHUP asynchronous event. If the system crashes, it shall be equivalent to a SIGHUP
|
|
asynchronous event.</p>
|
|
|
|
<p>During initialization (before the first file is copied into the edit buffer or any user commands from the terminal are
|
|
processed) the following shall occur:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the environment variable <i>EXINIT</i> is set, the editor shall execute the <i>ex</i> commands contained in that
|
|
variable.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <i>EXINIT</i> variable is not set, and all of the following are true:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>The <i>HOME</i> environment variable is not null and not empty.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The file <b>.exrc</b> in the directory referred to by the <i>HOME</i> environment variable:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Exists</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Is owned by the same user ID as the real user ID of the process or the process has appropriate privileges</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Is not writable by anyone other than the owner</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>the editor shall execute the <i>ex</i> commands contained in that file.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If and only if all of the following are true:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>The current directory is not referred to by the <i>HOME</i> environment variable.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<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
|
|
<i>HOME</i> environment variable sets the editor option <b>exrc</b>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The <b>.exrc</b> file in the current directory:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Exists</p>
|
|
</li>
|
|
|
|
<li>
|
|
<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>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Is not writable by anyone other than the owner</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>the editor shall attempt to execute the <i>ex</i> commands contained in that file.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<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
|
|
ownership or permission reasons, it shall be an error.</p>
|
|
|
|
<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,
|
|
as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<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
|
|
specified argument, with the exception that if tag processing does not result in a file to edit, the effect shall be as described
|
|
in step 3. below.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<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>
|
|
command was entered with the first of those arguments as its <i>file</i> argument.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, the effect shall be as if the <i>ex</i> <b>edit</b> command was entered with a nonexistent filename as its
|
|
<i>file</i> argument. It is unspecified whether this action shall set the current pathname. In an implementation where this action
|
|
does not set the current pathname, any editor command using the current pathname shall fail until an editor command sets the
|
|
current pathname.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<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>
|
|
option is edited, if recovery information has previously been saved about it, that information shall be recovered and the editor
|
|
shall behave as if the contents of the edit buffer have already been modified. If there are multiple instances of the file to be
|
|
recovered, the one most recently saved shall be recovered, and an informational message that there are previous versions of the
|
|
file that can be recovered shall be written. If no recovery information about a file is available, an informational message to this
|
|
effect shall be written, and the edit shall proceed as usual.</p>
|
|
|
|
<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
|
|
which recovery information is available, when the <b>-r</b> option is specified) replaces or initializes the contents of the edit
|
|
buffer, the current line shall be set to the last line of the edit buffer, the current column shall be set to non- <blank>,
|
|
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
|
|
shall not be set as described for the command associated with the replacement or initialization of the edit buffer contents.
|
|
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
|
|
executed and then the movement to the tag shall be performed.</p>
|
|
|
|
<p>The current argument list shall initially be set to the filenames specified by the user on the command line. If no filenames are
|
|
specified by the user, the current argument list shall be empty. If the <b>-t</b> option was specified, it is unspecified whether
|
|
any filename resulting from tag processing shall be prepended to the current argument list. In the case where the filename is added
|
|
as a prefix to the current argument list, the current argument list reference shall be set to that filename. In the case where the
|
|
filename is not added as a prefix to the current argument list, the current argument list reference shall logically be located
|
|
before the first of the filenames specified on the command line (for example, a subsequent <i>ex</i> <b>next</b> command shall edit
|
|
the first filename from the command line). If the <b>-t</b> option was not specified, the current argument list reference shall be
|
|
to the first of the filenames on the command line.</p>
|
|
|
|
<h5><a name="tag_04_45_13_02"></a>Addressing in ex</h5>
|
|
|
|
<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,
|
|
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
|
|
by a command. The current line number is the address of the current line. In each command description, the effect of the command on
|
|
the current line number and the current column is described.</p>
|
|
|
|
<p>Addresses are constructed as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The character <tt>'.'</tt> (period) shall address the current line.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The character <tt>'$'</tt> shall address the last line of the edit buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The positive decimal number <i>n</i> shall address the <i>n</i>th line of the edit buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<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 from the portable character set or one of the characters <tt>'`'</tt> or <tt>'"</tt> . It shall be an error if the line
|
|
that was 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> or <b>k</b> commands, or the <a href="../utilities/vi.html"><i>vi</i></a> <b>m</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A regular expression enclosed by slashes ( <tt>'/'</tt> ) shall address the first line found by searching forwards from the line
|
|
following the current line toward the end of the edit buffer and stopping at the first line for which the line excluding the
|
|
terminating <newline> matches the regular expression. As stated in <a href="#tag_04_45_13_58">Regular Expressions in ex</a> ,
|
|
an address consisting of a null regular expression delimited by slashes <tt>"//"</tt> shall address the next line for which the
|
|
line excluding the terminating <newline> matches the last regular expression encountered. In addition, the second slash can
|
|
be omitted at the end of a command line. If the <b>wrapscan</b> edit option 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 the entire edit buffer is searched. Within the
|
|
regular expression, the sequence <tt>"\/"</tt> shall represent a literal slash instead of the regular expression delimiter.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A regular expression enclosed in question marks ( <tt>'?'</tt> ) shall address the first line found by searching backwards from
|
|
the line preceding the current line toward the beginning of the edit buffer and stopping at the first line for which the line
|
|
excluding the terminating <newline> matches the regular expression. An address consisting of a null regular expression
|
|
delimited by question marks <tt>"??"</tt> shall address the previous line for which the line excluding the terminating
|
|
<newline> matches the last regular expression encountered. In addition, the second question mark can be omitted at the end of
|
|
a command line. If the <b>wrapscan</b> edit option is set, the search shall wrap 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 that the entire edit buffer is searched. Within
|
|
the regular expression, the sequence <tt>"\?"</tt> shall represent a literal question mark instead of the RE delimiter.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A plus sign ( <tt>'+'</tt> ) or a minus sign ( <tt>'-'</tt> ) followed by a decimal number shall address the current line plus
|
|
or minus the number. A <tt>'+'</tt> or <tt>'-'</tt> not followed by a decimal number shall address the current line plus or minus
|
|
1.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Addresses can be followed by zero or more address offsets, optionally <blank>-separated. Address offsets are constructed
|
|
as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>A <tt>'+'</tt> or <tt>'-'</tt> immediately followed by a decimal number shall add (subtract) the indicated number of lines to
|
|
(from) the address. A <tt>'+'</tt> or <tt>'-'</tt> not followed by a decimal number shall add (subtract) 1 to (from) the
|
|
address.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>A decimal number shall add the indicated number of lines to the address.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<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
|
|
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>
|
|
|
|
<p>Commands take zero, one, or two addresses; see the descriptions of <i>1addr</i> and <i>2addr</i> in <a href=
|
|
"#tag_04_45_13_10">Command Descriptions in ex</a> . If more than the required number of addresses are provided to a command that
|
|
requires zero addresses, it shall be an error. Otherwise, if more than the required number of addresses are provided to a command,
|
|
the addresses specified first shall be evaluated and then discarded until the maximum number of valid addresses remain.</p>
|
|
|
|
<p>Addresses shall be separated from each other by a comma ( <tt>','</tt> ) or a semicolon ( <tt>';'</tt> ). If no address is
|
|
specified before or after a comma or semicolon separator, it shall be as if the address of the current line was specified before or
|
|
after the separator. In the case of a semicolon separator, the current line ( <tt>'.'</tt> ) shall be set to the first address, and
|
|
only then will the next address be calculated. This feature can be used to determine the starting line for forwards and backwards
|
|
searches (see rules 5. and 6.).</p>
|
|
|
|
<p>A percent sign ( <tt>'%'</tt> ) shall be equivalent to entering the two addresses <tt>"1,$"</tt> .</p>
|
|
|
|
<p>Any delimiting <blank>s between addresses, address separators, or address offsets shall be discarded.</p>
|
|
|
|
<h5><a name="tag_04_45_13_03"></a>Command Line Parsing in ex</h5>
|
|
|
|
<p>The following symbol is used in this and following sections to describe parsing behavior:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>escape</i></dt>
|
|
|
|
<dd>If a character is referred to as "backslash-escaped" or " <control>-V-escaped," it shall mean that the character
|
|
acquired or lost a special meaning by virtue of being preceded, respectively, by a backslash or <control>-V character. Unless
|
|
otherwise specified, the escaping character shall be discarded at that time and shall not be further considered for any
|
|
purpose.</dd>
|
|
</dl>
|
|
|
|
<p>Command-line parsing shall be done in the following steps. For each step, characters already evaluated shall be ignored; that
|
|
is, the phrase "leading character" refers to the next character that has not yet been evaluated.</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Leading colon characters shall be skipped.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Leading <blank>s shall be skipped.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the leading character is a double-quote character, the characters up to and including the next non-backslash-escaped
|
|
<newline> shall be discarded, and any subsequent characters shall be parsed as a separate command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Leading characters that can be interpreted as addresses shall be evaluated; see <a href="#tag_04_45_13_02">Addressing in ex</a>
|
|
.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Leading <blank>s shall be skipped.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the next character is a vertical-line character or a <newline>:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>If the next character is a <newline>:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<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>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the last command was terminated by a vertical-line character, no action shall be taken; for example, the command
|
|
<tt>"||<newline>"</tt> shall execute two implied commands, not three.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, step 6.b. shall apply.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<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
|
|
any <i>ex</i> command shall be remembered and shall apply to this implied command. Executing the <i>ex</i> <b>number</b>,
|
|
<b>print</b>, or <b>list</b> command shall set the remembered flags to <b>#</b>, nothing, and <b>l</b>, respectively, plus any
|
|
other flags specified for that execution of the <b>number</b>, <b>print</b>, or <b>list</b> command.</p>
|
|
|
|
<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
|
|
line shall be incremented by 1 before the command is executed. If incrementing the current line would result in an address past the
|
|
last line in the edit buffer, the command shall fail, and the increment shall not happen.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The <newline> or vertical-line character shall be discarded and any subsequent characters shall be parsed as a separate
|
|
command.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The command name shall be comprised of the next character (if the character is not alphabetic), or the next character and any
|
|
subsequent alphabetic characters (if the character is alphabetic), with the following exceptions:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>Commands that consist of any prefix of the characters in the command name <b>delete</b>, followed immediately by any of the
|
|
characters <tt>'l'</tt> , <tt>'p'</tt> , <tt>'+'</tt> , <tt>'-'</tt> , or <tt>'#'</tt> shall be interpreted as a <b>delete</b>
|
|
command, followed by a <blank>, followed by the characters that were not part of the prefix of the <b>delete</b> command. The
|
|
maximum number of characters shall be matched to the command name <b>delete</b>; for example, <tt>"del"</tt> shall not be treated
|
|
as <tt>"de"</tt> followed by the flag <b>l</b>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<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
|
|
equivalent to the mark command followed by a <blank>, followed by the character that followed the <tt>'k'</tt> .</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Commands that consist of the character <tt>'s'</tt> , followed by characters that could be interpreted as valid options to the
|
|
<b>s</b> command, shall be the equivalent of the <b>s</b> command, without any pattern or replacement values, followed by a
|
|
<blank>, followed by the characters after the <tt>'s'</tt> .</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The command name shall be matched against the possible command names, and a command name that contains a prefix matching the
|
|
characters specified by the user shall be the executed command. In the case of commands where the characters specified by the user
|
|
could be ambiguous, the executed command shall be as follows:</p>
|
|
|
|
<center>
|
|
<table border="1" cellpadding="3" align="center">
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent"><b>a</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>append</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">n</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>next</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>t</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">t</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent"><b>c</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>change</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">p</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>print</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>u</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">undo</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent"><b>ch</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>change</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">pr</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>print</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>un</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">undo</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent"><b>e</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>edit</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">r</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>read</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>v</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">v</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent"><b>m</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>move</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">re</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>read</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>w</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">write</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr valign="top">
|
|
<td align="left">
|
|
<p class="tent"><b>ma</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>mark</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent">s</p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b>s</b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"> </p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
<td align="left">
|
|
<p class="tent"><b> </b></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
|
|
<p>Implementation extensions with names causing similar ambiguities shall not be checked for a match until all possible matches for
|
|
commands specified by IEEE Std 1003.1-2001 have been checked.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the command is a <b>!</b> command, or if the command is a <b>read</b> command followed by zero or more <blank>s and a
|
|
<b>!</b>, or if the command is a <b>write</b> command followed by one or more <blank>s and a <b>!</b>, the rest of the
|
|
command shall include all characters up to a non-backslash-escaped <newline>. The <newline> shall be discarded and any
|
|
subsequent characters shall be parsed as a separate <i>ex</i> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the command is an <b>edit</b>, <b>ex</b>, or <b>next</b> command, or a <b>visual</b> command while in open or
|
|
visual mode, the next part of the command shall be parsed as follows:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>Any <tt>'!'</tt> character immediately following the command shall be skipped and be part of the command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Any leading <blank>s shall be skipped and be part of the command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the next character is a <tt>'+'</tt> , characters up to the first non-backslash-escaped <newline> or
|
|
non-backslash-escaped <blank> shall be skipped and be part of the command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The rest of the command shall be determined by the steps specified in paragraph 12.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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 command shall be
|
|
parsed as follows:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>Any leading <blank>s shall be skipped and be part of the command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the next character is not an alphanumeric, double-quote, <newline>, backslash, or vertical-line character:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The next character shall be used as a command delimiter.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the command is a <b>global</b>, <b>open</b>, or <b>v</b> command, characters up to the first non-backslash-escaped
|
|
<newline>, or first non-backslash-escaped delimiter character, shall be skipped and be part of the command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the command is an <b>s</b> command, characters up to the first non-backslash-escaped <newline>, or second
|
|
non-backslash-escaped delimiter character, shall be skipped and be part of the command.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the command is a <b>global</b> or <b>v</b> command, characters up to the first non-backslash-escaped <newline> shall be
|
|
skipped and be part of the command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, the rest of the command shall be determined by the steps specified in paragraph 12.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>If the command was a <b>map</b>, <b>unmap</b>, <b>abbreviate</b>, or <b>unabbreviate</b> command, characters up to the first
|
|
non- <control>-V-escaped <newline>, vertical-line, or double-quote character shall be skipped and be part of the
|
|
command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, characters up to the first non-backslash-escaped <newline>, vertical-line, or double-quote character shall be
|
|
skipped and be part of the command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the command was an <b>append</b>, <b>change</b>, or <b>insert</b> command, and the step 12.b. ended at a vertical-line
|
|
character, any subsequent characters, up to the next non-backslash-escaped <newline> shall be used as input text to the
|
|
command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the command was ended by a double-quote character, all subsequent characters, up to the next non-backslash-escaped
|
|
<newline>, shall be discarded.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The terminating <newline> or vertical-line character shall be discarded and any subsequent characters shall be parsed as a
|
|
separate <i>ex</i> command.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Command arguments shall be parsed as described by the Synopsis and Description of each individual <i>ex</i> command. This
|
|
parsing shall not be <blank>-sensitive, except for the <b>!</b> argument, which must follow the command name without
|
|
intervening <blank>s, and where it would otherwise be ambiguous. For example, <i>count</i> and <i>flag</i> arguments need not
|
|
be <blank>-separated because <tt>"d22p"</tt> is not ambiguous, but <i>file</i> arguments to the <i>ex</i> <b>next</b> command
|
|
must be separated by one or more <blank>s. Any <blank> in command arguments for the <b>abbreviate</b>,
|
|
<b>unabbreviate</b>, <b>map</b>, and <b>unmap</b> commands can be <control>-V-escaped, in which case the <blank> shall
|
|
not be used as an argument delimiter. Any <blank> in the command argument for any other command can be backslash-escaped, in
|
|
which case that <blank> shall not be used as an argument delimiter.</p>
|
|
|
|
<p>Within command arguments for the <b>abbreviate</b>, <b>unabbreviate</b>, <b>map</b>, and <b>unmap</b> commands, any character
|
|
can be <control>-V-escaped. All such escaped characters shall be treated literally and shall have no special meaning. Within
|
|
command arguments for all other <i>ex</i> commands that are not regular expressions or replacement strings, any character that
|
|
would otherwise have a special meaning can be backslash-escaped. Escaped characters shall be treated literally, without special
|
|
meaning as shell expansion characters or <tt>'!'</tt> , <tt>'%'</tt> , and <tt>'#'</tt> expansion characters. See <a href=
|
|
"#tag_04_45_13_58">Regular Expressions in ex</a> and <a href="#tag_04_45_13_59">Replacement Strings in ex</a> for descriptions of
|
|
command arguments that are regular expressions or replacement strings.</p>
|
|
|
|
<p>Non-backslash-escaped <tt>'%'</tt> characters appearing in <i>file</i> arguments to any <i>ex</i> command shall be replaced by
|
|
the current pathname; unescaped <tt>'#'</tt> characters shall be replaced by the alternate pathname. It shall be an error if
|
|
<tt>'%'</tt> or <tt>'#'</tt> characters appear unescaped in an argument and their corresponding values are not set.</p>
|
|
|
|
<p>Non-backslash-escaped <tt>'!'</tt> characters in the arguments to either the <i>ex</i> <b>!</b> command or the open and visual
|
|
mode <b>!</b> command, or in the arguments to the <i>ex</i> <b>read</b> command, where the first non- <blank> after the
|
|
command name is a <tt>'!'</tt> character, or in the arguments to the <i>ex</i> <b>write</b> command where the command name is
|
|
followed by one or more <blank>s and the first non- <blank> after the command name is a <tt>'!'</tt> character, shall
|
|
be replaced with the arguments to the last of those three commands as they appeared after all unescaped <tt>'%'</tt> , <tt>'#'</tt>
|
|
, and <tt>'!'</tt> characters were replaced. It shall be an error if <tt>'!'</tt> characters appear unescaped in one of these
|
|
commands and there has been no previous execution of one of these commands.</p>
|
|
|
|
<p>If an error occurs during the parsing or execution of an <i>ex</i> command:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>An informational message to this effect shall be written. Execution of the <i>ex</i> command shall stop, and the cursor (for
|
|
example, the current line and column) shall not be further modified.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <i>ex</i> command resulted from a map expansion, all characters from that map expansion shall be discarded, except as
|
|
otherwise specified by the <b>map</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the <i>ex</i> command resulted from the processing of an <i>EXINIT</i> environment variable, a <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>, <b>ex</b>,
|
|
<b>next</b>, or <b>visual</b> command, no further commands from the source of the commands shall be executed.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the <i>ex</i> command resulted from the execution of a buffer or a <b>global</b> or <b>v</b> command, no further
|
|
commands caused by the execution of the buffer or the <b>global</b> or <b>v</b> command shall be executed.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the <i>ex</i> command was not terminated by a <newline>, all characters up to and including the next
|
|
non-backslash-escaped <newline> shall be discarded.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<h5><a name="tag_04_45_13_04"></a>Input Editing in ex</h5>
|
|
|
|
<p>The following symbol is used in this and the following sections to specify command actions:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>word</i></dt>
|
|
|
|
<dd>In the POSIX locale, a word consists of a maximal sequence of letters, digits, and underscores, delimited at both ends by
|
|
characters other than letters, digits, or underscores, or by the beginning or end of a line or the edit buffer.</dd>
|
|
</dl>
|
|
|
|
<p>When accepting input characters from the user, in either <i>ex</i> command mode or <i>ex</i> text input mode, <i>ex</i> shall
|
|
enable canonical mode input processing, as defined in the System Interfaces volume of IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>If in <i>ex</i> text input mode:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the <b>number</b> edit option is set, <i>ex</i> shall prompt for input using the line number that would be assigned to the
|
|
line if it is entered, in the format specified for the <i>ex</i> <b>number</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <b>autoindent</b> edit option is set, <i>ex</i> shall prompt for input using <b>autoindent</b> characters, as described
|
|
by the <b>autoindent</b> edit option. <b>autoindent</b> characters shall follow the line number, if any.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>If in <i>ex</i> command mode:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the <b>prompt</b> edit option is set, input shall be prompted for using a single <tt>':'</tt> character; otherwise, there
|
|
shall be no prompt.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>The input characters in the following sections shall have the following effects on the input line.</p>
|
|
|
|
<h5><a name="tag_04_45_13_05"></a>Scroll</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>eof
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>See the description of the <a href="../utilities/stty.html"><i>stty</i></a> <i>eof</i> character in <a href=
|
|
"stty.html"><i>stty</i></a> .</p>
|
|
|
|
<p>If in <i>ex</i> command mode:</p>
|
|
|
|
<blockquote>If the <i>eof</i> character is the first character entered on the line, the line shall be evaluated as if it contained
|
|
two characters: a <control>-D and a <newline>.
|
|
|
|
<p>Otherwise, the <i>eof</i> character shall have no special meaning.</p>
|
|
</blockquote>
|
|
|
|
<br>
|
|
<p>If in <i>ex</i> text input mode:</p>
|
|
|
|
<blockquote>If the cursor follows an <b>autoindent</b> character, the <b>autoindent</b> characters in the line shall be modified so
|
|
that a part of the next text input character will be displayed on the first column in the line after the previous <b>shiftwidth</b>
|
|
edit option column boundary, and the user shall be prompted again for input for the same line.
|
|
|
|
<p>Otherwise, if the cursor follows a <tt>'0'</tt> , which follows an <b>autoindent</b> character, and the <tt>'0'</tt> was the
|
|
previous text input character, the <tt>'0'</tt> and all <b>autoindent</b> characters in the line shall be discarded, and the user
|
|
shall be prompted again for input for the same line.</p>
|
|
|
|
<p>Otherwise, if the cursor follows a <tt>'^'</tt> , which follows an <b>autoindent</b> character, and the <tt>'^'</tt> was the
|
|
previous text input character, the <tt>'^'</tt> and all <b>autoindent</b> characters in the line shall be discarded, and the user
|
|
shall be prompted again for input for the same line. In addition, the <b>autoindent</b> level for the next input line shall be
|
|
derived from the same line from which the <b>autoindent</b> level for the current input line was derived.</p>
|
|
|
|
<p>Otherwise, if there are no <b>autoindent</b> or text input characters in the line, the <i>eof</i> character shall be
|
|
discarded.</p>
|
|
|
|
<p>Otherwise, the <i>eof</i> character shall have no special meaning.</p>
|
|
</blockquote>
|
|
|
|
<h5><a name="tag_04_45_13_06"></a><newline></h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt><newline>
|
|
<br>
|
|
<control>-J
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If in <i>ex</i> command mode:</p>
|
|
|
|
<blockquote>Cause the command line to be parsed; <control>-J shall be mapped to the <newline> for this
|
|
purpose.</blockquote>
|
|
|
|
<p>If in <i>ex</i> text input mode:</p>
|
|
|
|
<blockquote>Terminate the current line. If there are no characters other than <b>autoindent</b> characters on the line, all
|
|
characters on the line shall be discarded.
|
|
|
|
<p>Prompt for text input on a new line after the current line. If the <b>autoindent</b> edit option is set, an appropriate number
|
|
of <b>autoindent</b> characters shall be added as a prefix to the line as described by the <i>ex</i> <b>autoindent</b> edit
|
|
option.</p>
|
|
</blockquote>
|
|
|
|
<h5><a name="tag_04_45_13_07"></a><backslash></h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt><backslash>
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Allow the entry of a subsequent <newline> or <control>-J as a literal character, removing any special meaning that
|
|
it may have to the editor during text input mode. The backslash character shall be retained and evaluated when the command line is
|
|
parsed, or retained and included when the input text becomes part of the edit buffer.</p>
|
|
|
|
<h5><a name="tag_04_45_13_08"></a><control>-V</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt><control>-V
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Allow the entry of any subsequent character as a literal character, removing any special meaning that it may have to the editor
|
|
during text input mode. The <control>-V character shall be discarded before the command line is parsed or the input text
|
|
becomes part of the edit buffer.</p>
|
|
|
|
<p>If the "literal next" functionality is performed by the underlying system, it is implementation-defined whether a character
|
|
other than <control>-V performs this function.</p>
|
|
|
|
<h5><a name="tag_04_45_13_09"></a><control>-W</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt><control>-W
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Discard the <control>-W, and the word previous to it in the input line, including any <blank>s following the word
|
|
and preceding the <control>-W. If the "word erase" functionality is performed by the underlying system, it is
|
|
implementation-defined whether a character other than <control>-W performs this function.</p>
|
|
|
|
<h5><a name="tag_04_45_13_10"></a>Command Descriptions in ex</h5>
|
|
|
|
<p>The following symbols are used in this section to represent command modifiers. Some of these modifiers can be omitted, in which
|
|
case the specified defaults shall be used.</p>
|
|
|
|
<dl compact>
|
|
<dt><i>1addr</i></dt>
|
|
|
|
<dd>A single line address, given in any of the forms described in <a href="#tag_04_45_13_02">Addressing in ex</a> ; the default
|
|
shall be the current line ( <tt>'.'</tt> ), unless otherwise specified.
|
|
|
|
<p>If the line address is zero, it shall be an error, unless otherwise specified in the following command descriptions.</p>
|
|
|
|
<p>If the edit buffer is empty, and the address is specified with a command other than <b>=</b>, <b>append</b>, <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>
|
|
</dd>
|
|
|
|
<dt><i>2addr</i></dt>
|
|
|
|
<dd>Two addresses specifying an inclusive range of lines. If no addresses are specified, the default for <i>2addr</i> shall be the
|
|
current line only ( <tt>".,."</tt> ), unless otherwise specified in the following command descriptions. If one address is
|
|
specified, <i>2addr</i> shall specify that line only, unless otherwise specified in the following command descriptions.
|
|
|
|
<p>It shall be an error if the first address is greater than the second address.</p>
|
|
|
|
<p>If the edit buffer is empty, and the two addresses are specified with a command other than the <b>!</b>, <b>write</b>,
|
|
<b>wq</b>, or <b>xit</b> commands, or either address is not zero, it shall be an error.</p>
|
|
</dd>
|
|
|
|
<dt><i>count</i></dt>
|
|
|
|
<dd>A positive decimal number. If <i>count</i> is specified, it shall be equivalent to specifying an additional address to the
|
|
command, unless otherwise specified by the following command descriptions. The additional address shall be equal to the last
|
|
address specified to the command (either explicitly or by default) plus <i>count</i>-1.
|
|
|
|
<p>If this would result in an address greater than the last line of the edit buffer, it shall be corrected to equal the last line
|
|
of the edit buffer.</p>
|
|
</dd>
|
|
|
|
<dt><i>flags</i></dt>
|
|
|
|
<dd>One or more of the characters <tt>'+'</tt> , <tt>'-'</tt> , <tt>'#'</tt> , <tt>'p'</tt> , or <tt>'l'</tt> (ell). The flag
|
|
characters can be <blank>-separated, and in any order or combination. The characters <tt>'#'</tt> , <tt>'p'</tt> , and
|
|
<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>.
|
|
|
|
<p>The lines to be written are as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>All edit buffer lines written during the execution of the <i>ex</i> <b>&</b>, <b>˜</b>, <b>list</b>, <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 <i>flags</i>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>After the completion of an <i>ex</i> command with a flag as an argument, the current line shall be written as specified by
|
|
<i>flags</i>, unless the current line was the last line written by the command.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>The characters <tt>'+'</tt> and <tt>'-'</tt> cause the value of the current line after the execution of the <i>ex</i> command to
|
|
be adjusted by the offset address as described in <a href="#tag_04_45_13_02">Addressing in ex</a> . This adjustment shall occur
|
|
before the current line is written as described in 2. above.</p>
|
|
|
|
<p>The default for <i>flags</i> shall be none.</p>
|
|
</dd>
|
|
|
|
<dt><i>buffer</i></dt>
|
|
|
|
<dd>One of a number of named areas for holding text. The named buffers are specified by the alphanumeric characters of the POSIX
|
|
locale. There shall also be one "unnamed" buffer. When no buffer is specified for editor commands that use a buffer, the unnamed
|
|
buffer shall be used. Commands that store text into buffers shall store the text as it was before the command took effect, and
|
|
shall store text occurring earlier in the file before text occurring later in the file, regardless of how the text region was
|
|
specified. Commands that store text into buffers shall store the text into the unnamed buffer as well as any specified buffer.
|
|
|
|
<p>In <i>ex</i> commands, buffer names are specified as the name by itself. In open or visual mode commands the name is preceded by
|
|
a double quote ( <tt>' )'</tt> character.</p>
|
|
|
|
<p>If the specified buffer name is an uppercase character, and the buffer contents are to be modified, the buffer shall be appended
|
|
to rather than being overwritten. If the buffer is not being modified, specifying the buffer name in lowercase and uppercase shall
|
|
have identical results.</p>
|
|
|
|
<p>There shall also be buffers named by the numbers 1 through 9. In open and visual mode, if a region of text 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 <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 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> 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 the buffer named by
|
|
the next numerically greater value, the contents of buffer 9 shall be discarded, and the region of text shall be copied into buffer
|
|
1. This shall be in addition to copying the text into a user-specified buffer or unnamed buffer, or both. Numeric buffers can be
|
|
specified as a source buffer for open and visual mode commands; however, specifying a numeric buffer as the write target of an open
|
|
or visual mode command shall have unspecified results.</p>
|
|
|
|
<p>The text of each buffer shall have the characteristic of being in either line or character mode. Appending text to a non-empty
|
|
buffer shall set the mode to match the characteristic of the text being appended. Appending text to a buffer shall 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 line mode.
|
|
The <i>ex</i> commands that use buffers as the source of text specify individually how buffers of different modes are handled. Each
|
|
open or visual mode command that uses buffers for any purpose specifies individually the mode of the text stored into the buffer
|
|
and how buffers of different modes are handled.</p>
|
|
</dd>
|
|
|
|
<dt><i>file</i></dt>
|
|
|
|
<dd>Command text used to derive a pathname. The default shall be the current pathname, as defined previously, in which case, if no
|
|
current pathname has yet been established it shall be an error, except where specifically noted in the individual command
|
|
descriptions that follow. If the command text contains any of the characters <tt>'˜'</tt> , <tt>'{'</tt> , <tt>'['</tt> ,
|
|
<tt>'*'</tt> , <tt>'?'</tt> , <tt>'$'</tt> , <tt>'`'</tt> , <tt>'"</tt> , <tt>' ,'</tt> and <tt>'\'</tt> , it shall be subjected
|
|
to the process of "shell expansions", as described below; if more than a single pathname results and the command expects only
|
|
one, it shall be an error.
|
|
|
|
<p>The process of shell expansions in the editor shall be done as follows. The <i>ex</i> utility shall pass two arguments to the
|
|
program named by the shell edit option; the first shall be <b>-c</b>, and the second shall be the string <tt>"echo"</tt> and the
|
|
command text as a single argument. The standard output and standard error of that command shall replace the command text.</p>
|
|
</dd>
|
|
|
|
<dt><b>!</b></dt>
|
|
|
|
<dd>A character that can be appended to the command name to modify its operation, as detailed in the individual command
|
|
descriptions. With the exception of the <i>ex</i> <b>read</b>, <b>write</b>, and <b>!</b> commands, the <tt>'!'</tt> character
|
|
shall only act as a modifier if there are no <blank>s between it and the command name.</dd>
|
|
|
|
<dt><i>remembered search direction</i></dt>
|
|
|
|
<dd><br>
|
|
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
|
|
direction in the edit buffer based on a remembered search direction, which is initially unset, and is set by the <i>ex</i>
|
|
<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
|
|
<b>?</b> commands.</dd>
|
|
</dl>
|
|
|
|
<h5><a name="tag_04_45_13_11"></a>Abbreviate</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>ab</tt><b>[</b><i>breviate</i><b>][</b><i>lhs rhs</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <i>lhs</i> and <i>rhs</i> are not specified, write the current list of abbreviations and do nothing more.</p>
|
|
|
|
<p>Implementations may restrict the set of characters accepted in <i>lhs</i> or <i>rh</i>, except that printable characters and
|
|
<blank>s shall not be restricted. Additional restrictions shall be implementation-defined.</p>
|
|
|
|
<p>In both <i>lhs</i> and <i>rhs</i>, any character may be escaped with a <control>-V, in which case the character shall not
|
|
be used to delimit <i>lhs</i> from <i>rhs</i>, and the escaping <control>-V shall be discarded.</p>
|
|
|
|
<p>In open and visual text input mode, if a non-word or <ESC> character that is not escaped by a <control>-V character
|
|
is entered after a word character, a check shall be made for a set of characters matching <i>lhs</i>, 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 <i>lhs</i>.</p>
|
|
|
|
<p>The set of characters that are checked is defined as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If there are no characters inserted before the word and non-word or <ESC> characters that triggered the check, the set of
|
|
characters shall consist of the word character.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the character inserted before the word and non-word or <ESC> characters that triggered the check is a word character,
|
|
the set of characters shall consist of the characters inserted immediately before the triggering characters that are word
|
|
characters, plus the triggering word character.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the character inserted before the word and non-word or <ESC> characters that triggered the check is not a word
|
|
character, the set of characters shall consist of the characters that were inserted before the triggering characters that are
|
|
neither <blank>s nor word characters, plus the triggering word character.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>It is unspecified whether the <i>lhs</i> argument entered for the <i>ex</i> <b>abbreviate</b> and <b>unabbreviate</b> commands
|
|
is replaced in this fashion. Regardless of whether or not the replacement occurs, the effect of the command shall be as if the
|
|
replacement had not occurred.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_12"></a>Append</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>1addr</i><b>]</b> <tt>a</tt><b>[</b><tt>ppend</tt><b>][</b><tt>!</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Enter <i>ex</i> text input mode; the input text shall be placed after the specified line. If line zero is specified, the text
|
|
shall be placed at the beginning of the edit buffer.</p>
|
|
|
|
<p>This command shall be affected by the <b>number</b> and <b>autoindent</b> edit options; following the command name with
|
|
<tt>'!'</tt> shall cause the <b>autoindent</b> edit option setting to be toggled for the duration of this command only.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last input line; if no lines were input, set to the specified line, or to the first line of the
|
|
edit buffer if a line of zero was specified, or zero if the edit buffer is empty.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_13"></a>Arguments</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>ar</tt><b>[</b><i>gs</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Write the current argument list, with the current argument-list entry, if any, between <tt>'['</tt> and <tt>']'</tt>
|
|
characters.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_14"></a>Change</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Enter <i>ex</i> text input mode; the input text shall replace the specified lines. The specified lines shall be copied into the
|
|
unnamed buffer, which shall become a line mode buffer.</p>
|
|
|
|
<p>This command shall be affected by the <b>number</b> and <b>autoindent</b> edit options; following the command name with
|
|
<tt>'!'</tt> shall cause the <b>autoindent</b> edit option setting to be toggled for the duration of this command only.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last input line; if no lines were input, set to the line before the first address, 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 empty.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_15"></a>Change Directory</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>chd</tt><b>[</b><tt>ir</tt><b>][</b><tt>!</tt><b>][</b><i>directory</i><b>]</b><tt>cd</tt><b>[</b><tt>!</tt><b>][</b><i>directory</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Change the current working directory to <i>directory</i>.</p>
|
|
|
|
<p>If no <i>directory</i> argument is specified, and the <i>HOME</i> environment variable is set to a non-null and non-empty value,
|
|
<i>directory</i> shall default to the value named in the <i>HOME</i> environment variable. If the <i>HOME</i> environment variable
|
|
is empty or is undefined, the default value of <i>directory</i> is implementation-defined.</p>
|
|
|
|
<p>If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete write, and the
|
|
current pathname does not begin with a <tt>'/'</tt> , it shall be an error.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_16"></a>Copy</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>]
|
|
[</b><i>2addr</i><b>]</b> <tt>t</tt> <i>1addr</i> <b>[</b><i>flags</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Copy the specified lines after the specified destination line; line zero specifies that the lines shall be placed at the
|
|
beginning of the edit buffer.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last line copied.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_17"></a>Delete</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Delete the specified lines into a buffer (defaulting to the unnamed buffer), which shall become a line-mode buffer.</p>
|
|
|
|
<p>Flags can immediately follow the command name; see <a href="#tag_04_45_13_03">Command Line Parsing in ex</a> .</p>
|
|
|
|
<p><i>Current line</i>: Set to the line following the deleted lines, or to the last line in the edit buffer if that line is past
|
|
the end of the edit buffer, or to zero if the edit buffer is empty.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_18"></a>Edit</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>ex</tt><b>[</b><tt>!</tt><b>][</b><tt>+</tt><i>command</i><b>][</b><i>file</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete write, it
|
|
shall be an error.</p>
|
|
|
|
<p>If <i>file</i> is specified, replace the current contents of the edit buffer with the current contents of <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 buffer with the
|
|
current contents of the file named by the current pathname. If for any reason the current contents of the file cannot be accessed,
|
|
the edit buffer shall be empty.</p>
|
|
|
|
<p>The <b>+</b> <i>command</i> option shall be <blank>-delimited; <blank>s within <b>+</b> <i>command</i> can be
|
|
escaped by preceding them with a backslash character. The <b>+</b> <i>command</i> shall be interpreted as an <i>ex</i> command
|
|
immediately after the contents of the edit buffer have been replaced and the current line and column have been set.</p>
|
|
|
|
<p>If the edit buffer is empty:</p>
|
|
|
|
<p><i>Current line</i>: Set to 0.</p>
|
|
|
|
<p><i>Current column</i>: Set to 1.</p>
|
|
|
|
<p>Otherwise, if executed while in <i>ex</i> command mode or if the <b>+</b> <i>command</i> argument is specified:</p>
|
|
|
|
<p><i>Current line</i>: Set to the last line of the edit buffer.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<p>Otherwise, if <i>file</i> is omitted or results in the current pathname:</p>
|
|
|
|
<p><i>Current line</i>: Set to the first line of the edit buffer.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<p>Otherwise, if <i>file</i> is the same as the last file edited, the line and column shall be set as follows; if the file was
|
|
previously edited, the line and column may be set as follows:</p>
|
|
|
|
<p><i>Current line</i>: Set to the last value held when that file was last edited. If this value is not a valid line in the new
|
|
edit buffer, set to the first line of the edit buffer.</p>
|
|
|
|
<p><i>Current column</i>: If the current line was set to the last value held when the file was last edited, set to the 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 non-
|
|
<blank>.</p>
|
|
|
|
<p>Otherwise:</p>
|
|
|
|
<p><i>Current line</i>: Set to the first line of the edit buffer.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_19"></a>File</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>f</tt><b>[</b><tt>ile</tt><b>][</b><i>file</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If a <i>file</i> argument is specified, the alternate pathname shall be set to the current pathname, and the current pathname
|
|
shall be set to <i>file</i>.</p>
|
|
|
|
<p>Write an informational message. If the file has a current pathname, it shall be included in this message; otherwise, the message
|
|
shall indicate that there is no current pathname. If the edit buffer contains lines, the current line number and the number of
|
|
lines in the edit buffer shall be included in this message; otherwise, the message shall indicate that the edit buffer is empty. If
|
|
the edit buffer has been modified since the last complete write, this fact shall be included in this message. If the
|
|
<b>readonly</b> edit option is set, this fact shall be included in this message. The message may contain other unspecified
|
|
information.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_20"></a>Global</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>]
|
|
[</b><i>2addr</i><b>]</b> <tt>v /</tt><i>pattern</i><tt>/</tt> <b>[</b><i>commands</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The optional <tt>'!'</tt> character after the <b>global</b> command shall be the same as executing the <b>v</b> command.</p>
|
|
|
|
<p>If <i>pattern</i> is empty (for example, <tt>"//"</tt> ) or not specified, the last regular expression used in the editor
|
|
command shall be used as the <i>pattern</i>. The <i>pattern</i> can be delimited by slashes (shown in the Synopsis), as well as any
|
|
non-alphanumeric or non- <blank> other than backslash, vertical line, double quote, or <newline>.</p>
|
|
|
|
<p>If no lines are specified, the lines shall default to the entire file.</p>
|
|
|
|
<p>The <b>global</b> and <b>v</b> commands are logically two-pass operations. First, mark the lines within the specified lines for
|
|
which the line excluding the terminating <newline> matches ( <b>global</b>) or does not match ( <b>v</b> or <b>global!</b>)
|
|
the specified pattern. Second, execute the <i>ex</i> commands given by <i>commands</i>, with the current line ( <tt>'.'</tt> ) set
|
|
to each marked line. If an error occurs during this process, or the contents of the edit buffer are replaced (for example, by the
|
|
<i>ex</i> <b>:edit</b> command) an error message shall be written and no more commands resulting from the execution of this command
|
|
shall be processed.</p>
|
|
|
|
<p>Multiple <i>ex</i> commands can be specified by entering multiple commands on a single line using a vertical line to delimit
|
|
them, or one per line, by escaping each <newline> with a backslash.</p>
|
|
|
|
<p>If no commands are specified:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If in <i>ex</i> command mode, it shall be as if the <b>print</b> command were specified.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, no command shall be executed.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>For the <b>append</b>, <b>change</b>, and <b>insert</b> commands, the input text shall be included as part of the command, and
|
|
the terminating period can be omitted if the command ends the list of commands. The <b>open</b> and <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 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 current line shall be set to the
|
|
next marked line, and open or visual mode reentered, until the list of marked lines is exhausted.</p>
|
|
|
|
<p>The <b>global</b>, <b>v</b>, and <b>undo</b> commands cannot be used in <i>commands</i>. Marked lines may be deleted by commands
|
|
executed for lines occurring earlier in the file than the marked lines. In this case, no commands shall be executed for the deleted
|
|
lines.</p>
|
|
|
|
<p>If the remembered search direction is not set, the <b>global</b> and <b>v</b> commands shall set it to forward.</p>
|
|
|
|
<p>The <b>autoprint</b> and <b>autoindent</b> edit options shall be inhibited for the duration of the <b>g</b> or <b>v</b>
|
|
command.</p>
|
|
|
|
<p><i>Current line</i>: If no commands executed, set to the last marked line. Otherwise, as specified for the executed <i>ex</i>
|
|
commands.</p>
|
|
|
|
<p><i>Current column</i>: If no commands are executed, set to non- <blank>; otherwise, as specified for the individual
|
|
<i>ex</i> commands.</p>
|
|
|
|
<h5><a name="tag_04_45_13_21"></a>Insert</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>1addr</i><b>]</b> <tt>i</tt><b>[</b><tt>nsert</tt><b>][</b><tt>!</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Enter <i>ex</i> text input mode; the input text shall be placed before the specified line. If the line is zero or 1, the text
|
|
shall be placed at the beginning of the edit buffer.</p>
|
|
|
|
<p>This command shall be affected by the <b>number</b> and <b>autoindent</b> edit options; following the command name with
|
|
<tt>'!'</tt> shall cause the <b>autoindent</b> edit option setting to be toggled for the duration of this command only.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last input line; if no lines were input, set to the line before the specified line, 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 empty.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_22"></a>Join</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <i>count</i> is specified:</p>
|
|
|
|
<blockquote>If no address was specified, the <b>join</b> command shall behave as if <i>2addr</i> were the current line and the
|
|
current line plus <i>count</i> (.,. + <i>count</i>).
|
|
|
|
<p>If one address was specified, the <b>join</b> command shall behave as if <i>2addr</i> were the specified address and the
|
|
specified address plus <i>count</i> ( <i>addr</i>, <i>addr</i> + <i>count</i>).</p>
|
|
|
|
<p>If two addresses were specified, the <b>join</b> command shall behave as if an additional address, equal to the last address
|
|
plus <i>count</i> -1 ( <i>addr1</i>, <i>addr2</i>, <i>addr2</i> + <i>count</i> -1), was specified.</p>
|
|
|
|
<p>If this would result in a second address greater than the last line of the edit buffer, it shall be corrected to be equal to the
|
|
last line of the edit buffer.</p>
|
|
</blockquote>
|
|
|
|
<p>If no <i>count</i> is specified:</p>
|
|
|
|
<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
|
|
line (.,. +1).
|
|
|
|
<p>If one address was specified, the <b>join</b> command shall behave as if <i>2addr</i> were the specified address and the next
|
|
line ( <i>addr</i>, <i>addr</i> +1).</p>
|
|
</blockquote>
|
|
|
|
<p>Join the text from the specified lines together into a single line, which shall replace the specified lines.</p>
|
|
|
|
<p>If a <tt>'!'</tt> character is appended to the command name, the <b>join</b> shall be without modification of any line,
|
|
independent of the current locale.</p>
|
|
|
|
<p>Otherwise, in the POSIX locale, set the current line to the first of the specified lines, and then, for each subsequent line,
|
|
proceed as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Discard leading <space>s from the line to be joined.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the line to be joined is now empty, delete it, and skip steps 3 through 5.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the current line ends in a <blank>, or the first character of the line to be joined is a <tt>')'</tt> character, join
|
|
the lines without further modification.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the last character of the current line is a <tt>'.'</tt> , join the lines with two <space>s between them.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, join the lines with a single <space> between them.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p><i>Current line</i>: Set to the first line specified.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_23"></a>List</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>This command shall be equivalent to the <i>ex</i> command:</p>
|
|
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
|
|
<p>See <a href="#tag_04_45_13_31">Print</a> .</p>
|
|
|
|
<h5><a name="tag_04_45_13_24"></a>Map</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>map</tt><b>[</b><tt>!</tt><b>][</b><i>lhs rhs</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <i>lhs</i> and <i>rhs</i> are not specified:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If <tt>'!'</tt> is specified, write the current list of text input mode maps.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, write the current list of command mode maps.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Do nothing more.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Implementations may restrict the set of characters accepted in <i>lhs</i> or <i>rhs</i>, except that printable characters and
|
|
<blank>s shall not be restricted. Additional restrictions shall be implementation-defined. In both <i>lhs</i> and <i>rhs</i>,
|
|
any character can be escaped with a <control>-V, in which case the character shall not be used to delimit <i>lhs</i> from
|
|
<i>rhs</i>, and the escaping <control>-V shall be discarded.</p>
|
|
|
|
<p>If the character <tt>'!'</tt> is appended to the <b>map</b> command name, the mapping shall be effective during 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 <b>map</b>
|
|
definitions at the same time: one for command mode and one for text input mode.</p>
|
|
|
|
<p>For command mode mappings:</p>
|
|
|
|
<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
|
|
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.
|
|
|
|
<p>If any character in the command, other than the first, is escaped using a <control>-V character, that character shall not
|
|
be part of a match to an <i>lhs</i>.</p>
|
|
|
|
<p>It is unspecified whether implementations shall support <b>map</b> commands where the <i>lhs</i> is more than a single character
|
|
in length, where the first character of the <i>lhs</i> is printable.</p>
|
|
|
|
<p>If <i>lhs</i> contains more than one character and the first character is <tt>'#'</tt> , followed by a sequence of digits
|
|
corresponding to a numbered function key, then when this function key is typed it shall be mapped to <i>rhs</i>. Characters other
|
|
than digits following a <tt>'#'</tt> character also represent the function key named by the characters in the <i>lhs</i> 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
|
|
supported.</p>
|
|
</blockquote>
|
|
|
|
<p>For text input mode mappings:</p>
|
|
|
|
<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
|
|
if the corresponding <i>rhs</i> had been entered.
|
|
|
|
<p>If any character in the input text is escaped using a <control>-V character, that character shall not be part of a match
|
|
to an <i>lhs</i>.</p>
|
|
|
|
<p>It is unspecified whether the <i>lhs</i> text entered for subsequent <b>map</b> or <b>unmap</b> commands is replaced with the
|
|
<i>rhs</i> text for the purposes of the screen display; regardless of whether or not the display appears as if 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>
|
|
</blockquote>
|
|
|
|
<p>If only part of the <i>lhs</i> is entered, it is unspecified how long the editor will wait for additional, possibly matching
|
|
characters before treating the already entered characters as not matching the <i>lhs</i>.</p>
|
|
|
|
<p>The <i>rhs</i> characters shall themselves be subject to remapping, unless otherwise specified by the <b>remap</b> edit option,
|
|
except that if the characters in <i>lhs</i> occur as prefix characters in <i>rhs</i>, those characters shall not be remapped.</p>
|
|
|
|
<p>On block-mode terminals, the mapping need not occur immediately (for example, it may occur after the terminal transmits a group
|
|
of characters to the system), but it shall achieve the same results as if it occurred immediately.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_25"></a>Mark</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>1addr</i><b>]</b> <tt>ma</tt><b>[</b><tt>rk</tt><b>]</b> <i>character
|
|
</i><b>[</b><i>1addr</i><b>]</b> <tt>k</tt> <i>character</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Implementations shall support <i>character</i> values of a single lowercase letter of the POSIX locale and the characters
|
|
<tt>'`'</tt> and <tt>'"</tt> ; support of other characters is implementation-defined.</p>
|
|
|
|
<p>If executing the <a href="../utilities/vi.html"><i>vi</i></a> <b>m</b> command, set the specified mark to the current line and
|
|
1-based numbered character referenced by the current column, if any; otherwise, column position 1.</p>
|
|
|
|
<p>Otherwise, set the specified mark to the specified line and 1-based numbered first non- <blank> non- <newline> in
|
|
the line, if any; otherwise, the last non- <newline> in the line, if any; otherwise, column position 1.</p>
|
|
|
|
<p>The mark shall remain associated with the line until the mark is reset or the line is deleted. If a deleted line is restored by
|
|
a subsequent <b>undo</b> command, any marks previously associated with the line, which have not been reset, shall be restored as
|
|
well. Any use of a mark not associated with a current line in the edit buffer shall be an error.</p>
|
|
|
|
<p>The marks <b>`</b> and <b>'</b> shall be set as described previously, immediately before the following events occur in the
|
|
editor:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The use of <tt>'$'</tt> as an <i>ex</i> address</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The use of a positive decimal number as an <i>ex</i> address</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The use of a search command as an <i>ex</i> address</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The use of a mark reference as an <i>ex</i> address</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The use of the following open and visual mode commands: <control>-], <b>%</b>, <b>(</b>, <b>)</b>, <b>[</b>, <b>]</b>,
|
|
<b>{</b>, <b>}</b></p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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> if the
|
|
current line will change as a result of the command</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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 or column
|
|
will change as a result of the command</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The use of the <i>ex</i> mode commands: <b>z</b>, <b>undo</b>, <b>global</b>, <b>v</b></p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>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 as specified
|
|
by rule 6.a. in <a href="#tag_04_45_13_03">Command Line Parsing in ex</a> .</p>
|
|
|
|
<p>For rules 5., 6., and 7., the <b>`</b> and <b>'</b> marks shall not be set if the commands are used as motion commands in open
|
|
and visual mode.</p>
|
|
|
|
<p>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 fails.</p>
|
|
|
|
<p>The <b>`</b> and <b>'</b> marks shall be set as described previously, each time the contents of the edit buffer are 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 not empty,
|
|
before any commands or movements (including commands or movements specified by the <b>-c</b> or <b>-t</b> options or the <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 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> command.</p>
|
|
|
|
<p>When changing from <b>ex</b> mode to open or visual mode, if the <b>`</b> and <b>'</b> marks are not already set, the <b>`</b>
|
|
and <b>'</b> marks shall be set as described previously.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_26"></a>Move</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Move the specified lines after the specified destination line. A destination of line zero specifies that the lines 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 be
|
|
moved.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last of the moved lines.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_27"></a>Next</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete write, it
|
|
shall be an error, unless the file is successfully written as specified by the <b>autowrite</b> option.</p>
|
|
|
|
<p>If one or more files is specified:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Set the argument list to the specified filenames.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Set the current argument list reference to be the first entry in the argument list.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Set the current pathname to the first filename specified.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Otherwise:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>It shall be an error if there are no more filenames in the argument list after the filename currently referenced.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Set the current pathname and the current argument list reference to the filename after the filename currently referenced in the
|
|
argument list.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Replace the contents of the edit buffer with the contents of the file named by the current pathname. If for any reason the
|
|
contents of the file cannot be accessed, the edit buffer shall be empty.</p>
|
|
|
|
<p>This command shall be affected by the <b>autowrite</b> and <b>writeany</b> edit options.</p>
|
|
|
|
<p>The <b>+</b> <i>command</i> option shall be <blank>-delimited; <blank>s can be escaped by preceding them with a
|
|
backslash character. The <b>+</b> <i>command</i> shall be interpreted as an <i>ex</i> command immediately after the contents of the
|
|
edit buffer have been replaced and the current line and column have been set.</p>
|
|
|
|
<p><i>Current line</i>: Set as described for the <b>edit</b> command.</p>
|
|
|
|
<p><i>Current column</i>: Set as described for the <b>edit</b> command.</p>
|
|
|
|
<h5><a name="tag_04_45_13_28"></a>Number</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>]
|
|
[</b><i>2addr</i><b>]</b> <tt>#</tt><b>[</b><i>count</i><b>][</b><i>flags</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>These commands shall be equivalent to the <i>ex</i> command:</p>
|
|
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
|
|
<p>See <a href="#tag_04_45_13_31">Print</a> .</p>
|
|
|
|
<h5><a name="tag_04_45_13_29"></a>Open</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>This command need not be supported on block-mode terminals or terminals with insufficient capabilities. If standard input,
|
|
standard output, or standard error are not terminal devices, the results are unspecified.</p>
|
|
|
|
<p>Enter open mode.</p>
|
|
|
|
<p>The trailing delimiter can be omitted from <i>pattern</i> at the end of the command line. If <i>pattern</i> is empty (for
|
|
example, <tt>"//"</tt> ) or not specified, the last regular expression used in the editor shall be used as the pattern. The pattern
|
|
can be delimited by slashes (shown in the Synopsis), as well as any alphanumeric, or non- <blank> other than backslash,
|
|
vertical line, double quote, or <newline>.</p>
|
|
|
|
<p><i>Current line</i>: Set to the specified line.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_30"></a>Preserve</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>pre</tt><b>[</b><tt>serve</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>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>
|
|
<b>recover</b> command. After the file has been preserved, a mail message shall be sent to the user. This message shall be readable
|
|
by invoking the <a href="../utilities/mailx.html"><i>mailx</i></a> utility. The message shall contain the name of the file, the
|
|
time of preservation, and an <i>ex</i> command that could be used to recover the file. Additional information may be included in
|
|
the mail message.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_31"></a>Print</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Write the addressed lines. The behavior is unspecified if the number of columns on the display is less than the number of
|
|
columns required to write any single character in the lines being written.</p>
|
|
|
|
<p>Non-printable characters, except for the <tab>, shall be written as implementation-defined multi-character sequences.</p>
|
|
|
|
<p>If the <b>#</b> flag is specified or the <b>number</b> edit option is set, each line shall be preceded by its line number in the
|
|
following format:</p>
|
|
|
|
<pre>
|
|
<tt>"%6d<img src="../images/delta.gif" border="0"><img src="../images/delta.gif" border="0">", <</tt><i>line number</i><tt>>
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the <b>l</b> flag is specified or the <b>list</b> edit option is set:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The characters listed in the Base Definitions volume of IEEE Std 1003.1-2001, Table 5-1, Escape Sequences and
|
|
Associated Actions shall be written as the corresponding escape sequence.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Non-printable characters not in the Base Definitions volume of IEEE Std 1003.1-2001, Table 5-1, Escape Sequences and
|
|
Associated Actions shall be written as one three-digit octal number (with a preceding backslash) for each byte in the character
|
|
(most significant byte first). If the size of a byte on the system is greater than 9 bits, the format used for non-printable
|
|
characters is implementation-defined.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The end of each line shall be marked with a <tt>'$'</tt> , and literal <tt>'$'</tt> characters within the line shall be written
|
|
with a preceding backslash.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Long lines shall be folded; the length at which folding occurs is unspecified, but should be appropriate for the output
|
|
terminal, considering the number of columns of the terminal.</p>
|
|
|
|
<p>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 unspecified
|
|
whether a multi-column character at the folding position is separated; it shall not be discarded.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last written line.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged if the current line is unchanged; otherwise, set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_32"></a>Put</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>1addr</i><b>]</b> <tt>pu</tt><b>[</b><tt>t</tt><b>][</b><i>buffer</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Append text from the specified buffer (by default, the unnamed buffer) to the specified line; line zero specifies 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 the edit
|
|
buffer, regardless of the mode of the buffer.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last line entered into the edit buffer.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_33"></a>Quit</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>q</tt><b>[</b><tt>uit</tt><b>][</b><tt>!</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no <tt>'!'</tt> is appended to the command name:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the edit buffer has been modified since the last complete write, it shall be an error.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If there are filenames in the argument list after the filename currently referenced, and the last command was not a <b>quit</b>,
|
|
<b>wq</b>, <b>xit</b>, or <b>ZZ</b> (see <a href="vi.html#tag_04_167_13_87"><i>Exit</i></a> ) command, it shall be an error.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Otherwise, terminate the editing session.</p>
|
|
|
|
<h5><a name="tag_04_45_13_34"></a>Read</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <tt>'!'</tt> is not the first non- <blank> to follow the command name, a copy of the specified file shall be appended
|
|
into the edit buffer after the specified line; line zero specifies that the copy shall be placed at the beginning of 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 default.
|
|
If there is no current pathname, then <i>file</i> shall become the current pathname. If there is no current pathname or <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>
|
|
|
|
<p>Otherwise, if <i>file</i> is preceded by <tt>'!'</tt> , the rest of the line after the <tt>'!'</tt> shall have <tt>'%'</tt> ,
|
|
<tt>'#'</tt> , and <tt>'!'</tt> characters expanded as described in <a href="#tag_04_45_13_03">Command Line Parsing in ex</a> .</p>
|
|
|
|
<p>The <i>ex</i> utility shall then pass two arguments to the program named by the shell edit option; the first shall 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 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 of the
|
|
program shall be appended into the edit buffer after the specified line.</p>
|
|
|
|
<p>Each line in the copied file or program output (as delimited by <newline>s or the end of the file or output if it is not
|
|
immediately preceded by a <newline>), shall be a separate line in the edit buffer. Any occurrences of <carriage-return>
|
|
and <newline> pairs in the output shall be treated as single <newline>s.</p>
|
|
|
|
<p>The special meaning of the <tt>'!'</tt> following the <b>read</b> command can be overridden by escaping it with a backslash
|
|
character.</p>
|
|
|
|
<p><i>Current line</i>: If no lines are added to the edit buffer, unchanged. Otherwise, if in open or visual mode, set to the first
|
|
line entered into the edit buffer. Otherwise, set to the last line entered into the edit buffer.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_35"></a>Recover</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>rec</tt><b>[</b><tt>over</tt><b>][</b><tt>!</tt><b>]</b> <i>file</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete write, it
|
|
shall be an error.</p>
|
|
|
|
<p>If no <i>file</i> operand is specified, then the current pathname shall be used. If there is no current pathname or <i>file</i>
|
|
operand, it shall be an error.</p>
|
|
|
|
<p>If no recovery information has previously been saved about <i>file</i>, the <b>recover</b> command shall behave identically to
|
|
the <b>edit</b> command, and an informational message to this effect shall be written.</p>
|
|
|
|
<p>Otherwise, set the current pathname to <i>file</i>, and replace the current contents of the edit buffer with the recovered
|
|
contents of <i>file</i>. If there are multiple instances of the file to be recovered, the one most recently saved shall be
|
|
recovered, and an informational message that there are previous versions of the file that can be recovered shall be written. The
|
|
editor shall behave as if the contents of the edit buffer have already been modified.</p>
|
|
|
|
<p><i>Current file</i>: Set as described for the <b>edit</b> command.</p>
|
|
|
|
<p><i>Current column</i>: Set as described for the <b>edit</b> command.</p>
|
|
|
|
<h5><a name="tag_04_45_13_36"></a>Rewind</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>rew</tt><b>[</b><tt>ind</tt><b>][</b><tt>!</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no <tt>'!'</tt> is appended to the command name, and the edit buffer has been modified since the last complete write, it
|
|
shall be an error, unless the file is successfully written as specified by the <b>autowrite</b> option.</p>
|
|
|
|
<p>If the argument list is empty, it shall be an error.</p>
|
|
|
|
<p>The current argument list reference and the current pathname shall be set to the first filename in the argument list.</p>
|
|
|
|
<p>Replace the contents of the edit buffer with the contents of the file named by the current pathname. If for any reason the
|
|
contents of the file cannot be accessed, the edit buffer shall be empty.</p>
|
|
|
|
<p>This command shall be affected by the <b>autowrite</b> and <b>writeany</b> edit options.</p>
|
|
|
|
<p><i>Current line</i>: Set as described for the <b>edit</b> command.</p>
|
|
|
|
<p><i>Current column</i>: Set as described for the <b>edit</b> command.</p>
|
|
|
|
<h5><a name="tag_04_45_13_37"></a>Set</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>When no arguments are specified, write the value of the <b>term</b> edit option and those options whose values have been changed
|
|
from the default settings; when the argument <i>all</i> is specified, write all of the option values.</p>
|
|
|
|
<p>Giving an option name followed by the character <tt>'?'</tt> shall cause the current value of that option to be written. The
|
|
<tt>'?'</tt> can be separated from the option name by zero or more <blank>s. The <tt>'?'</tt> shall be 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 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> <i>option</i>=
|
|
<i>value</i>. Any <blank>s in strings can be included as is by preceding each <blank> with an escaping backslash. More
|
|
than one option can be set or listed by a single set command by specifying multiple arguments, each separated from the next by one
|
|
or more <blank>s.</p>
|
|
|
|
<p>See <a href="#tag_04_45_13_60">Edit Options in ex</a> for details about specific options.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_38"></a>Shell</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>sh</tt><b>[</b><tt>ell</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Invoke the program named in the <b>shell</b> edit option with the single argument <b>-i</b> (interactive mode). Editing shall be
|
|
resumed when the program exits.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_39"></a>Source</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>so</tt><b>[</b><tt>urce</tt><b>]</b> <i>file</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Read and execute <i>ex</i> commands from <i>file</i>. Lines in the file that are blank lines shall be ignored.</p>
|
|
|
|
<p><i>Current line</i>: As specified for the individual <i>ex</i> commands.</p>
|
|
|
|
<p><i>Current column</i>: As specified for the individual <i>ex</i> commands.</p>
|
|
|
|
<h5><a name="tag_04_45_13_40"></a>Substitute</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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><br>
|
|
</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><br>
|
|
</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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Replace the first instance of the pattern <i>pattern</i> by the string <i>repl</i> on each specified line. (See <a href=
|
|
"#tag_04_45_13_58">Regular Expressions in ex</a> and <a href="#tag_04_45_13_59">Replacement Strings in ex</a> .) Any
|
|
non-alphabetic, non- <blank> delimiter other than <tt>'\'</tt> , <tt>'|'</tt> , double quote, or <newline> can be used
|
|
instead of <tt>'/'</tt> . Backslash characters can be used to escape delimiters, backslash characters, and other special
|
|
characters.</p>
|
|
|
|
<p>The trailing delimiter can be omitted from <i>pattern</i> or from <i>repl</i> at the end of the command line. If 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
|
|
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
|
|
pattern. If only <i>repl</i> is not specified or is empty, the pattern shall be replaced by nothing. If the entire replacement
|
|
pattern is <tt>'%'</tt> , the last replacement pattern to an <b>s</b> command shall be used.</p>
|
|
|
|
<p>Entering a <carriage-return> in <i>repl</i> (which requires an escaping backslash in <i>ex</i> mode and an escaping
|
|
<control>-V in open or <a href="../utilities/vi.html"><i>vi</i></a> mode) shall split the line at that point, creating a new
|
|
line in the edit buffer. The <carriage-return> shall be discarded.</p>
|
|
|
|
<p>If <i>options</i> includes the letter <tt>'g'</tt> ( <b>global</b>), all non-overlapping instances of the pattern in the line
|
|
shall be replaced.</p>
|
|
|
|
<p>If <i>options</i> includes the letter <tt>'c'</tt> ( <b>confirm</b>), then before each substitution the line shall be written;
|
|
the written line shall reflect all previous substitutions. On the following line, <space>s shall be written beneath the
|
|
characters from the line that are before the <i>pattern</i> to be replaced, and <tt>'^'</tt> characters written 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 user. An
|
|
affirmative response shall cause the substitution to be done, while any other input shall not make the substitution. An affirmative
|
|
response shall consist of a line with the affirmative response (as defined by the current locale) at the beginning of the line.
|
|
This line shall be subject to editing in the same way as the <i>ex</i> command line.</p>
|
|
|
|
<p>If interrupted (see the ASYNCHRONOUS EVENTS section), any modifications confirmed by the user shall be preserved in the edit
|
|
buffer after the interrupt.</p>
|
|
|
|
<p>If the remembered search direction is not set, the <b>s</b> command shall set it to forward.</p>
|
|
|
|
<p>In the second Synopsis, the <b>&</b> command shall repeat the previous substitution, as if the <b>&</b> command were
|
|
replaced by:</p>
|
|
|
|
<pre>
|
|
<tt>s/</tt><i>pattern</i><tt>/</tt><i>repl</i><tt>/
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>where <i>pattern</i> and <i>repl</i> are as specified in the previous <b>s</b>, <b>&</b>, or <b>˜</b> command.</p>
|
|
|
|
<p>In the third Synopsis, the <b>˜</b> command shall repeat the previous substitution, as if the <tt>'˜'</tt> were
|
|
replaced by:</p>
|
|
|
|
<pre>
|
|
<tt>s/</tt><i>pattern</i><tt>/</tt><i>repl</i><tt>/
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>where <i>pattern</i> shall be the last regular expression specified to the editor, and <i>repl</i> shall be from the previous
|
|
substitution (including <b>&</b> and <b>˜</b>) command.</p>
|
|
|
|
<p>These commands shall be affected by the <i>LC_MESSAGES</i> environment variable.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last line in which a substitution occurred, or, unchanged if no substitution occurred.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_41"></a>Suspend</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>su</tt><b>[</b><tt>spend</tt><b>][</b><tt>!</tt><b>]</b><tt>st</tt><b>[</b><tt>op</tt><b>][</b><tt>!</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Allow control to return to the invoking process; <i>ex</i> shall suspend itself as if it had received the SIGTSTP signal. The
|
|
suspension shall occur only if job control is enabled in the invoking shell (see the description of <a href=
|
|
"../utilities/set.html"><i>set</i></a> <b>-m</b>).</p>
|
|
|
|
<p>These commands shall be affected by the <b>autowrite</b> and <b>writeany</b> edit options.</p>
|
|
|
|
<p>The current <b>susp</b> character (see <a href="stty.html"><i>stty</i></a> ) shall be equivalent to the <b>suspend</b>
|
|
command.</p>
|
|
|
|
<h5><a name="tag_04_45_13_42"></a>Tag</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>ta</tt><b>[</b><tt>g</tt><b>][</b><tt>!</tt><b>]</b> <i>tagstring</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The results are unspecified if the format of a tags file is not as specified by the <a href=
|
|
"../utilities/ctags.html"><i>ctags</i></a> utility (see <a href="ctags.html"><i>ctags</i></a> ) description.</p>
|
|
|
|
<p>The <b>tag</b> command shall search for <i>tagstring</i> in the tag files referred to by the <b>tag</b> edit option, in the
|
|
order they are specified, until a reference to <i>tagstring</i> is found. Files shall be searched from beginning to 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 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 message shall
|
|
be written at the first occurrence of such an error.</p>
|
|
|
|
<p>Otherwise, if the tags file contained a pattern, the pattern shall be treated as a regular expression used in the editor; for
|
|
example, for the purposes of the <b>s</b> command.</p>
|
|
|
|
<p>If the <i>tagstring</i> is in a file with a different name than the current pathname, set the current pathname to 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> is appended
|
|
to the command name, and the edit buffer has been modified since the last complete write, it shall be an error, unless the file is
|
|
successfully written as specified by the <b>autowrite</b> option.</p>
|
|
|
|
<p>This command shall be affected by the <b>autowrite</b>, <b>tag</b>, <b>taglength</b>, and <b>writeany</b> edit options.</p>
|
|
|
|
<p><i>Current line</i>: If the tags file contained a line number, set to that line number. If the line number is 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 the <b>edit</b>
|
|
command.</p>
|
|
|
|
<p>If the tags file contained a pattern, set to the first occurrence of the pattern in the file. If no matching 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>
|
|
|
|
<p><i>Current column</i>: If the tags file contained a line-number reference and that line-number was not larger than the last line
|
|
in the edit buffer, or if the tags file contained a pattern and that pattern was found, set to non- <blank>. Otherwise, set
|
|
as specified for the <b>edit</b> command.</p>
|
|
|
|
<h5><a name="tag_04_45_13_43"></a>Unabbreviate</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>una</tt><b>[</b><tt>bbrev</tt><b>]</b> <i>lhs</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <i>lhs</i> is not an entry in the current list of abbreviations (see <a href="#tag_04_45_13_11">Abbreviate</a> ), it shall be
|
|
an error. Otherwise, delete <i>lhs</i> from the list of abbreviations.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_44"></a>Undo</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>u</tt><b>[</b><tt>ndo</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Reverse the changes made by the last command that modified the contents of the edit buffer, including <b>undo</b>. For this
|
|
purpose, the <b>global</b>, <b>v</b>, <b>open</b>, and <b>visual</b> commands, and commands resulting from buffer executions and
|
|
mapped character expansions, are considered single commands.</p>
|
|
|
|
<p>If no action that can be undone preceded the <b>undo</b> command, it shall be an error.</p>
|
|
|
|
<p>If the <b>undo</b> command restores lines that were marked, the mark shall also be restored unless it was reset subsequent to
|
|
the deletion of the lines.</p>
|
|
|
|
<p><i>Current line</i>:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If lines are added or changed in the file, set to the first line added or changed.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Set to the line before the first line deleted, if it exists.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Set to 1 if the edit buffer is not empty.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Set to zero.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_45"></a>Unmap</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>unm</tt><b>[</b><tt>ap</tt><b>][</b><tt>!</tt><b>]</b> <i>lhs</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>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 map
|
|
definitions, it shall be an error. Otherwise, delete <i>lhs</i> from the list of text input mode map definitions.</p>
|
|
|
|
<p>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 map
|
|
definitions, it shall be an error. Otherwise, delete <i>lhs</i> from the list of command mode map definitions.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_46"></a>Version</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>ve</tt><b>[</b><tt>rsion</tt><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Write a message containing version information for the editor. The format of the message is unspecified.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_47"></a>Visual</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <i>ex</i> is currently in open or visual mode, the Synopsis and behavior of the visual command shall be the same as the
|
|
<b>edit</b> command, as specified by <a href="#tag_04_45_13_18">Edit</a> .</p>
|
|
|
|
<p>Otherwise, this command need not be supported on block-mode terminals or terminals with insufficient capabilities. If standard
|
|
input, standard output, or standard error are not terminal devices, the results are unspecified.</p>
|
|
|
|
<p>If <i>count</i> is specified, the value of the <b>window</b> edit option shall be set to <i>count</i> (as described in <a href=
|
|
"#tag_04_45_13_93">window</a> ). If the <tt>'^'</tt> type character was also specified, the <b>window</b> edit option shall be set
|
|
before being used by the type character.</p>
|
|
|
|
<p>Enter visual mode. If <i>type</i> is not specified, it shall be as if a <i>type</i> of <tt>'+'</tt> was specified. The
|
|
<i>type</i> shall cause the following effects:</p>
|
|
|
|
<dl compact>
|
|
<dt><tt>+</tt></dt>
|
|
|
|
<dd>Place the beginning of the specified line at the top of the display.</dd>
|
|
|
|
<dt><tt>-</tt></dt>
|
|
|
|
<dd>Place the end of the specified line at the bottom of the display.</dd>
|
|
|
|
<dt><tt>.</tt></dt>
|
|
|
|
<dd>Place the beginning of the specified line in the middle of the display.</dd>
|
|
|
|
<dt><tt>^</tt></dt>
|
|
|
|
<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,
|
|
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
|
|
of the displayed lines as possible, while still displaying the value of the <b>window</b> edit option number of lines.</dd>
|
|
</dl>
|
|
|
|
<p><i>Current line</i>: Set to the specified line.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_48"></a>Write</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>2addr</i><b>]</b> <tt>w</tt><b>[</b><tt>rite</tt><b>][</b><tt>!</tt><b>][</b><tt>>></tt><b>][</b><i>file</i><b>]
|
|
[</b><i>2addr</i><b>]</b> <tt>w</tt><b>[</b><tt>rite</tt><b>][</b><tt>!</tt><b>][</b><i>file</i><b>]
|
|
[</b><i>2addr</i><b>]</b> <tt>wq</tt><b>[</b><tt>!</tt><b>][</b><tt>>></tt><b>][</b><i>file</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no lines are specified, the lines shall default to the entire file.</p>
|
|
|
|
<p>The command <b>wq</b> shall be equivalent to a <b>write</b> command followed by a <b>quit</b> command; <b>wq!</b> 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> shall not be
|
|
attempted.</p>
|
|
|
|
<p>If the command name is not followed by one or more <blank>s, or <i>file</i> is not preceded by a <tt>'!'</tt> character,
|
|
the <b>write</b> shall be to a file.</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the <b>>></b> argument is specified, and the file already exists, the lines shall be appended to the file instead of
|
|
replacing its contents. If the <b>>></b> argument is specified, and the file does not already exist, it is unspecified
|
|
whether the write shall proceed as if the <b>>></b> argument had not been specified or if the write shall fail.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the <b>readonly</b> edit option is set (see <a href="#tag_04_45_13_76">readonly</a> ), the <b>write</b> shall fail.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If <i>file</i> is specified, and is not the current pathname, and the file exists, the <b>write</b> shall fail.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If <i>file</i> is not specified, the current pathname shall be used. If there is no current pathname, the <b>write</b> command
|
|
shall fail.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the current pathname is used, and the current pathname has been changed by the <b>file</b> or <b>read</b> 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 fail for this
|
|
reason (unless the current pathname is changed again).</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the whole edit buffer is not being written, and the file to be written exists, the <b>write</b> shall fail.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>For rules 1., 2., 4., and 5., the <b>write</b> can be forced by appending the character <tt>'!'</tt> to the command name.</p>
|
|
|
|
<p>For rules 2., 4., and 5., the <b>write</b> can be forced by setting the <b>writeany</b> edit option.</p>
|
|
|
|
<p>Additional, implementation-defined tests may cause the <b>write</b> to fail.</p>
|
|
|
|
<p>If the edit buffer is empty, a file without any contents shall be written.</p>
|
|
|
|
<p>An informational message shall be written noting the number of lines and bytes written.</p>
|
|
|
|
<p>Otherwise, if the command is followed by one or more <blank>s, and the file is preceded by <tt>'!'</tt> , the rest of the
|
|
line after the <tt>'!'</tt> shall have <tt>'%'</tt> , <tt>'#'</tt> , and <tt>'!'</tt> characters expanded as described in <a href=
|
|
"#tag_04_45_13_03">Command Line Parsing in ex</a> .</p>
|
|
|
|
<p>The <i>ex</i> utility shall then pass two arguments to the program named by the <b>shell</b> edit option; the first 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 lines
|
|
shall be written to the standard input of the command. The standard error and standard output of the program, if any, shall be
|
|
written as described for the <b>print</b> command. If the last character in that output is not a <newline>, a <newline>
|
|
shall be written at the end of the output.</p>
|
|
|
|
<p>The special meaning of the <tt>'!'</tt> following the <b>write</b> command can be overridden by escaping it with a backslash
|
|
character.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_49"></a>Write and Exit</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If the edit buffer has not been modified since the last complete <b>write</b>, <b>xit</b> shall be equivalent to the <b>quit</b>
|
|
command, or if a <tt>'!'</tt> is appended to the command name, to <b>quit!</b>.</p>
|
|
|
|
<p>Otherwise, <b>xit</b> shall be equivalent to the <b>wq</b> command, or if a <tt>'!'</tt> is appended to the command name, to
|
|
<b>wq!</b>.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_50"></a>Yank</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Copy the specified lines to the specified buffer (by default, the unnamed buffer), which shall become a line-mode buffer.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_51"></a>Adjust Window</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<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>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no line is specified, the current line shall be the default; if <i>type</i> is omitted as well, the current line 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 buffer, it
|
|
shall be an error.</p>
|
|
|
|
<p>If there are <blank>s between the <i>type</i> argument and the preceding <b>z</b> command name or optional <tt>'!'</tt>
|
|
character, it shall be an error.</p>
|
|
|
|
<p>If <i>count</i> is specified, the value of the <b>window</b> edit option shall be set to <i>count</i> (as described in <a href=
|
|
"#tag_04_45_13_93">window</a> ). If <i>count</i> is omitted, it shall default to 2 times the value of the <b>scroll</b> edit
|
|
option, or if <b>!</b> was specified, the number of lines in the display minus 1.</p>
|
|
|
|
<p>If <i>type</i> is omitted, then <i>count</i> lines starting with the specified line shall be written. Otherwise, <i>count</i>
|
|
lines starting with the line specified by the <i>type</i> argument shall be written.</p>
|
|
|
|
<p>The <i>type</i> argument shall change the lines to be written. The possible values of <i>type</i> are as follows:</p>
|
|
|
|
<dl compact>
|
|
<dt><tt>-</tt></dt>
|
|
|
|
<dd>The specified line shall be decremented by the following value:
|
|
|
|
<pre>
|
|
<tt>(((number of "-" characters) x</tt> <i>count</i><tt>) -1)
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the calculation would result in a number less than 1, it shall be an error. 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 has been written.</p>
|
|
</dd>
|
|
|
|
<dt><tt>+</tt></dt>
|
|
|
|
<dd>The specified line shall be incremented by the following value:
|
|
|
|
<pre>
|
|
<tt>(((number of "+" characters) -1) x</tt> <i>count</i><tt>) +1
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the calculation would result in a number greater than the last line in the edit buffer, it shall be an error. 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 has been
|
|
written.</p>
|
|
</dd>
|
|
|
|
<dt><tt>=</tt>,<tt>.</tt></dt>
|
|
|
|
<dd>If more than a single <tt>'.'</tt> or <tt>'='</tt> is specified, it shall be an error. The following steps shall be taken:
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If <i>count</i> is zero, nothing shall be written.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Write as many of the <i>N</i> lines before the current line in the edit buffer as exist. If <i>count</i> or <tt>'!'</tt> was
|
|
specified, <i>N</i> shall be:</p>
|
|
|
|
<pre>
|
|
<tt>(</tt><i>count</i> <tt>-1) /2
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>Otherwise, <i>N</i> shall be:</p>
|
|
|
|
<pre>
|
|
<tt>(</tt><i>count</i> <tt>-3) /2
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If <i>N</i> is a number less than 3, no lines shall be written.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If <tt>'='</tt> was specified as the type character, write a line consisting of the smaller of the number of columns in the
|
|
display divided by two, or 40 <tt>'-'</tt> characters.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Write the current line.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Repeat step 3.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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 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 written.</p>
|
|
</li>
|
|
</ol>
|
|
</dd>
|
|
|
|
<dt><tt>^</tt></dt>
|
|
|
|
<dd>The specified line shall be decremented by the following value:
|
|
|
|
<pre>
|
|
<tt>(((number of "^" characters) +1) x</tt> <i>count</i><tt>) -1
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>If the calculation would result in a number less than 1, it shall be an error. 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 has been written.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p><i>Current line</i>: Set to the last line written, unless the type is <b>=</b>, in which case, set to the specified line.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_52"></a>Escape</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt>!</tt> <i>command
|
|
</i><b>[</b><i>addr</i><b>]</b><tt>!</tt> <i>command</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>The contents of the line after the <tt>'!'</tt> shall have <tt>'%'</tt> , <tt>'#'</tt> , and <tt>'!'</tt> characters expanded as
|
|
described in <a href="#tag_04_45_13_03">Command Line Parsing in ex</a> . If the expansion causes the text of the line to change, it
|
|
shall be redisplayed, preceded by a single <tt>'!'</tt> character.</p>
|
|
|
|
<p>The <i>ex</i> utility shall execute the program named by the <b>shell</b> edit option. It shall pass two arguments 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
|
|
argument.</p>
|
|
|
|
<p>If no lines are specified, the standard input, standard output, and standard error of the program shall be set to the standard
|
|
input, standard output, and standard error of the <i>ex</i> program when it was invoked. In addition, a warning message shall be
|
|
written if the edit buffer has been modified since the last complete write, and the <b>warn</b> edit option is set.</p>
|
|
|
|
<p>If lines are specified, they shall be passed to the program as standard input, and the standard output and standard error of the
|
|
program shall replace those lines in the edit buffer. Each line in the program output (as delimited by <newline>s or the end
|
|
of the output if it is not immediately preceded by a <newline>), shall be a separate line in the edit buffer. Any occurrences
|
|
of <carriage-return> and <newline> pairs in the output shall be treated as single <newline>s. The specified lines
|
|
shall be copied into the unnamed buffer before they are replaced, and the unnamed buffer shall become a line-mode buffer.</p>
|
|
|
|
<p>If in <i>ex</i> mode, a single <tt>'!'</tt> character shall be written when the program completes.</p>
|
|
|
|
<p>This command shall be affected by the <b>shell</b> and <b>warn</b> edit options. If no lines are specified, this command shall
|
|
be affected by the <b>autowrite</b> and <b>writeany</b> edit options. If lines are specified, this command shall be affected by the
|
|
<b>autoprint</b> edit option.</p>
|
|
|
|
<p><i>Current line</i>:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If no lines are specified, unchanged.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, set to the last line read in, if any lines are read in.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, set to the line before the first line of the lines specified, if that line exists.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, set to the first line of the edit buffer if the edit buffer is not empty.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, set to zero.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p><i>Current column</i>: If no lines are specified, unchanged. Otherwise, set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_53"></a>Shift Left</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>2addr</i><b>]</b> <tt><</tt><b>[</b><tt>< ...</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Shift the specified lines to the start of the line; the number of column positions to be shifted shall be the number of command
|
|
characters times the value of the <b>shiftwidth</b> edit option. Only leading <blank>s shall be deleted or changed into other
|
|
<blank>s in shifting; other characters shall not be affected.</p>
|
|
|
|
<p>Lines to be shifted shall be copied into the unnamed buffer, which shall become a line-mode buffer.</p>
|
|
|
|
<p>This command shall be affected by the <b>autoprint</b> edit option.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last line in the lines specified.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_54"></a>Shift Right</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>2addr</i><b>]</b> <tt>></tt><b>[</b><tt>> ...</tt><b>][</b><i>count</i><b>][</b><i>flags</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>Shift the specified lines away from the start of the line; the number of column positions to be shifted shall be the number of
|
|
command characters times the value of the <b>shiftwidth</b> edit option. The shift shall be accomplished by adding <blank>s
|
|
as a prefix to the line or changing leading <blank>s into other <blank>s. Empty lines shall not be changed.</p>
|
|
|
|
<p>Lines to be shifted shall be copied into the unnamed buffer, which shall become a line-mode buffer.</p>
|
|
|
|
<p>This command shall be affected by the <b>autoprint</b> edit option.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last line in the lines specified.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_55"></a><control>-D</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<tt><control>-D
|
|
</tt>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>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 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 error.</p>
|
|
|
|
<p><i>Current line</i>: Set to the last line written.</p>
|
|
|
|
<p><i>Current column</i>: Set to non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_56"></a>Write Line Number</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>1addr</i><b>]</b> <tt>=</tt> <b>[</b><i>flags</i><b>]</b>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If <i>line</i> is not specified, it shall default to the last line in the edit buffer. Write the line number of the specified
|
|
line.</p>
|
|
|
|
<p><i>Current line</i>: Unchanged.</p>
|
|
|
|
<p><i>Current column</i>: Unchanged.</p>
|
|
|
|
<h5><a name="tag_04_45_13_57"></a>Execute</h5>
|
|
|
|
<dl compact>
|
|
<dt><i>Synopsis</i>:</dt>
|
|
|
|
<dd>
|
|
<pre>
|
|
<b>[</b><i>2addr</i><b>]</b> <tt>@</tt> <i>buffer</i><b>[</b><i>2addr</i><b>]</b> <tt>*</tt> <i>buffer</i>
|
|
</pre>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>If no buffer is specified or is specified as <tt>'@'</tt> or <tt>'*'</tt> , the last buffer executed shall be used. If no
|
|
previous buffer has been executed, it shall be an error.</p>
|
|
|
|
<p>For each line specified by the addresses, set the current line ( <tt>'.'</tt> ) to the specified line, and execute 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 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 if the line
|
|
was terminated by a <newline>.</p>
|
|
|
|
<p>If an error occurs during this process, or a line specified by the addresses does not exist when the current line 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 (for example, by
|
|
the <i>ex</i> <b>:edit</b> command) an error message shall be written, and no more commands resulting from the execution of this
|
|
command shall be processed.</p>
|
|
|
|
<p><i>Current line</i>: As specified for the individual <i>ex</i> commands.</p>
|
|
|
|
<p><i>Current column</i>: As specified for the individual <i>ex</i> commands.</p>
|
|
|
|
<h5><a name="tag_04_45_13_58"></a>Regular Expressions in ex</h5>
|
|
|
|
<p>The <i>ex</i> utility shall support regular expressions that are a superset of the basic regular expressions described in the
|
|
Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap09.html#tag_09_03">Section 9.3, Basic
|
|
Regular Expressions</a>. A null regular expression ( <tt>"//"</tt> ) shall be equivalent to the last regular expression
|
|
encountered.</p>
|
|
|
|
<p>Regular expressions can be used in addresses to specify lines and, in some commands (for example, the <b>substitute</b>
|
|
command), to specify portions of a line to be substituted.</p>
|
|
|
|
<p>The following constructs can be used to enhance the basic regular expressions:</p>
|
|
|
|
<dl compact>
|
|
<dt><tt>\<</tt></dt>
|
|
|
|
<dd>Match the beginning of a <i>word</i>. (See the definition of <i>word</i> at the beginning of <a href="#tag_04_45_13_10">Command
|
|
Descriptions in ex</a> .)</dd>
|
|
|
|
<dt><tt>\></tt></dt>
|
|
|
|
<dd>Match the end of a <i>word</i>.</dd>
|
|
|
|
<dt><tt>˜</tt></dt>
|
|
|
|
<dd>Match the replacement part of the last <b>substitute</b> command. The tilde ( <tt>'˜'</tt> ) character can be escaped in a
|
|
regular expression to become a normal character with no special meaning. The backslash shall be discarded.</dd>
|
|
</dl>
|
|
|
|
<p>When the editor option <b>magic</b> is not set, the only characters with special meanings shall be <tt>'^'</tt> at the beginning
|
|
of a pattern, <tt>'$'</tt> at the end of a pattern, and <tt>'\'</tt> . The characters <tt>'.'</tt> , <tt>'*'</tt> , <tt>'['</tt> ,
|
|
and <tt>'˜'</tt> shall be treated as ordinary characters unless preceded by a <tt>'\'</tt> ; when preceded by a <tt>'\'</tt>
|
|
they shall regain their special meaning, or in the case of backslash, be handled as a single backslash. Backslashes used to escape
|
|
other characters shall be discarded.</p>
|
|
|
|
<h5><a name="tag_04_45_13_59"></a>Replacement Strings in ex</h5>
|
|
|
|
<p>The character <tt>'&'</tt> ( <tt>'\&'</tt> if the editor option <b>magic</b> is not set) in the replacement string shall
|
|
stand for the text matched by the pattern to be replaced. The character <tt>'˜'</tt> ( <tt>'\˜'</tt> if <b>magic</b> is
|
|
not set) shall be replaced by the replacement part of the previous <b>substitute</b> command. The sequence <tt>'\n'</tt> , where
|
|
<i>n</i> is an integer, shall be replaced by the text matched by the pattern enclosed in the <i>n</i>th set of parentheses
|
|
<tt>'\('</tt> and <tt>'\)'</tt> .</p>
|
|
|
|
<p>The strings <tt>'\l'</tt> , <tt>'\u'</tt> , <tt>'\L'</tt> , and <tt>'\U'</tt> can be used to modify the case of elements in the
|
|
replacement string (using the <tt>'\&'</tt> or <tt>"\"</tt> digit) notation. The string <tt>'\l'</tt> ( <tt>'\u'</tt> ) shall
|
|
cause the character that follows to be converted to lowercase (uppercase). The string <tt>'\L'</tt> ( <tt>'\U'</tt> ) shall cause
|
|
all characters subsequent to it to be converted to lowercase (uppercase) as they are inserted by the substitution until the string
|
|
<tt>'\e'</tt> or <tt>'\E'</tt> , or the end of the replacement string, is encountered.</p>
|
|
|
|
<p>Otherwise, any character following a backslash shall be treated as that literal character, and the escaping backslash shall be
|
|
discarded.</p>
|
|
|
|
<p>An example of case conversion with the <b>s</b> command is as follows:</p>
|
|
|
|
<pre>
|
|
<b>:</b><tt>p
|
|
</tt><b>The cat sat on the mat.
|
|
:</b><tt>s/\<.at\>/\u&/gp
|
|
</tt><b>The Cat Sat on the Mat.
|
|
:</b><tt>s/S\(.*\)M/S\U\1\eM/p
|
|
</tt><b>The Cat SAT ON THE Mat.</b>
|
|
</pre>
|
|
|
|
<h5><a name="tag_04_45_13_60"></a>Edit Options in ex</h5>
|
|
|
|
<p>The <i>ex</i> utility has a number of options that modify its behavior. These options have default settings, which can be
|
|
changed using the <b>set</b> command.</p>
|
|
|
|
<p>Options are Boolean unless otherwise specified.</p>
|
|
|
|
<h5><a name="tag_04_45_13_61"></a>autoindent, ai</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>autoindent</b> is set, each line in input mode shall be indented (using first as many <tab>s as possible, as
|
|
determined by the editor option <b>tabstop</b>, and then using <space>s) to align with another line, as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If in open or visual mode and the text input is part of a line-oriented command (see the EXTENDED DESCRIPTION in <a href=
|
|
"vi.html"><i>vi</i></a> ), align to the first column.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if in open or visual mode, indentation for each line shall be set as follows:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>If a line was previously inserted as part of this command, it shall be set to the indentation of the last inserted line by
|
|
default, or as otherwise specified for the <control>-D character in <a href="vi.html#tag_04_167_13_88"><i>Input Mode Commands
|
|
in vi</i></a> .</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, it shall be set to the indentation of the previous current line, if any; otherwise, to the first column.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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:</p>
|
|
|
|
<ol type="a">
|
|
<li>
|
|
<p>If a line was previously inserted as part of this command, it shall be set to the indentation of the last inserted line by
|
|
default, or as otherwise specified for the <i>eof</i> character in <a href="#tag_04_45_13_05">Scroll</a> .</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the command is the <i>ex</i> <b>a</b> command, it shall be set to the line appended after, if any; otherwise to
|
|
the first column.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the command is the <i>ex</i> <b>i</b> command, it shall be set to the line inserted before, if any; otherwise to
|
|
the first column.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if the command is the <i>ex</i> <b>c</b> command, it shall be set to the indentation of the line replaced.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ol>
|
|
|
|
<h5><a name="tag_04_45_13_62"></a>autoprint, ap</h5>
|
|
|
|
<p>[Default <i>set</i>]</p>
|
|
|
|
<p>If <b>autoprint</b> is set, the current line shall be written after each <i>ex</i> command that modifies the contents of the
|
|
current edit buffer, and after each <b>tag</b> command for which the tag search pattern was found or tag line number was valid,
|
|
unless:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The command was executed while in open or visual mode.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The command was executed as part of a <b>global</b> or <b>v</b> command or <b>@</b> buffer execution.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The command was the form of the <b>read</b> command that reads a file into the edit buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The command was the <b>append</b>, <b>change</b>, or <b>insert</b> command.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The command was not terminated by a <newline>.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The current line shall be written by a flag specified to the command; for example, <b>delete #</b> shall write the current line
|
|
as specified for the flag modifier to the <b>delete</b> command, and not as specified by the <b>autoprint</b> edit option.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<h5><a name="tag_04_45_13_63"></a>autowrite, aw</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>autowrite</b> is set, and the edit buffer has been modified since it was last completely written to any file, the contents
|
|
of the edit buffer shall be written as if the <i>ex</i> <b>write</b> command had been specified without arguments, before each
|
|
command affected by the <b>autowrite</b> edit option is executed. Appending the character <tt>'!'</tt> to the command 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 command
|
|
shall not be executed.</p>
|
|
|
|
<h5><a name="tag_04_45_13_64"></a>beautify, bf</h5>
|
|
|
|
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>beautify</b> is set, all non-printable characters, other than <tab>s, <newline>s, and <form-feed>s,
|
|
shall be discarded from text read in from files. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
|
|
<h5><a name="tag_04_45_13_65"></a>directory, dir</h5>
|
|
|
|
<p>[Default <i>implementation-defined</i>]</p>
|
|
|
|
<p>The value of this option specifies the directory in which the editor buffer is to be placed. If this directory is not writable
|
|
by the user, the editor shall quit.</p>
|
|
|
|
<h5><a name="tag_04_45_13_66"></a>edcompatible, ed</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>Causes the presence of <b>g</b> and <b>c</b> suffixes on substitute commands to be remembered, and toggled by repeating the
|
|
suffixes.</p>
|
|
|
|
<h5><a name="tag_04_45_13_67"></a>errorbells, eb</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If the editor is in <i>ex</i> mode, and the terminal does not support a standout mode (such as inverse video), and
|
|
<b>errorbells</b> is set, error messages shall be preceded by alerting the terminal.</p>
|
|
|
|
<h5><a name="tag_04_45_13_68"></a>exrc</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>exrc</b> is set, <i>ex</i> shall access any <b>.exrc</b> file in the current directory, as described in <a href=
|
|
"#tag_04_45_13_01">Initialization in ex and vi</a> . If <b>exrc</b> is not set, <i>ex</i> shall ignore any <b>.exrc</b> file in the
|
|
current directory during initialization, unless the current directory is that named by the <i>HOME</i> environment variable.</p>
|
|
|
|
<h5><a name="tag_04_45_13_69"></a>ignorecase, ic</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>ignorecase</b> is set, characters that have uppercase and lowercase representations shall have those representations
|
|
considered as equivalent for purposes of regular expression comparison.</p>
|
|
|
|
<p>The <b>ignorecase</b> edit option shall affect all remembered regular expressions; for example, unsetting the <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 the last basic
|
|
regular expression in a case-sensitive fashion.</p>
|
|
|
|
<h5><a name="tag_04_45_13_70"></a>list</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>list</b> is set, edit buffer lines written while in <i>ex</i> command mode shall be written as specified for 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
|
|
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
|
|
cursor does not rest on any character in the line, it shall rest on the <tt>'$'</tt> marking the end of the line.</p>
|
|
|
|
<h5><a name="tag_04_45_13_71"></a>magic</h5>
|
|
|
|
<p>[Default <i>set</i>]</p>
|
|
|
|
<p>If <b>magic</b> is set, modify the interpretation of characters in regular expressions and substitution replacement strings (see
|
|
<a href="#tag_04_45_13_58">Regular Expressions in ex</a> and <a href="#tag_04_45_13_59">Replacement Strings in ex</a> ).</p>
|
|
|
|
<h5><a name="tag_04_45_13_72"></a>mesg</h5>
|
|
|
|
<p>[Default <i>set</i>]</p>
|
|
|
|
<p>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 terminal shall
|
|
be turned on while in open or visual mode. The shell-level command <a href="../utilities/mesg.html"><i>mesg</i></a> <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 the editor
|
|
started (or in a shell escape), such as:</p>
|
|
|
|
<pre>
|
|
<tt>:!mesg y
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>the <b>mesg</b> option in <i>ex</i> shall suppress incoming messages, but the <b>mesg</b> option shall not enable incoming
|
|
messages if <b>mesg n</b> was issued.</p>
|
|
|
|
<h5><a name="tag_04_45_13_73"></a>number, nu</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>number</b> is set, edit buffer lines written while in <i>ex</i> command mode shall be written with line 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 line shall be
|
|
preceded by the line number it will have in the file.</p>
|
|
|
|
<p>In open or visual mode, each edit buffer line shall be displayed with a preceding line number, in the format 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 the line for the
|
|
purposes of evaluating the current column; that is, column position 1 shall be the first column position after the format specified
|
|
by the <b>print</b> command.</p>
|
|
|
|
<h5><a name="tag_04_45_13_74"></a>paragraphs, para</h5>
|
|
|
|
<p>[Default in the POSIX locale <tt>IPLPPPQPP LIpplpipbp</tt>]</p>
|
|
|
|
<p>The <b>paragraphs</b> edit option shall define additional paragraph boundaries for the open and visual mode commands. The
|
|
<b>paragraphs</b> edit option can be set to a character string consisting of zero or more character pairs. It shall be an error to
|
|
set it to an odd number of characters.</p>
|
|
|
|
<h5><a name="tag_04_45_13_75"></a>prompt</h5>
|
|
|
|
<p>[Default <i>set</i>]</p>
|
|
|
|
<p>If <b>prompt</b> is set, <i>ex</i> command mode input shall be prompted for with a colon ( <tt>':'</tt> ); when unset, no prompt
|
|
shall be written.</p>
|
|
|
|
<h5><a name="tag_04_45_13_76"></a>readonly</h5>
|
|
|
|
<p>[Default <i>see text</i>]</p>
|
|
|
|
<p>If the <b>readonly</b> edit option is set, read-only mode shall be enabled (see <a href="#tag_04_45_13_48">Write</a> ). The
|
|
<b>readonly</b> edit option shall be initialized to set if either of the following conditions are true:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The command-line option -R was specified.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Performing actions equivalent to the <a href="../functions/access.html"><i>access</i>()</a> function called with the following
|
|
arguments indicates that the file lacks write permission:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The current pathname is used as the <i>path</i> argument.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The constant <b>W_OK</b> is used as the <i>amode</i> argument.</p>
|
|
</li>
|
|
</ol>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>The <b>readonly</b> edit option may be initialized to set for other, implementation-defined reasons. The <b>readonly</b> edit
|
|
option shall not be initialized to unset based on any special privileges of the user or process. The <b>readonly</b> edit option
|
|
shall be reinitialized each time that the contents of the edit buffer are replaced (for example, by an <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 explicitly unsets it. Once unset,
|
|
it shall again be reinitialized each time that the contents of the edit buffer are replaced.</p>
|
|
|
|
<h5><a name="tag_04_45_13_77"></a>redraw</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>The editor simulates an intelligent terminal on a dumb terminal. (Since this is likely to require a large amount of output to
|
|
the terminal, it is useful only at high transmission speeds.)</p>
|
|
|
|
<h5><a name="tag_04_45_13_78"></a>remap</h5>
|
|
|
|
<p>[Default <i>set</i>]</p>
|
|
|
|
<p>If <b>remap</b> is set, map translation shall allow for maps defined in terms of other maps; translation shall continue until a
|
|
final product is obtained. If unset, only a one-step translation shall be done.</p>
|
|
|
|
<h5><a name="tag_04_45_13_79"></a>report</h5>
|
|
|
|
<p>[Default 5]</p>
|
|
|
|
<p>The value of this <b>report</b> edit option specifies what number of lines being added, copied, deleted, or modified in the edit
|
|
buffer will cause an informational message to be written to the user. The following conditions shall cause an informational
|
|
message. The message shall contain the number of lines added, copied, deleted, or modified, but is otherwise unspecified.</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>An <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> editor command, other than <b>open</b>, <b>undo</b>, 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
|
|
<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
|
|
cause an informational message to be written.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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 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 <b>v</b>
|
|
command, or <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> buffer execution, shall cause an informational message to be
|
|
written.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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=
|
|
"../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
|
|
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=
|
|
"../utilities/vi.html"><i>vi</i></a> buffer execution, shall cause an informational message to be written. (For example, if 3 lines
|
|
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>
|
|
edit option after the command completed.)</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<h5><a name="tag_04_45_13_80"></a>scroll, scr</h5>
|
|
|
|
<p>[Default (number of lines in the display -1)/2]</p>
|
|
|
|
<p>The value of the <b>scroll</b> edit option shall determine the number of lines scrolled by the <i>ex</i> <control>-D and
|
|
<b>z</b> commands. For the <a href="../utilities/vi.html"><i>vi</i></a> <control>-D and <control>-U commands, it shall
|
|
be the initial number of lines to scroll when no previous <control>-D or <control>-U command has been executed.</p>
|
|
|
|
<h5><a name="tag_04_45_13_81"></a>sections</h5>
|
|
|
|
<p>[Default in the POSIX locale <tt>NHSHH HUnhsh</tt>]</p>
|
|
|
|
<p>The <b>sections</b> edit option shall define additional section boundaries for the open and visual mode commands. 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 to
|
|
set it to an odd number of characters.</p>
|
|
|
|
<h5><a name="tag_04_45_13_82"></a>shell, sh</h5>
|
|
|
|
<p>[Default from the environment variable <i>SHELL ]</i></p>
|
|
|
|
<p>The value of this option shall be a string. The default shall be taken from the <i>SHELL</i> environment variable. If the
|
|
<i>SHELL</i> environment variable is null or empty, the <a href="../utilities/sh.html"><i>sh</i></a> (see <a href=
|
|
"sh.html"><i>sh</i></a> ) utility shall be the default.</p>
|
|
|
|
<h5><a name="tag_04_45_13_83"></a>shiftwidth, sw</h5>
|
|
|
|
<p>[Default 8]</p>
|
|
|
|
<p>The value of this option shall give the width in columns of an indentation level used during autoindentation and by the shift
|
|
commands ( <b><</b> and <b>></b>).</p>
|
|
|
|
<h5><a name="tag_04_45_13_84"></a>showmatch, sm</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>The functionality described for the <b>showmatch</b> edit option need not be supported on block-mode terminals or terminals with
|
|
insufficient capabilities.</p>
|
|
|
|
<p>If <b>showmatch</b> is set, in open or visual mode, when a <tt>')'</tt> or <tt>'}'</tt> is typed, if the matching <tt>'('</tt>
|
|
or <tt>'{'</tt> is currently visible on the display, the matching <tt>'('</tt> or <tt>'{'</tt> shall be flagged moving the cursor
|
|
to its location for an unspecified amount of time.</p>
|
|
|
|
<h5><a name="tag_04_45_13_85"></a>showmode</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>showmode</b> is set, in open or visual mode, the current mode that the editor is in shall be displayed on the last line of
|
|
the display. Command mode and text input mode shall be differentiated; other unspecified modes and implementation-defined
|
|
information may be displayed.</p>
|
|
|
|
<h5><a name="tag_04_45_13_86"></a>slowopen</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>slowopen</b> is set during open and visual text input modes, the editor shall not update portions of the display other
|
|
than those display line columns that display the characters entered by the user (see <a href="vi.html#tag_04_167_13_88"><i>Input
|
|
Mode Commands in vi</i></a> ).</p>
|
|
|
|
<h5><a name="tag_04_45_13_87"></a>tabstop, ts</h5>
|
|
|
|
<p>[Default 8]</p>
|
|
|
|
<p>The value of this edit option shall specify the column boundary used by a <tab> in the display (see <a href=
|
|
"#tag_04_45_13_62">autoprint, ap</a> and <a href="vi.html#tag_04_167_13_88"><i>Input Mode Commands in vi</i></a> ).</p>
|
|
|
|
<h5><a name="tag_04_45_13_88"></a>taglength, tl</h5>
|
|
|
|
<p>[Default zero]</p>
|
|
|
|
<p>The value of this edit option shall specify the maximum number of characters that are considered significant in the
|
|
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
|
|
significant.</p>
|
|
|
|
<h5><a name="tag_04_45_13_89"></a>tags</h5>
|
|
|
|
<p>[Default <i>see text</i>]</p>
|
|
|
|
<p>The value of this edit option shall be a string of <blank>-delimited pathnames of files used by the <b>tag</b> command.
|
|
The default value is unspecified.</p>
|
|
|
|
<h5><a name="tag_04_45_13_90"></a>term</h5>
|
|
|
|
<p>[Default from the environment variable <i>TERM ]</i></p>
|
|
|
|
<p>The value of this edit option shall be a string. The default shall be taken from the <i>TERM</i> variable in the environment. If
|
|
the <i>TERM</i> environment variable is empty or null, the default is unspecified. The editor shall use the value of this edit
|
|
option to determine the type of the display device.</p>
|
|
|
|
<p>The results are unspecified if the user changes the value of the term edit option after editor initialization.</p>
|
|
|
|
<h5><a name="tag_04_45_13_91"></a>terse</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>terse</b> is set, error messages may be less verbose. However, except for this caveat, error messages are unspecified.
|
|
Furthermore, not all error messages need change for different settings of this option.</p>
|
|
|
|
<h5><a name="tag_04_45_13_92"></a>warn</h5>
|
|
|
|
<p>[Default <i>set</i>]</p>
|
|
|
|
<p>If <b>warn</b> is set, and the contents of the edit buffer have been modified since they were last completely written, the
|
|
editor shall write a warning message before certain <b>!</b> commands (see <a href="#tag_04_45_13_52">Escape</a> ).</p>
|
|
|
|
<h5><a name="tag_04_45_13_93"></a>window</h5>
|
|
|
|
<p>[Default <i>see text</i>]</p>
|
|
|
|
<p>A value used in open and visual mode, by the <control>-B and <control>-F commands, and, in visual mode, to specify
|
|
the number of lines displayed when the screen is repainted.</p>
|
|
|
|
<p>If the <b>-w</b> command-line option is not specified, the default value shall be set to the value of the <i>LINES</i>
|
|
environment variable. If the <i>LINES</i> environment variable is empty or null, the default shall be the number of lines in the
|
|
display minus 1.</p>
|
|
|
|
<p>Setting the <b>window</b> edit option to zero or to a value greater than the number of lines in the display minus 1 (either
|
|
explicitly or based on the <b>-w</b> option or the <i>LINES</i> environment variable) shall cause the <b>window</b> edit option to
|
|
be set to the number of lines in the display minus 1.</p>
|
|
|
|
<p>The baud rate of the terminal line may change the default in an implementation-defined manner.</p>
|
|
|
|
<h5><a name="tag_04_45_13_94"></a>wrapmargin, wm</h5>
|
|
|
|
<p>[Default 0]</p>
|
|
|
|
<p>If the value of this edit option is zero, it shall have no effect.</p>
|
|
|
|
<p>If not in the POSIX locale, the effect of this edit option is implementation-defined.</p>
|
|
|
|
<p>Otherwise, it shall specify a number of columns from the ending margin of the terminal.</p>
|
|
|
|
<p>During open and visual text input modes, for each character for which any part of the character is displayed in a column that is
|
|
less than <b>wrapmargin</b> columns from the ending margin of the display line, the editor shall behave as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the character triggering this event is a <blank>, it, and all immediately preceding <blank>s on the current line
|
|
entered during the execution of the current text input command, shall be discarded, and the editor shall behave as if the user had
|
|
entered a single <newline> instead. In addition, if the next user-entered character is a <space>, it shall be discarded
|
|
as well.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, if there are one or more <blank>s on the current line immediately preceding the last group of inserted non-
|
|
<blank>s which was entered during the execution of the current text input command, the <blank>s shall be replaced as if
|
|
the user had entered a single <newline> instead.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>If the <b>autoindent</b> edit option is set, and the events described in 1. or 2. are performed, any <blank>s at or after
|
|
the cursor in the current line shall be discarded.</p>
|
|
|
|
<p>The ending margin shall be determined by the system or overridden by the user, as described for <i>COLUMNS</i> in the
|
|
ENVIRONMENT VARIABLES section and the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>.</p>
|
|
|
|
<h5><a name="tag_04_45_13_95"></a>wrapscan, ws</h5>
|
|
|
|
<p>[Default <i>set</i>]</p>
|
|
|
|
<p>If <b>wrapscan</b> is set, searches (the <i>ex</i> <b>/</b> or <b>?</b> addresses, or open and visual mode <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, searches shall stop at the
|
|
beginning or end of the edit buffer.</p>
|
|
|
|
<h5><a name="tag_04_45_13_96"></a>writeany, wa</h5>
|
|
|
|
<p>[Default <i>unset</i>]</p>
|
|
|
|
<p>If <b>writeany</b> is set, some of the checks performed when executing the <i>ex</i> <b>write</b> commands shall be inhibited,
|
|
as described in editor option <b>autowrite</b>.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>Successful completion.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>When any error is encountered and the standard input is not a terminal device file, <i>ex</i> shall not write the file or return
|
|
to command or text input mode, and shall terminate with a non-zero exit status.</p>
|
|
|
|
<p>Otherwise, when an unrecoverable error is encountered, it shall be equivalent to a SIGHUP asynchronous event.</p>
|
|
|
|
<p>Otherwise, when an error is encountered, the editor shall behave as specified in <a href="#tag_04_45_13_03">Command Line Parsing
|
|
in ex</a> .</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_45_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>If a SIGSEGV signal is received while <i>ex</i> is saving a file, the file might not be successfully saved.</p>
|
|
|
|
<p>The <b>next</b> command can accept more than one file, so usage such as:</p>
|
|
|
|
<pre>
|
|
<tt>next `ls [abc]*`
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>is valid; it would not be valid for the <b>edit</b> or <b>read</b> commands, for example, because they expect only one file and
|
|
unspecified results occur.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<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
|
|
and System V implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>. A freely redistributable implementation
|
|
of <i>ex</i>/ <a href="../utilities/vi.html"><i>vi</i></a>, which is tracking IEEE Std 1003.1-2001 fairly closely, and
|
|
demonstrates the intended changes between historical implementations and IEEE Std 1003.1-2001, may be obtained by
|
|
anonymous FTP from:</p>
|
|
|
|
<pre>
|
|
<tt>ftp://ftp.rdg.opengroup.org/pub/mirrors/nvi
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>A <i>restricted editor</i> (both the historical <i>red</i> utility and modifications to <i>ex</i>) were considered and rejected
|
|
for inclusion. Neither option provided the level of security that users might expect.</p>
|
|
|
|
<p>It is recognized that <i>ex</i> visual mode and related features would be difficult, if not impossible, to implement
|
|
satisfactorily on a block-mode terminal, or a terminal without any form of cursor addressing; thus, it is not a mandatory
|
|
requirement that such features should work on all terminals. It is the intention, however, that an <i>ex</i> implementation should
|
|
provide the full set of capabilities on all terminals capable of supporting them.</p>
|
|
|
|
<h5><a name="tag_04_45_18_01"></a>Options</h5>
|
|
|
|
<p>The <b>-c</b> replacement for <b>+</b> <i>command</i> was inspired by the <b>-e</b> option of <a href=
|
|
"../utilities/sed.html"><i>sed</i></a>. Historically, all such commands (see <b>edit</b> and <b>next</b> as well) were executed
|
|
from the last line of the edit buffer. This meant, for example, that <tt>"+/pattern"</tt> would fail unless the <b>wrapscan</b>
|
|
option was set. IEEE Std 1003.1-2001 requires conformance to historical practice. Historically, some implementations
|
|
restricted the <i>ex</i> commands that could be listed as part of the command line arguments. For consistency,
|
|
IEEE Std 1003.1-2001 does not permit these restrictions.</p>
|
|
|
|
<p>In historical implementations of the editor, the <b>-R</b> option (and the <b>readonly</b> edit option) only prevented
|
|
overwriting of files; appending to files was still permitted, mapping loosely into the <i>csh</i> <b>noclobber</b> variable. Some
|
|
implementations, however, have not followed this semantic, and <b>readonly</b> does not permit appending either.
|
|
IEEE Std 1003.1-2001 follows the latter practice, believing that it is a more obvious and intuitive meaning of
|
|
<b>readonly</b>.</p>
|
|
|
|
<p>The <b>-s</b> option suppresses all interactive user feedback and is useful for editing scripts in batch jobs. The list of
|
|
specific effects is historical practice. The terminal type "incapable of supporting open and visual modes" has historically been
|
|
named "dumb".</p>
|
|
|
|
<p>The <b>-t</b> option was required because the <a href="../utilities/ctags.html"><i>ctags</i></a> utility appears in
|
|
IEEE Std 1003.1-2001 and the option is available in all historical implementations of <i>ex</i>.</p>
|
|
|
|
<p>Historically, the <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> utilities accepted a <b>-x</b> option, which did
|
|
encryption based on the algorithm found in the historical <i>crypt</i> utility. The <b>-x</b> option for encryption, and the
|
|
associated <i>crypt</i> utility, were omitted because the algorithm used was not specifiable and the export control laws of some
|
|
nations make it difficult to export cryptographic technology. In addition, it did not historically provide the level of security
|
|
that users might expect.</p>
|
|
|
|
<h5><a name="tag_04_45_18_02"></a>Standard Input</h5>
|
|
|
|
<p>An end-of-file condition is not equivalent to an end-of-file character. A common end-of-file character, <control>-D, is
|
|
historically an <i>ex</i> command.</p>
|
|
|
|
<p>There was no maximum line length in historical implementations of <i>ex</i>. Specifically, as it was parsed in chunks, the
|
|
addresses had a different maximum length than the filenames. Further, the maximum line buffer size was declared as BUFSIZ, which
|
|
was different lengths on different systems. This version selected the value of {LINE_MAX} to impose a reasonable restriction on
|
|
portable usage of <i>ex</i> and to aid test suite writers in their development of realistic tests that exercise this limit.</p>
|
|
|
|
<h5><a name="tag_04_45_18_03"></a>Input Files</h5>
|
|
|
|
<p>It was an explicit decision by the standard developers that a <newline> be added to any file lacking one. It 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 make text files
|
|
lacking a trailing <newline> more portable. It is recognized that this will require a user-specified option 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 than text if
|
|
such files are not otherwise identified by the system. It was agreed that the ability to edit files of arbitrary type 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>
|
|
implementation be required to handle files other than text files.</p>
|
|
|
|
<p>The paragraph in the INPUT FILES section, "By default, ...", is intended to close a long-standing security problem in
|
|
<i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>; that of the "modeline" or "modelines" edit option. This 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,
|
|
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
|
|
the next <tt>':'</tt> or <newline> as a command. Consider the consequences, for example, of an unsuspecting user using
|
|
<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
|
|
as:</p>
|
|
|
|
<pre>
|
|
<tt>ex:! rm -rf :
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>appeared in the signature lines. The standard developers believed strongly that an editor should not by default interpret any
|
|
lines of a file. Vendors are strongly urged to delete this feature from their implementations of <i>ex</i> and <a href=
|
|
"../utilities/vi.html"><i>vi</i></a>.</p>
|
|
|
|
<h5><a name="tag_04_45_18_04"></a>Asynchronous Events</h5>
|
|
|
|
<p>The intention of the phrase "complete write" is that the entire edit buffer be written to stable storage. The note regarding
|
|
temporary files is intended for implementations that use temporary files to back edit buffers unnamed by the user.</p>
|
|
|
|
<p>Historically, SIGQUIT was ignored by <i>ex</i>, but was the equivalent of the <b>Q</b> command in visual mode; that is, it
|
|
exited visual mode and entered <i>ex</i> mode. IEEE Std 1003.1-2001 permits, but does not require, this behavior.
|
|
Historically, SIGINT was often used by <a href="../utilities/vi.html"><i>vi</i></a> users to terminate text input mode (
|
|
<control>-C is often easier to enter than <ESC>). Some implementations of <a href="../utilities/vi.html"><i>vi</i></a>
|
|
alerted the terminal on this event, and some did not. IEEE Std 1003.1-2001 requires that SIGINT behave identically to
|
|
<ESC>, and that the terminal not be alerted.</p>
|
|
|
|
<p>Historically, suspending the <i>ex</i> editor during text input mode was similar to SIGINT, as completed lines were retained,
|
|
but any partial line discarded, and the editor returned to command mode. IEEE Std 1003.1-2001 is silent on this issue;
|
|
implementations are encouraged to follow historical practice, where possible.</p>
|
|
|
|
<p>Historically, the <a href="../utilities/vi.html"><i>vi</i></a> editor did not treat SIGTSTP as an asynchronous event, and it was
|
|
therefore impossible to suspend the editor in visual text input mode. There are two major reasons for this. The first is that
|
|
SIGTSTP is a broadcast signal on UNIX systems, and the chain of events where the shell <a href=
|
|
"../utilities/exec.html"><i>exec</i></a>s an application that then <a href=
|
|
"../utilities/exec.html"><i>exec</i></a>s <a href="../utilities/vi.html"><i>vi</i></a> usually caused confusion for the
|
|
terminal state if SIGTSTP was delivered to the process group in the default manner. The second was that most implementations of the
|
|
UNIX <i>curses</i> package are not reentrant, and the receipt of SIGTSTP at the wrong time will cause them to crash.
|
|
IEEE Std 1003.1-2001 is silent on this issue; implementations are encouraged to treat suspension as an asynchronous event
|
|
if possible.</p>
|
|
|
|
<p>Historically, modifications to the edit buffer made before SIGINT interrupted an operation were retained; that is, anywhere from
|
|
zero to all of the lines to be modified might have been modified by the time the SIGINT arrived. These changes were not discarded
|
|
by the arrival of SIGINT. IEEE Std 1003.1-2001 permits this behavior, noting that the <b>undo</b> command is required to
|
|
be able to undo these partially completed commands.</p>
|
|
|
|
<p>The action taken for signals other than SIGINT, SIGCONT, SIGHUP, and SIGTERM is unspecified because some implementations attempt
|
|
to save the edit buffer in a useful state when other signals are received.</p>
|
|
|
|
<h5><a name="tag_04_45_18_05"></a>Standard Error</h5>
|
|
|
|
<p>For <i>ex</i>/ <a href="../utilities/vi.html"><i>vi</i></a>, diagnostic messages are those messages reported as a 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 insufficient
|
|
resources, or an abnormal termination condition. Diagnostic messages should not be confused with the error messages generated by
|
|
inappropriate or illegal user commands.</p>
|
|
|
|
<h5><a name="tag_04_45_18_06"></a>Initialization in ex and vi</h5>
|
|
|
|
<p>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 of the
|
|
alternate and current pathnames will be set. Informally, they are set as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the <i>ex</i> command is one that replaces the contents of the edit buffer, and it succeeds, the current pathname will be set
|
|
to the filename argument (the first filename argument in the case of the <b>next</b> command) and the alternate pathname will be
|
|
set to the previous current pathname, if there was one.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>In the case of the file read/write forms of the <b>read</b> and <b>write</b> commands, if there is no current pathname, the
|
|
current pathname will be set to the filename argument.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Otherwise, the alternate pathname will be set to the filename argument.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>For example, <b>:edit foo</b> and <b>:recover foo</b>, when successful, set the current pathname, and, if there was a previous
|
|
current pathname, the alternate pathname. The commands <b>:write</b>, <b>!command</b>, and <b>:edit</b> set neither the current or
|
|
alternate pathnames. If the <b>:edit foo</b> command were to fail for some reason, the alternate pathname would be set. The
|
|
<b>read</b> and <b>write</b> commands set the alternate pathname to their <i>file</i> argument, unless the current pathname is not
|
|
set, in which case they set the current pathname to their <i>file</i> arguments. The alternate pathname was not historically set by
|
|
the <b>:source</b> command. IEEE Std 1003.1-2001 requires conformance to historical practice. Implementations adding
|
|
commands that take filenames as arguments are encouraged to set the alternate pathname as described here.</p>
|
|
|
|
<p>Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> read the <b>.exrc</b> file in the <i>$HOME</i>
|
|
directory twice, if the editor was executed in the <i>$HOME</i> directory. IEEE Std 1003.1-2001 prohibits this
|
|
behavior.</p>
|
|
|
|
<p>Historically, the 4 BSD <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> read the <i>$HOME</i> and local <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 considerations.
|
|
This was a security problem because it is possible to put normal UNIX system commands inside a <b>.exrc</b> file.
|
|
IEEE Std 1003.1-2001 does not specify the <b>sourceany</b> option, and historical implementations are encouraged to
|
|
delete it.</p>
|
|
|
|
<p>The <b>.exrc</b> files must be owned by the real ID of the user, and not writable by anyone other than the owner. The
|
|
appropriate privileges exception is intended to permit users to acquire special privileges, but continue to use the <b>.exrc</b>
|
|
files in their home directories.</p>
|
|
|
|
<p>System V Release 3.2 and later <a href="../utilities/vi.html"><i>vi</i></a> implementations added the option <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 <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 System V
|
|
permitted users to give away files, so there is no possible ownership or writeability test to ensure that the file is safe. This is
|
|
still a security problem on systems where users can give away files, but there is nothing additional that
|
|
IEEE Std 1003.1-2001 can do. The implementation-defined exception is intended to permit groups to have local <b>.exrc</b>
|
|
files that are shared by users, by creating pseudo-users to own the shared files.</p>
|
|
|
|
<p>IEEE Std 1003.1-2001 does not mention system-wide <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> start-up
|
|
files. While they exist in several implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>, they are not
|
|
present in any implementations considered historical practice by IEEE Std 1003.1-2001. Implementations that have such
|
|
files should use them 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 by any user other than their owner. System-wide start-up files should be read before the <i>EXINIT</i>
|
|
variable, <b>$HOME/.exrc</b>, or local <b>.exrc</b> files are evaluated.</p>
|
|
|
|
<p>Historically, any <i>ex</i> command could be entered in the <i>EXINIT</i> variable or the <b>.exrc</b> file, although ones
|
|
requiring that the edit buffer already contain lines of text generally caused historical implementations of the editor to drop
|
|
<b>core</b>. IEEE Std 1003.1-2001 requires that any <i>ex</i> command be permitted in the <i>EXINIT</i> variable and
|
|
<b>.exrc</b> files, for simplicity of specification and consistency, although many of them will obviously fail under many
|
|
circumstances.</p>
|
|
|
|
<p>The initialization of the contents of the edit buffer uses the phrase "the effect shall be" with regard to various <i>ex</i>
|
|
commands. The intent of this phrase is that edit buffer contents loaded during the initialization phase not be 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 write the edit
|
|
buffer. An additional intent of this phrase is to specify that the initial current line and column is set as specified for the
|
|
individual <i>ex</i> commands.</p>
|
|
|
|
<p>Historically, the <b>-t</b> option behaved as if the tag search were a <b>+</b> <i>command</i>; that is, it was executed from
|
|
the last line of the file specified by the tag. This resulted in the search failing if the pattern was a forward search pattern and
|
|
the <b>wrapscan</b> edit option was not set. IEEE Std 1003.1-2001 does not permit this behavior, requiring that the
|
|
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
|
|
location in the file.</p>
|
|
|
|
<p>Historically, the empty edit buffer presented for editing when a file was not specified by the user was unnamed. This is
|
|
permitted by IEEE Std 1003.1-2001; however, implementations are encouraged to provide users a temporary filename for this
|
|
buffer because it permits them the use of <i>ex</i> commands that use the current pathname during temporary edit sessions.</p>
|
|
|
|
<p>Historically, the file specified using the <b>-t</b> option was not part of the current argument list. This practice is
|
|
permitted by IEEE Std 1003.1-2001; however, implementations are encouraged to include its name in the current argument
|
|
list for consistency.</p>
|
|
|
|
<p>Historically, the <b>-c</b> command was generally not executed until a file that already exists was edited.
|
|
IEEE Std 1003.1-2001 requires conformance to this historical practice. Commands that could cause the <b>-c</b> command to
|
|
be executed 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="../utilities/vi.html"><i>vi</i></a> commands <control>-^ and <control>-]. Historically, reading a file into an
|
|
edit buffer did not cause the <b>-c</b> command to be executed (even though it might set the current pathname) with the exception
|
|
that 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, the edit buffer was empty, and no read commands had yet been attempted. For consistency and simplicity of specification,
|
|
IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>Historically, the <b>-r</b> option was the same as a normal edit session if there was no recovery information available for the
|
|
file. This allowed users to enter:</p>
|
|
|
|
<pre>
|
|
<tt>vi -r *.c
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>and recover whatever files were recoverable. In some implementations, recovery was attempted only on the first file named, and
|
|
the file was not entered into the argument list; in others, recovery was attempted for each file named. In addition, some
|
|
historical implementations ignored <b>-r</b> if <b>-t</b> was specified or did not support command line <i>file</i> arguments with
|
|
the <b>-t</b> option. For consistency and simplicity of specification, IEEE Std 1003.1-2001 disallows these special
|
|
cases, and requires that recovery be attempted the first time each file is edited.</p>
|
|
|
|
<p>Historically, <a href="../utilities/vi.html"><i>vi</i></a> initialized the <b>`</b> and <b>'</b> marks, but <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 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 entered
|
|
without the marks being initialized. Because the standard developers believed the marks to be generally useful, and for consistency
|
|
and simplicity of specification, IEEE Std 1003.1-2001 requires that they always be initialized if in open or visual mode,
|
|
or if 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 practice; however, it has always been possible to set (and use) marks in empty edit buffers in open and visual mode edit
|
|
sessions.</p>
|
|
|
|
<h5><a name="tag_04_45_18_07"></a>Addressing</h5>
|
|
|
|
<p>Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> accepted the additional addressing forms <tt>'\/'</tt>
|
|
and <tt>'\?'</tt> . They were equivalent to <tt>"//"</tt> and <tt>"??"</tt> , respectively. They are not required by
|
|
IEEE Std 1003.1-2001, mostly because nobody can remember whether they ever did anything different historically.</p>
|
|
|
|
<p>Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> permitted an address of zero for several commands, and
|
|
permitted the <b>%</b> address in empty files for others. For consistency, IEEE Std 1003.1-2001 requires support for the
|
|
former in the few commands where it makes sense, and disallows it otherwise. In addition, because IEEE Std 1003.1-2001
|
|
requires that <b>%</b> be logically equivalent to <tt>"1,$"</tt> , it is also supported where it makes sense and disallowed
|
|
otherwise.</p>
|
|
|
|
<p>Historically, the <b>%</b> address could not be followed by further addresses. For consistency and simplicity of specification,
|
|
IEEE Std 1003.1-2001 requires that additional addresses be supported.</p>
|
|
|
|
<p>All of the following are valid <i>addresses</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><tt>+++</tt></dt>
|
|
|
|
<dd>Three lines after the current line.</dd>
|
|
|
|
<dt><tt>/</tt><i>re</i><tt>/-</tt></dt>
|
|
|
|
<dd>One line before the next occurrence of <i>re</i>.</dd>
|
|
|
|
<dt><tt>-2</tt></dt>
|
|
|
|
<dd>Two lines before the current line.</dd>
|
|
|
|
<dt><tt>3 ---- 2</tt></dt>
|
|
|
|
<dd>Line one (note intermediate negative address).</dd>
|
|
|
|
<dt><tt>1 2 3</tt></dt>
|
|
|
|
<dd>Line six.</dd>
|
|
</dl>
|
|
|
|
<p>Any number of addresses can be provided to commands taking addresses; for example, <tt>"1,2,3,4,5p"</tt> prints lines 4 and 5,
|
|
because two is the greatest valid number of addresses accepted by the <b>print</b> command. This, in combination with the semicolon
|
|
delimiter, permits users to create commands based on ordered patterns in the file. For example, the 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 lines. Note that the address
|
|
<b>3;</b> must be evaluated before being discarded because the search origin for the <b>/foo/</b> command depends on this.</p>
|
|
|
|
<p>Historically, values could be added to addresses by including them after one or more <blank>s; for example,
|
|
<b>3 - 5p</b> wrote the seventh line of the file, and <b>/foo/ 5</b> was the same as <b>/foo/+5</b>. However, only
|
|
absolute values could be added; for example, <b>5 /foo/</b> was an error. IEEE Std 1003.1-2001 requires conformance
|
|
to historical practice. Address offsets are separately specified from addresses because they could historically be provided to
|
|
visual mode search commands.</p>
|
|
|
|
<p>Historically, any missing addresses defaulted to the current line. This was true for leading and trailing comma-delimited
|
|
addresses, and for trailing semicolon-delimited addresses. For consistency, IEEE Std 1003.1-2001 requires it for leading
|
|
semicolon addresses as well.</p>
|
|
|
|
<p>Historically, <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> accepted the <tt>'^'</tt> character as both an address
|
|
and as a flag offset for commands. In both cases it was identical to the <tt>'-'</tt> character. IEEE Std 1003.1-2001
|
|
does not require or prohibit this behavior.</p>
|
|
|
|
<p>Historically, the enhancements to basic regular expressions could be used in addressing; for example, <tt>'˜'</tt> ,
|
|
<tt>'\<'</tt> , and <tt>'\>'</tt> . IEEE Std 1003.1-2001 requires conformance to historical practice; that is, that
|
|
regular expression usage be consistent, and that regular expression enhancements be supported wherever regular expressions are
|
|
used.</p>
|
|
|
|
<h5><a name="tag_04_45_18_08"></a>Command Line Parsing in ex</h5>
|
|
|
|
<p>Historical <i>ex</i> command parsing was even more complex than that described here. IEEE Std 1003.1-2001 requires the
|
|
subset of the command parsing that the standard developers believed was documented and that users could reasonably be expected to
|
|
use in a portable fashion, and that was historically consistent between implementations. (The discarded functionality is obscure,
|
|
at best.) Historical implementations will require changes in order to comply with IEEE Std 1003.1-2001; however, users
|
|
are not expected to notice any of these changes. Most of the complexity in <i>ex</i> parsing is to handle three special termination
|
|
cases:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The <b>!</b>, <b>global</b>, <b>v</b>, and the filter versions of the <b>read</b> and <b>write</b> commands are delimited by
|
|
<newline>s (they can contain vertical-line characters that are usually shell pipes).</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>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> commands,
|
|
optionally containing vertical-line characters, as their first arguments.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The <b>s</b> command takes a regular expression as its first argument, and uses the delimiting characters to delimit the
|
|
command.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Historically, vertical-line characters in the <b>+</b> <i>command</i> argument of the <b>ex</b>, <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 <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>, <b>global</b>, and <b>v</b>
|
|
commands, they did not delimit the command at all. For example, the following commands are all valid:</p>
|
|
|
|
<pre>
|
|
<b>:</b><tt>edit +25 | s/abc/ABC/ file.c
|
|
</tt><b>:</b><tt>s/ | /PIPE/
|
|
</tt><b>:</b><tt>read !spell % | columnate
|
|
</tt><b>:</b><tt>global/pattern/p | l
|
|
</tt><b>:</b><tt>s/a/b/ | s/c/d | set
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>Historically, empty or <blank> filled lines in <b>.exrc</b> files and <b>source</b>d files (as well as <i>EXINIT</i>
|
|
variables and <i>ex</i> command scripts) were treated as default commands; that is, <b>print</b> commands.
|
|
IEEE Std 1003.1-2001 specifically requires that they be ignored when encountered in <b>.exrc</b> and <b>source</b>d files
|
|
to eliminate a common source of new user error.</p>
|
|
|
|
<p>Historically, <i>ex</i> commands with multiple adjacent (or <blank>-separated) vertical lines were handled oddly when
|
|
executed from <i>ex</i> mode. For example, the command <b>|||</b> <carriage-return>, when the cursor was on line 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, instead of the
|
|
next two lines. The former worked more logically when executed from <a href="../utilities/vi.html"><i>vi</i></a> mode, and
|
|
displayed lines 2, 3, and 4. IEEE Std 1003.1-2001 requires the <a href="../utilities/vi.html"><i>vi</i></a> behavior;
|
|
that is, a single default command and line number increment for each command separator, and trailing <newline>s after
|
|
vertical-line separators are discarded.</p>
|
|
|
|
<p>Historically, <i>ex</i> permitted a single extra colon as a leading command character; for example, <b>:g/pattern/:p</b> was a
|
|
valid command. IEEE Std 1003.1-2001 generalizes this to require that any number of leading colon characters be
|
|
stripped.</p>
|
|
|
|
<p>Historically, any prefix of the <b>delete</b> command could be followed without intervening <blank>s by a flag character
|
|
because in the command <b>d p</b>, <i>p</i> is interpreted as the buffer <i>p</i>. IEEE Std 1003.1-2001 requires
|
|
conformance to historical practice.</p>
|
|
|
|
<p>Historically, the <b>k</b> command could be followed by the mark name without intervening <blank>s.
|
|
IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<p>Historically, the <b>s</b> command could be immediately followed by flag and option characters; for example,
|
|
<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
|
|
<b>s l</b> would fail, while the command <b>sgp</b> and <b>s gl</b> would succeed. (Obviously, the <tt>'#'</tt> flag
|
|
character was used as a delimiter character if it followed the command.) Another issue was that option characters had to precede
|
|
flag characters even when the command was fully specified; for example, the command <b>s/e/E/pg</b> would fail, while the command
|
|
<b>s/e/E/gp</b> would succeed. IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<p>Historically, the first command name that had a prefix matching the input from the user was the executed command; 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, however, so that
|
|
<b>a</b> matched <b>append</b>, not <b>abbreviate</b>. IEEE Std 1003.1-2001 requires conformance to historical practice.
|
|
The restriction on command search order for implementations with extensions is to avoid the addition of commands such that the
|
|
historical prefixes would fail to work portably.</p>
|
|
|
|
<p>Historical implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> did not correctly handle multiple
|
|
<i>ex</i> commands, separated by vertical-line characters, that entered or exited visual mode or the editor. Because
|
|
implementations of <a href="../utilities/vi.html"><i>vi</i></a> exist that do not exhibit this failure mode,
|
|
IEEE Std 1003.1-2001 does not permit it.</p>
|
|
|
|
<p>The requirement that alphabetic command names consist of all following alphabetic characters up to the next non-alphabetic
|
|
character means that alphabetic command names must be separated from their arguments by one or more non-alphabetic characters,
|
|
normally a <blank> or <tt>'!'</tt> character, except as specified for the exceptions, the <b>delete</b>, <b>k</b>, and
|
|
<b>s</b> commands.</p>
|
|
|
|
<p>Historically, the repeated execution of the <i>ex</i> default <b>print</b> commands ( <control>-D, <i>eof</i>,
|
|
<newline>, <carriage-return>) erased any prompting character and displayed the next lines without scrolling the
|
|
terminal; that is, immediately below any previously displayed lines. This provided a cleaner presentation of the lines in the file
|
|
for the user. IEEE Std 1003.1-2001 does not require this behavior because it may be impossible in some situations;
|
|
however, implementations are strongly encouraged to provide this semantic if possible.</p>
|
|
|
|
<p>Historically, it was possible to change files in the middle of a command, and have the rest of the command executed in the new
|
|
file; for example:</p>
|
|
|
|
<pre>
|
|
<tt>:edit +25 file.c | s/abc/ABC/ | 1
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>was a valid command, and the substitution was attempted in the newly edited file. IEEE Std 1003.1-2001 requires
|
|
conformance to historical practice. The following commands are examples that exercise the <i>ex</i> parser:</p>
|
|
|
|
<pre>
|
|
<tt>echo 'foo | bar' > file1; echo 'foo/bar' > file2;
|
|
vi
|
|
:edit +1 | s/|/PIPE/ | w file1 | e file2 | 1 | s/\//SLASH/ | wq
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>Historically, there was no protection in editor implementations to avoid <i>ex</i> <b>global</b>, <b>v</b>, <b>@</b>, or
|
|
<b>*</b> commands changing edit buffers during execution of their associated commands. Because this would almost invariably result
|
|
in catastrophic failure of the editor, and implementations exist that do exhibit these problems, IEEE Std 1003.1-2001
|
|
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
|
|
which there will be more than a single execution, be an error. Implementations supporting multiple edit buffers simultaneously are
|
|
strongly encouraged to apply the same semantics to switching between buffers as well.</p>
|
|
|
|
<p>The <i>ex</i> command quoting required by IEEE Std 1003.1-2001 is a superset of the quoting in historical
|
|
implementations of the editor. For example, it was not historically possible to escape a <blank> in a filename; for example,
|
|
<b>:edit foo\\\ bar</b> would report that too many filenames had been entered for the edit command, and there was no
|
|
method of escaping a <blank> in the first argument of an <b>edit</b>, <b>ex</b>, <b>next</b>, or <b>visual</b> command at
|
|
all. IEEE Std 1003.1-2001 extends historical practice, requiring that quoting behavior be made consistent across all
|
|
<i>ex</i> commands, except for the <b>map</b>, <b>unmap</b>, <b>abbreviate</b>, and <b>unabbreviate</b> commands, which
|
|
historically used <control>-V instead of backslashes for quoting. For those four commands, IEEE Std 1003.1-2001
|
|
requires conformance to historical practice.</p>
|
|
|
|
<p>Backslash quoting in <i>ex</i> is non-intuitive. Backslash escapes are ignored unless they escape a special character; for
|
|
example, when performing <i>file</i> argument expansion, the string <tt>"\\%"</tt> is equivalent to <tt>'\%'</tt> , not
|
|
<tt>"\<</tt><i>current pathname</i><tt>>"</tt>. This can be confusing for users because backslash is usually one of the
|
|
characters that causes shell expansion to be performed, and therefore shell quoting rules must be taken into consideration.
|
|
Generally, quoting characters are only considered if they escape a special character, and a quoting character must be provided for
|
|
each layer of parsing for which the character is special. As another example, only a single backslash is necessary for the
|
|
<tt>'\l'</tt> sequence in substitute replacement patterns, because the character <tt>'l'</tt> is not special to any parsing layer
|
|
above it.</p>
|
|
|
|
<p><control>-V quoting in <i>ex</i> is slightly different from backslash quoting. In the four commands where
|
|
<control>-V quoting applies ( <b>abbreviate</b>, <b>unabbreviate</b>, <b>map</b>, and <b>unmap</b>), any character may be
|
|
escaped by a <control>-V whether it would have a special meaning or not. IEEE Std 1003.1-2001 requires conformance
|
|
to historical practice.</p>
|
|
|
|
<p>Historical implementations of the editor did not require delimiters within character classes to be escaped; for example, the
|
|
command <b>:s/[/]//</b> on the string <tt>"xxx/yyy"</tt> would delete the <tt>'/'</tt> from the string.
|
|
IEEE Std 1003.1-2001 disallows this historical practice for consistency and because it places a large burden on
|
|
implementations by requiring that knowledge of regular expressions be built into the editor parser.</p>
|
|
|
|
<p>Historically, quoting <newline>s in <i>ex</i> commands was handled inconsistently. In most cases, the <newline>
|
|
always terminated the command, regardless of any preceding escape character, because backslash characters did not escape
|
|
<newline>s for most <i>ex</i> commands. However, some <i>ex</i> commands (for example, <b>s</b>, <b>map</b>, and
|
|
<b>abbreviation</b>) permitted <newline>s to be escaped (although in the case of <b>map</b> and <b>abbreviation</b>,
|
|
<control>-V characters escaped them instead of backslashes). This was true in not only the command line, but also
|
|
<b>.exrc</b> and <b>source</b>d files. For example, the command:</p>
|
|
|
|
<pre>
|
|
<tt>map = foo<control-V><newline>bar
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>would succeed, although it was sometimes difficult to get the <control>-V and the inserted <newline> passed to the
|
|
<i>ex</i> parser. For consistency and simplicity of specification, IEEE Std 1003.1-2001 requires that it be possible to
|
|
escape <newline>s in <i>ex</i> commands at all times, using backslashes for most <i>ex</i> commands, and using
|
|
<control>-V characters for the <b>map</b> and <b>abbreviation</b> commands. For example, the command <b>print</b>
|
|
<newline> <b>list</b> is required to be parsed as the single command <b>print</b> <newline> <b>list</b>. While this
|
|
differs from historical practice, IEEE Std 1003.1-2001 developers believed it unlikely that any script or user depended
|
|
on the historical behavior.</p>
|
|
|
|
<p>Historically, an error in a command specified using the <b>-c</b> option did not cause the rest of the <b>-c</b> commands to be
|
|
discarded. IEEE Std 1003.1-2001 disallows this for consistency with mapped keys, the <b>@</b>, <b>global</b>,
|
|
<b>source</b>, and <b>v</b> commands, the <i>EXINIT</i> environment variable, and the <b>.exrc</b> files.</p>
|
|
|
|
<h5><a name="tag_04_45_18_09"></a>Input Editing in ex</h5>
|
|
|
|
<p>One of the common uses of the historical <i>ex</i> editor is over slow network connections. Editors that run in canonical mode
|
|
can require far less traffic to and from, and far less processing on, the host machine, as well as more easily supporting
|
|
block-mode terminals. For these reasons, IEEE Std 1003.1-2001 requires that <i>ex</i> be implemented using canonical mode
|
|
input processing, as was done historically.</p>
|
|
|
|
<p>IEEE Std 1003.1-2001 does not require the historical 4 BSD input editing characters "word erase" or "literal
|
|
next". For this reason, it is unspecified how they are handled by <i>ex</i>, although they must have the required effect.
|
|
Implementations that resolve them after the line has been ended using a <newline> or <control>-M character, and
|
|
implementations that rely on the underlying system terminal support for this processing, are both conforming. Implementations are
|
|
strongly urged to use the underlying system functionality, if at all possible, for compatibility with other system text input
|
|
interfaces.</p>
|
|
|
|
<p>Historically, when the <i>eof</i> character was used to decrement the <b>autoindent</b> level, the cursor moved to 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 <control>-D
|
|
character from the line. IEEE Std 1003.1-2001 does not specify that the cursor remain on the same line or that the rest
|
|
of the line is erased; however, implementations are strongly encouraged to provide the best possible user interface; that is, the
|
|
cursor should remain on the same line, and any <control>-D character on the line should be erased.</p>
|
|
|
|
<p>IEEE Std 1003.1-2001 does not require the historical 4 BSD input editing character "reprint", traditionally
|
|
<control>-R, which redisplayed the current input from the user. For this reason, and because the functionality cannot be
|
|
implemented after the line has been terminated by the user, IEEE Std 1003.1-2001 makes no requirements about this
|
|
functionality. Implementations are strongly urged to make this historical functionality available, if possible.</p>
|
|
|
|
<p>Historically, <control>-Q did not perform a literal next function in <i>ex</i>, as it did in <a href=
|
|
"../utilities/vi.html"><i>vi</i></a>. IEEE Std 1003.1-2001 requires conformance to historical practice to avoid breaking
|
|
historical <i>ex</i> scripts and <b>.exrc</b> files.</p>
|
|
|
|
<h5><a name="tag_04_45_18_10"></a>eof</h5>
|
|
|
|
<p>Whether the <i>eof</i> character immediately modifies the <b>autoindent</b> characters in the prompt is left unspecified so that
|
|
implementations can conform in the presence of systems that do not support this functionality. Implementations are encouraged to
|
|
modify the line and redisplay it immediately, if possible.</p>
|
|
|
|
<p>The specification of the handling of the <i>eof</i> character differs from historical practice only in that <i>eof</i>
|
|
characters are not discarded if they follow normal characters in the text input. Historically, they were always discarded.</p>
|
|
|
|
<h5><a name="tag_04_45_18_11"></a>Command Descriptions in ex</h5>
|
|
|
|
<p>Historically, several commands (for example, <b>global</b>, <b>v</b>, <b>visual</b>, <b>s</b>, <b>write</b>, <b>wq</b>,
|
|
<b>yank</b>, <b>!</b>, <b><</b>, <b>></b>, <b>&</b>, and <b>˜</b>) were executable in empty files (that is, the
|
|
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).
|
|
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
|
|
commands (because users may wish to write empty files). IEEE Std 1003.1-2001 requires this behavior for such commands and
|
|
disallows it otherwise, for consistency and simplicity of specification.</p>
|
|
|
|
<p>A count to an <i>ex</i> command has been historically corrected to be no greater than the last line in a file; for example, in a
|
|
five-line file, the command <b>1,6print</b> would fail, but the command <b>1print300</b> would succeed.
|
|
IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<p>Historically, the use of flags in <i>ex</i> commands could be obscure. General historical practice was as described by
|
|
IEEE Std 1003.1-2001, but there were some special cases. For instance, the <b>list</b>, <b>number</b>, and <b>print</b>
|
|
commands ignored trailing address offsets; for example, <b>3p +++#</b> would display line 3, and 3 would be the current line
|
|
after the execution of the command. The <b>open</b> and <b>visual</b> commands ignored both the trailing offsets and the trailing
|
|
flags. Also, flags specified to the <b>open</b> and <b>visual</b> commands interacted badly with the <b>list</b> edit option, and
|
|
setting and then unsetting it during the open/visual session would cause <a href="../utilities/vi.html"><i>vi</i></a> to stop
|
|
displaying lines in the specified format. For consistency and simplicity of specification, IEEE Std 1003.1-2001 does not
|
|
permit any of these exceptions to the general rule.</p>
|
|
|
|
<p>IEEE Std 1003.1-2001 uses the word <i>copy</i> in several places when discussing buffers. This is not intended to
|
|
imply implementation.</p>
|
|
|
|
<p>Historically, <i>ex</i> users could not specify numeric buffers because of the ambiguity this would cause; for example, in the
|
|
command <b>3 delete 2</b>, it is unclear whether 2 is a buffer name or a <i>count</i>. IEEE Std 1003.1-2001
|
|
requires conformance to historical practice by default, but does not preclude extensions.</p>
|
|
|
|
<p>Historically, the contents of the unnamed buffer were frequently discarded after commands that did not explicitly affect it; for
|
|
example, when using the <b>edit</b> command to switch files. For consistency and simplicity of specification,
|
|
IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>The <i>ex</i> utility did not historically have access to the numeric buffers, and, furthermore, deleting lines in <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 user switched
|
|
to <i>ex</i>, did another delete, and then switched back to <a href="../utilities/vi.html"><i>vi</i></a>, the contents of the
|
|
numeric buffers would not have changed. IEEE Std 1003.1-2001 requires conformance to historical practice. Numeric buffers
|
|
are described in the <i>ex</i> utility in order to confine the description of buffers to a single location in
|
|
IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>The metacharacters that trigger shell expansion in <i>file</i> arguments match historical practice, as does the method for doing
|
|
shell expansion. Implementations wishing to provide users with the flexibility to alter the set of metacharacters are encouraged to
|
|
provide a <b>shellmeta</b> string edit option.</p>
|
|
|
|
<p>Historically, <i>ex</i> commands executed from <a href="../utilities/vi.html"><i>vi</i></a> refreshed the screen when it did not
|
|
strictly need to do so; for example, <b>:!date > /dev/null</b> does not require a screen refresh because the output of
|
|
the UNIX <a href="../utilities/date.html"><i>date</i></a> command requires only a single line of the screen.
|
|
IEEE Std 1003.1-2001 requires that the screen be refreshed if it has been overwritten, but makes no requirements as to
|
|
how an implementation should make that determination. Implementations may prompt and refresh the screen regardless.</p>
|
|
|
|
<h5><a name="tag_04_45_18_12"></a>Abbreviate</h5>
|
|
|
|
<p>Historical practice was that characters that were entered as part of an abbreviation replacement were subject to <b>map</b>
|
|
expansions, the <b>showmatch</b> edit option, further abbreviation expansions, and so on; that is, they were logically pushed onto
|
|
the terminal input queue, and were not a simple replacement. IEEE Std 1003.1-2001 requires conformance to historical
|
|
practice. Historical practice was that whenever a non-word character (that had not been escaped by a <control>-V) was entered
|
|
after a word character, <a href="../utilities/vi.html"><i>vi</i></a> would check for abbreviations. The check was based on the type
|
|
of the character entered before the word character of the word/non-word pair that triggered the check. The word character of the
|
|
word/non-word pair that triggered the check and all characters entered before the trigger pair that were of that type were included
|
|
in the check, with the exception of <blank>s, which always delimited the abbreviation.</p>
|
|
|
|
<p>This means that, for the abbreviation to work, the <i>lhs</i> must end with a word character, there can be no transitions from
|
|
word to non-word characters (or <i>vice versa</i>) other than between the last and next-to-last characters in the <i>lhs</i>, and
|
|
there can be no <blank>s in the <i>lhs</i>. In addition, because of the historical quoting rules, it was impossible to enter
|
|
a literal <control>-V in the <i>lhs</i>. IEEE Std 1003.1-2001 requires conformance to historical practice.
|
|
Historical implementations did not inform users when abbreviations that could never be used were entered; implementations are
|
|
strongly encouraged to do so.</p>
|
|
|
|
<p>For example, the following abbreviations will work:</p>
|
|
|
|
<pre>
|
|
<tt>:ab (p REPLACE
|
|
:ab p REPLACE
|
|
:ab ((p REPLACE
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>The following abbreviations will not work:</p>
|
|
|
|
<pre>
|
|
<tt>:ab ( REPLACE
|
|
:ab (pp REPLACE
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>Historical practice is that words on the <a href="../utilities/vi.html"><i>vi</i></a> colon command line were subject to
|
|
abbreviation expansion, including the arguments to the <b>abbrev</b> (and more interestingly) the <b>unabbrev</b> command. Because
|
|
there are implementations that do not do abbreviation expansion for the first argument to those commands, this is permitted, but
|
|
not required, by IEEE Std 1003.1-2001. However, the following sequence:</p>
|
|
|
|
<pre>
|
|
<tt>:ab foo bar
|
|
:ab foo baz
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>resulted in the addition of an abbreviation of <tt>"baz"</tt> for the string <tt>"bar"</tt> in historical <i>ex</i>/ <a href=
|
|
"../utilities/vi.html"><i>vi</i></a>, and the sequence:</p>
|
|
|
|
<pre>
|
|
<tt>:ab foo1 bar
|
|
:ab foo2 bar
|
|
:unabbreviate foo2
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>deleted the abbreviation <tt>"foo1"</tt> , not <tt>"foo2"</tt> . These behaviors are not permitted by
|
|
IEEE Std 1003.1-2001 because they clearly violate the expectations of the user.</p>
|
|
|
|
<p>It was historical practice that <control>-V, not backslash, characters be interpreted as escaping subsequent characters in
|
|
the <b>abbreviate</b> command. IEEE Std 1003.1-2001 requires conformance to historical practice; however, it should be
|
|
noted that an abbreviation containing a <blank> will never work.</p>
|
|
|
|
<h5><a name="tag_04_45_18_13"></a>Append</h5>
|
|
|
|
<p>Historically, any text following a vertical-line command separator after an <b>append</b>, <b>change</b>, or <b>insert</b>
|
|
command became part of the insert text. For example, in the command:</p>
|
|
|
|
<pre>
|
|
<tt>:g/pattern/append|stuff1
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>a line containing the text <tt>"stuff1"</tt> would be appended to each line matching pattern. It was also historically valid to
|
|
enter:</p>
|
|
|
|
<pre>
|
|
<tt>:append|stuff1
|
|
stuff2
|
|
.
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>and the text on the <i>ex</i> command line would be appended along with the text inserted after it. There was an historical bug,
|
|
however, that the user had to enter two terminating lines (the <tt>'.'</tt> lines) to terminate text input mode in this case.
|
|
IEEE Std 1003.1-2001 requires conformance to historical practice, but disallows the historical need for multiple
|
|
terminating lines.</p>
|
|
|
|
<h5><a name="tag_04_45_18_14"></a>Change</h5>
|
|
|
|
<p>See the RATIONALE for the <b>append</b> command. Historical practice for cursor positioning after the change command when no
|
|
text is input, is as described in IEEE Std 1003.1-2001. However, one System V implementation is known to have been
|
|
modified such that the cursor is positioned on the first address specified, and not on the line before the first address.
|
|
IEEE Std 1003.1-2001 disallows this modification for consistency.</p>
|
|
|
|
<p>Historically, the <b>change</b> command did not support buffer arguments, although some implementations allow the specification
|
|
of an optional buffer. This behavior is neither required nor disallowed by IEEE Std 1003.1-2001.</p>
|
|
|
|
<h5><a name="tag_04_45_18_15"></a>Change Directory</h5>
|
|
|
|
<p>A common extension in <i>ex</i> implementations is to use the elements of a <b>cdpath</b> edit option as prefix directories for
|
|
<i>path</i> arguments to <b>chdir</b> that are relative pathnames and that do not have <tt>'.'</tt> or <tt>".."</tt> as their first
|
|
component. Elements in the <b>cdpath</b> edit option are colon-separated. The initial value of the <b>cdpath</b> edit option is the
|
|
value of the shell <i>CDPATH</i> environment variable. This feature was not included in IEEE Std 1003.1-2001 because it
|
|
does not exist in any of the implementations considered historical practice.</p>
|
|
|
|
<h5><a name="tag_04_45_18_16"></a>Copy</h5>
|
|
|
|
<p>Historical implementations of <i>ex</i> permitted copies to lines inside of the specified range; for example, <b>:2,5copy3</b>
|
|
was a valid command. IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<h5><a name="tag_04_45_18_17"></a>Delete</h5>
|
|
|
|
<p>IEEE Std 1003.1-2001 requires support for the historical parsing of a <b>delete</b> command followed by flags, without
|
|
any intervening <blank>s. For example:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>1dp</b></dt>
|
|
|
|
<dd>Deletes the first line and prints the line that was second.</dd>
|
|
|
|
<dt><b>1delep</b></dt>
|
|
|
|
<dd>As for <b>1dp</b>.</dd>
|
|
|
|
<dt><b>1d</b></dt>
|
|
|
|
<dd>Deletes the first line, saving it in buffer <i>p</i>.</dd>
|
|
|
|
<dt><b>1d p1l</b></dt>
|
|
|
|
<dd>(Pee-one-ell.) Deletes the first line, saving it in buffer <i>p</i>, and listing the line that was second.</dd>
|
|
</dl>
|
|
|
|
<h5><a name="tag_04_45_18_18"></a>Edit</h5>
|
|
|
|
<p>Historically, any <i>ex</i> command could be entered as a <b>+</b> <i>command</i> argument to the <b>edit</b> command, although
|
|
some (for example, <b>insert</b> and <b>append</b>) were known to confuse historical implementations. For consistency and
|
|
simplicity of specification, IEEE Std 1003.1-2001 requires that any command be supported as an argument to the
|
|
<b>edit</b> command.</p>
|
|
|
|
<p>Historically, the command argument was executed with the current line set to the last line of the file, regardless of whether
|
|
the <b>edit</b> command was executed from visual mode or not. IEEE Std 1003.1-2001 requires conformance to historical
|
|
practice.</p>
|
|
|
|
<p>Historically, the <b>+</b> <i>command</i> specified to the <b>edit</b> and <b>next</b> commands was delimited by the first
|
|
<blank>, and there was no way to quote them. For consistency, IEEE Std 1003.1-2001 requires that the usual
|
|
<i>ex</i> backslash quoting be provided.</p>
|
|
|
|
<p>Historically, specifying the <b>+</b> <i>command</i> argument to the edit command required a filename to be specified as well;
|
|
for example, <b>:edit +100</b> would always fail. For consistency and simplicity of specification,
|
|
IEEE Std 1003.1-2001 does not permit this usage to fail for that reason.</p>
|
|
|
|
<p>Historically, only the cursor position of the last file edited was remembered by the editor. IEEE Std 1003.1-2001
|
|
requires that this be supported; however, implementations are permitted to remember and restore the cursor position for any file
|
|
previously edited.</p>
|
|
|
|
<h5><a name="tag_04_45_18_19"></a>File</h5>
|
|
|
|
<p>Historical versions of the <i>ex</i> editor <b>file</b> command displayed a current line and number of lines in the edit buffer
|
|
of 0 when the file was empty, while the <a href="../utilities/vi.html"><i>vi</i></a> <control>-G command displayed a current
|
|
line and number of lines in the edit buffer of 1 in the same situation. IEEE Std 1003.1-2001 does not permit this
|
|
discrepancy, instead requiring that a message be displayed indicating that the file is empty.</p>
|
|
|
|
<h5><a name="tag_04_45_18_20"></a>Global</h5>
|
|
|
|
<p>The two-pass operation of the <b>global</b> and <b>v</b> commands is not intended to imply implementation, only the required
|
|
result of the operation.</p>
|
|
|
|
<p>The current line and column are set as specified for the individual <i>ex</i> commands. This requirement is cumulative; that is,
|
|
the current line and column must track across all the commands executed by the <b>global</b> or <b>v</b> commands.</p>
|
|
|
|
<h5><a name="tag_04_45_18_21"></a>Insert</h5>
|
|
|
|
<p>See the RATIONALE for the <b>append</b> command.</p>
|
|
|
|
<p>Historically, <b>insert</b> could not be used with an address of zero; that is, not when the edit buffer was empty.
|
|
IEEE Std 1003.1-2001 requires that this command behave consistently with the <b>append</b> command.</p>
|
|
|
|
<h5><a name="tag_04_45_18_22"></a>Join</h5>
|
|
|
|
<p>The action of the <b>join</b> command in relation to the special characters is only defined for the POSIX locale because the
|
|
correct amount of white space after a period varies; in Japanese none is required, in French only a single space, and so on.</p>
|
|
|
|
<h5><a name="tag_04_45_18_23"></a>List</h5>
|
|
|
|
<p>The historical output of the <b>list</b> command was potentially ambiguous. The standard developers believed correcting this to
|
|
be more important than adhering to historical practice, and IEEE Std 1003.1-2001 requires unambiguous output.</p>
|
|
|
|
<h5><a name="tag_04_45_18_24"></a>Map</h5>
|
|
|
|
<p>Historically, command mode maps only applied to command names; for example, if the character <tt>'x'</tt> was mapped to
|
|
<tt>'y'</tt> , the command <b>fx</b> searched for the <tt>'x'</tt> character, not the <tt>'y'</tt> character.
|
|
IEEE Std 1003.1-2001 requires this behavior. Historically, entering <control>-V as the first character of a <a
|
|
href="../utilities/vi.html"><i>vi</i></a> command was an error. Several implementations have extended the semantics of <a href=
|
|
"../utilities/vi.html"><i>vi</i></a> such that <control>-V means that the subsequent command character is not mapped. This is
|
|
permitted, but not required, by IEEE Std 1003.1-2001. Regardless, using <control>-V to escape the second or later
|
|
character in a sequence of characters that might match a <b>map</b> command, or any character in text input mode, is historical
|
|
practice, and stops the entered keys from matching a map. IEEE Std 1003.1-2001 requires conformance to historical
|
|
practice.</p>
|
|
|
|
<p>Historical implementations permitted digits to be used as a <b>map</b> command <i>lhs</i>, but then ignored the map.
|
|
IEEE Std 1003.1-2001 requires that the mapped digits not be ignored.</p>
|
|
|
|
<p>The historical implementation of the <b>map</b> command did not permit <b>map</b> commands that were more than a single
|
|
character in length if the first character was printable. This behavior is permitted, but not required, by
|
|
IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>Historically, mapped characters were remapped unless the <b>remap</b> edit option was not set, or the prefix of the mapped
|
|
characters matched the mapping characters; for example, in the <b>map</b>:</p>
|
|
|
|
<pre>
|
|
<tt>:map ab abcd
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>the characters <tt>"ab"</tt> were used as is and were not remapped, but the characters <tt>"cd"</tt> were mapped if appropriate.
|
|
This can cause infinite loops in the <a href="../utilities/vi.html"><i>vi</i></a> mapping mechanisms.
|
|
IEEE Std 1003.1-2001 requires conformance to historical practice, and that such loops be interruptible.</p>
|
|
|
|
<p>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> command as
|
|
did the <i>ex</i> <b>abbreviate</b> and <b>unabbreviate</b> commands. See the RATIONALE for the <i>ex</i> <b>abbreviate</b>
|
|
command. IEEE Std 1003.1-2001 requires similar modification of some historical practice for the <b>map</b> and
|
|
<b>unmap</b> commands, as described for the <b>abbreviate</b> and <b>unabbreviate</b> commands.</p>
|
|
|
|
<p>Historically, <b>map</b>s that were subsets of other <b>map</b>s behaved differently depending on the order in which they were
|
|
defined. For example:</p>
|
|
|
|
<pre>
|
|
<tt>:map! ab short
|
|
:map! abc long
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>would always translate the characters <tt>"ab"</tt> to <tt>"short"</tt> , regardless of how fast the characters <tt>"abc"</tt>
|
|
were entered. If the entry order was reversed:</p>
|
|
|
|
<pre>
|
|
<tt>:map! abc long
|
|
:map! ab short
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>the characters <tt>"ab"</tt> would cause the editor to pause, waiting for the completing <tt>'c'</tt> character, and the
|
|
characters might never be mapped to <tt>"short"</tt> . For consistency and simplicity of specification,
|
|
IEEE Std 1003.1-2001 requires that the shortest match be used at all times.</p>
|
|
|
|
<p>The length of time the editor spends waiting for the characters to complete the <i>lhs</i> is unspecified because the timing
|
|
capabilities of systems are often inexact and variable, and it may depend on other factors such as the speed of the 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 have to wait. Some
|
|
implementations of <a href="../utilities/vi.html"><i>vi</i></a> have added a <b>keytime</b> option, which permits users to set the
|
|
number of 0,1 seconds the editor waits for the completing characters. Because mapped terminal function and cursor keys tend to
|
|
start with an <ESC> character, and <ESC> is the key ending <a href="../utilities/vi.html"><i>vi</i></a> text input
|
|
mode, <b>map</b>s starting with <ESC> characters are generally exempted from this timeout period, or, at least timed out
|
|
differently.</p>
|
|
|
|
<h5><a name="tag_04_45_18_25"></a>Mark</h5>
|
|
|
|
<p>Historically, users were able to set the "previous context" marks explicitly. In addition, the <i>ex</i> commands <b>"</b>
|
|
and <b>'`</b> and the <a href="../utilities/vi.html"><i>vi</i></a> commands <b>"</b>, <b>``</b>, <b>`'</b>, and <b>'`</b> all
|
|
referred to the same mark. In addition, the previous context marks were not set if the command, with which the address setting the
|
|
mark was associated, failed. IEEE Std 1003.1-2001 requires conformance to historical practice. Historically, if marked
|
|
lines were deleted, the mark was also deleted, but would reappear if the change was undone. IEEE Std 1003.1-2001 requires
|
|
conformance to historical practice.</p>
|
|
|
|
<p>The description of the special events that set the <b>`</b> and <b>'</b> marks matches historical practice. For 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> did.</p>
|
|
|
|
<h5><a name="tag_04_45_18_26"></a>Next</h5>
|
|
|
|
<p>Historically, any <i>ex</i> command could be entered as a <b>+</b> <i>command</i> argument to the <b>next</b> command, although
|
|
some (for example, <b>insert</b> and <b>append</b>) were known to confuse historical implementations.
|
|
IEEE Std 1003.1-2001 requires that any command be permitted and that it behave as specified. The <b>next</b> command can
|
|
accept more than one file, so usage such as:</p>
|
|
|
|
<pre>
|
|
<tt>next `ls [abc] `
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>is valid; it need not be valid for the <b>edit</b> or <b>read</b> commands, for example, because they expect only one
|
|
filename.</p>
|
|
|
|
<p>Historically, the <b>next</b> command behaved differently from the <b>:rewind</b> command in that it ignored the force flag if
|
|
the <b>autowrite</b> flag was set. For consistency, IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>Historically, the <b>next</b> command positioned the cursor as if the file had never been edited before, regardless.
|
|
IEEE Std 1003.1-2001 does not permit this behavior, for consistency with the <b>edit</b> command.</p>
|
|
|
|
<p>Implementations wanting to provide a counterpart to the <b>next</b> command that edited the previous file have used the command
|
|
<b>prev[ious],</b> which takes no <i>file</i> argument. IEEE Std 1003.1-2001 does not require this command.</p>
|
|
|
|
<h5><a name="tag_04_45_18_27"></a>Open</h5>
|
|
|
|
<p>Historically, the <b>open</b> command would fail if the <b>open</b> edit option was not set. IEEE Std 1003.1-2001 does
|
|
not mention the <b>open</b> edit option and does not require this behavior. Some historical implementations do not permit entering
|
|
open mode from open or visual mode, only from <i>ex</i> mode. For consistency, IEEE Std 1003.1-2001 does not permit this
|
|
behavior.</p>
|
|
|
|
<p>Historically, entering open mode from the command line (that is, <a href="../utilities/vi.html"><i>vi</i></a> <b>+open</b>)
|
|
resulted in anomalous behaviors; for example, the <i>ex</i> file and <a href="../utilities/set.html"><i>set</i></a>
|
|
commands, and the <a href="../utilities/vi.html"><i>vi</i></a> command <control>-G did not work. For consistency,
|
|
IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>Historically, the <b>open</b> command only permitted <tt>'/'</tt> characters to be used as the search pattern delimiter. For
|
|
consistency, IEEE Std 1003.1-2001 requires that the search delimiters used by the <b>s</b>, <b>global</b>, and <b>v</b>
|
|
commands be accepted as well.</p>
|
|
|
|
<h5><a name="tag_04_45_18_28"></a>Preserve</h5>
|
|
|
|
<p>The <b>preserve</b> command does not historically cause the file to be considered unmodified for the purposes of future commands
|
|
that may exit the editor. IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<p>Historical documentation stated that mail was not sent to the user when preserve was executed; however, historical
|
|
implementations did send mail in this case. IEEE Std 1003.1-2001 requires conformance to the historical
|
|
implementations.</p>
|
|
|
|
<h5><a name="tag_04_45_18_29"></a>Print</h5>
|
|
|
|
<p>The writing of NUL by the <b>print</b> command is not specified as a special case because the standard developers did not want
|
|
to require <i>ex</i> to support NUL characters. Historically, characters were displayed using the ARPA standard mappings, which are
|
|
as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Printable characters are left alone.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Control characters less than \177 are represented as <tt>'^'</tt> followed by the character offset from the <tt>'@'</tt>
|
|
character in the ASCII map; for example, \007 is represented as <tt>'^G'</tt> .</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>\177 is represented as <tt>'^'</tt> followed by <tt>'?'</tt> .</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>The display of characters having their eighth bit set was less standard. Existing implementations use hex (0x00), octal (\000),
|
|
and a meta-bit display. (The latter displayed bytes that had their eighth bit set as the two characters <tt>"M-"</tt> followed by
|
|
the seven-bit display as described above.) The latter probably has the best claim to historical practice because it was 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 since
|
|
1980.</p>
|
|
|
|
<p>No specific display format is required by IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>Explicit dependence on the ASCII character set has been avoided where possible, hence the use of the phrase an
|
|
"implementation-defined multi-character sequence" for the display of non-printable characters in preference to the historical
|
|
usage of, for instance, <tt>"^I"</tt> for the <tab>. Implementations are encouraged to conform to historical practice in the
|
|
absence of any strong reason to diverge.</p>
|
|
|
|
<p>Historically, all <i>ex</i> commands beginning with the letter <tt>'p'</tt> could be entered using capitalized versions of the
|
|
commands; for example, <b>P[rint]</b>, <b>Pre[serve]</b>, and <b>Pu[t]</b> were all valid command names.
|
|
IEEE Std 1003.1-2001 permits, but does not require, this historical practice because capital forms of the commands are
|
|
used by some implementations for other purposes.</p>
|
|
|
|
<h5><a name="tag_04_45_18_30"></a>Put</h5>
|
|
|
|
<p>Historically, an <i>ex</i> <b>put</b> command, executed from open or visual mode, was the same as the open or 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 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 taken was
|
|
usually <b>put</b>, and the buffer was handled as if in line mode, but it was possible to get extremely anomalous 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 errors as well,
|
|
such as appending text that was unrelated to the (supposed) contents of the buffer. For consistency and simplicity of
|
|
specification, IEEE Std 1003.1-2001 does not permit these behaviors. All <i>ex</i> <b>put</b> commands are required to
|
|
operate in line mode, and the contents of the buffers are not altered by changing the mode of the editor.</p>
|
|
|
|
<h5><a name="tag_04_45_18_31"></a>Read</h5>
|
|
|
|
<p>Historically, an <i>ex</i> <b>read</b> command executed from open or visual mode, executed in an empty file, left an empty line
|
|
as the first line of the file. For consistency and simplicity of specification, IEEE Std 1003.1-2001 does not permit this
|
|
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
|
|
first. For consistency, IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>Historical implementations of <i>ex</i> were unable to undo <b>read</b> commands that read from the output of a program. For
|
|
consistency, IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>Historically, the <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> message after a successful <b>read</b> or
|
|
<b>write</b> command specified "characters", not "bytes". IEEE Std 1003.1-2001 requires that the number of bytes be
|
|
displayed, not the number of characters, because it may be difficult in multi-byte implementations to determine the number of
|
|
characters read. Implementations are encouraged to clarify the message displayed to the user.</p>
|
|
|
|
<p>Historically, reads were not permitted on files other than type regular, except that FIFO files could be read (probably only
|
|
because they did not exist when <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> were originally written). Because the
|
|
historical <i>ex</i> evaluated <b>read!</b> and <b>read !</b> equivalently, there can be no optional way to force the read.
|
|
IEEE Std 1003.1-2001 permits, but does not require, this behavior.</p>
|
|
|
|
<h5><a name="tag_04_45_18_32"></a>Recover</h5>
|
|
|
|
<p>Some historical implementations of the editor permitted users to recover the edit buffer contents from a previous edit session,
|
|
and then exit without saving those contents (or explicitly discarding them). The intent of IEEE Std 1003.1-2001 in
|
|
requiring that the edit buffer be treated as already modified is to prevent this user error.</p>
|
|
|
|
<h5><a name="tag_04_45_18_33"></a>Rewind</h5>
|
|
|
|
<p>Historical implementations supported the <b>rewind</b> command when the user was editing the first file in the list; that is,
|
|
the file that the <b>rewind</b> command would edit. IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<h5><a name="tag_04_45_18_34"></a>Substitute</h5>
|
|
|
|
<p>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 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
|
|
required by IEEE Std 1003.1-2001. Historically, the <b>c</b> and <b>g</b> options were toggled; for example, the command
|
|
<b>:s/abc/def/</b> was the same as <b>s/abc/def/ccccgggg</b>. For simplicity of specification, IEEE Std 1003.1-2001 does
|
|
not permit this behavior.</p>
|
|
|
|
<p>The tilde command is often used to replace the last search RE. For example, in the sequence:</p>
|
|
|
|
<pre>
|
|
<tt>s/red/blue/
|
|
/green
|
|
˜
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>the <b>˜</b> command is equivalent to:</p>
|
|
|
|
<pre>
|
|
<tt>s/green/blue/
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>Historically, <i>ex</i> accepted all of the following forms:</p>
|
|
|
|
<pre>
|
|
<tt>s/abc/def/
|
|
s/abc/def
|
|
s/abc/
|
|
s/abc
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>IEEE Std 1003.1-2001 requires conformance to this historical practice.</p>
|
|
|
|
<p>The <b>s</b> command presumes that the <tt>'^'</tt> character only occupies a single column in the display. Much of the
|
|
<i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> specification presumes that the <space> only occupies a single
|
|
column in the display. There are no known character sets for which this is not true.</p>
|
|
|
|
<p>Historically, the final column position for the substitute commands was based on previous column movements; a search for a
|
|
pattern followed by a substitution would leave the column position unchanged, while a 0 command followed by a substitution would
|
|
change the column position to the first non- <blank>. For consistency and simplicity of specification,
|
|
IEEE Std 1003.1-2001 requires that the final column position always be set to the first non- <blank>.</p>
|
|
|
|
<h5><a name="tag_04_45_18_35"></a>Set</h5>
|
|
|
|
<p>Historical implementations redisplayed all of the options for each occurrence of the <b>all</b> keyword.
|
|
IEEE Std 1003.1-2001 permits, but does not require, this behavior.</p>
|
|
|
|
<h5><a name="tag_04_45_18_36"></a>Tag</h5>
|
|
|
|
<p>No requirement is made as to where <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> shall look for the 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 current directory.
|
|
A useful extension found in some implementations is to look based on the directory containing the tags file that 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 order to permit
|
|
extensions such as multiple entries in a tags file for a tag.</p>
|
|
|
|
<p>Because users often specify many different tags files, some of which need not be relevant or exist at any particular time,
|
|
IEEE Std 1003.1-2001 requires that error messages about problem tags files be displayed only if the requested tag is not
|
|
found, and then, only once for each time that the <b>tag</b> edit option is changed.</p>
|
|
|
|
<p>The requirement that the current edit buffer be unmodified is only necessary if the file indicated by the tag entry is not the
|
|
same as the current file (as defined by the current pathname). Historically, the file would be reloaded if the filename had
|
|
changed, as well as if the filename was different from the current pathname. For consistency and simplicity of specification,
|
|
IEEE Std 1003.1-2001 does not permit this behavior, requiring that the name be the only factor in the decision.</p>
|
|
|
|
<p>Historically, <a href="../utilities/vi.html"><i>vi</i></a> only searched for tags in the current file from the current cursor to
|
|
the end of the file, and therefore, if the <b>wrapscan</b> option was not set, tags occurring before the current cursor were not
|
|
found. IEEE Std 1003.1-2001 considers this a bug, and implementations are required to search for the first occurrence in
|
|
the file, regardless.</p>
|
|
|
|
<h5><a name="tag_04_45_18_37"></a>Undo</h5>
|
|
|
|
<p>The <b>undo</b> description deliberately uses the word "modified". The <b>undo</b> command is not intended to 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>
|
|
|
|
<p>Cursor positioning after the <b>undo</b> command was inconsistent in the historical <a href=
|
|
"../utilities/vi.html"><i>vi</i></a>, sometimes attempting to restore the original cursor position ( <b>global</b>, <b>undo</b>,
|
|
and <b>v</b> commands), and sometimes, in the presence of maps, placing the cursor on the last line added or changed instead of the
|
|
first. IEEE Std 1003.1-2001 requires a simplified behavior for consistency and simplicity of specification.</p>
|
|
|
|
<h5><a name="tag_04_45_18_38"></a>Version</h5>
|
|
|
|
<p>The <b>version</b> command cannot be exactly specified since there is no widely-accepted definition of what the version
|
|
information should contain. Implementations are encouraged to do something reasonably intelligent.</p>
|
|
|
|
<h5><a name="tag_04_45_18_39"></a>Write</h5>
|
|
|
|
<p>Historically, the <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> message after a successful <b>read</b> or
|
|
<b>write</b> command specified "characters", not "bytes". IEEE Std 1003.1-2001 requires that the number of bytes be
|
|
displayed, not the number of characters because it may be difficult in multi-byte implementations to determine the number of
|
|
characters written. Implementations are encouraged to clarify the message displayed to the user.</p>
|
|
|
|
<p>Implementation-defined tests are permitted so that implementations can make additional checks; for example, for locks or file
|
|
modification times.</p>
|
|
|
|
<p>Historically, attempting to append to a nonexistent file caused an error. It has been left unspecified in
|
|
IEEE Std 1003.1-2001 to permit implementations to let the <b>write</b> succeed, so that the append semantics are similar
|
|
to those of the historical <i>csh</i>.</p>
|
|
|
|
<p>Historical <a href="../utilities/vi.html"><i>vi</i></a> permitted empty edit buffers to be written. However, since the way <a
|
|
href="../utilities/vi.html"><i>vi</i></a> got around dealing with "empty" files was to always have a line in the edit buffer, no
|
|
matter what, it wrote them as files of a single, empty line. IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>Historically, <i>ex</i> restored standard output and standard error to their values as of when <i>ex</i> was invoked, before
|
|
writes to programs were performed. This could disturb the terminal configuration as well as be a security issue for some terminals.
|
|
IEEE Std 1003.1-2001 does not permit this, requiring that the program output be captured and displayed as if by the
|
|
<i>ex</i> <b>print</b> command.</p>
|
|
|
|
<h5><a name="tag_04_45_18_40"></a>Adjust Window</h5>
|
|
|
|
<p>Historically, the line count was set to the value of the <b>scroll</b> option if the type character was end-of-file. This
|
|
feature was broken on most historical implementations long ago, however, and is not documented anywhere. For this reason,
|
|
IEEE Std 1003.1-2001 is resolutely silent.</p>
|
|
|
|
<p>Historically, the <b>z</b> command was <blank>-sensitive and <b>z +</b> and <b>z -</b> did different things than
|
|
<b>z+</b> and <b>z-</b> because the type could not be distinguished from a flag. (The commands <b>z .</b> and <b>z =</b>
|
|
were historically invalid.) IEEE Std 1003.1-2001 requires conformance to this historical practice.</p>
|
|
|
|
<p>Historically, the <b>z</b> command was further <blank>-sensitive in that the <i>count</i> could not be
|
|
<blank>-delimited; for example, the commands <b>z= 5</b> and <b>z- 5</b> were also invalid. Because the
|
|
<i>count</i> is not ambiguous with respect to either the type character or the flags, this is not permitted by
|
|
IEEE Std 1003.1-2001.</p>
|
|
|
|
<h5><a name="tag_04_45_18_41"></a>Escape</h5>
|
|
|
|
<p>Historically, <i>ex</i> filter commands only read the standard output of the commands, letting standard error appear on the
|
|
terminal as usual. The <a href="../utilities/vi.html"><i>vi</i></a> utility, however, read both standard output and standard error.
|
|
IEEE Std 1003.1-2001 requires the latter behavior for both <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a>,
|
|
for consistency.</p>
|
|
|
|
<h5><a name="tag_04_45_18_42"></a>Shift Left and Shift Right</h5>
|
|
|
|
<p>Historically, it was possible to add shift characters to increase the effect of the command; for example, <b><<<</b>
|
|
outdented (or <b>>>></b> indented) the lines 3 levels of indentation instead of the default 1.
|
|
IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<h5><a name="tag_04_45_18_43"></a><control>-D</h5>
|
|
|
|
<p>Historically, the <control>-D command erased the prompt, providing the user with an unbroken presentation of lines from
|
|
the edit buffer. This is not required by IEEE Std 1003.1-2001; implementations are encouraged to provide it if possible.
|
|
Historically, the <control>-D command took, and then ignored, a <i>count</i>. IEEE Std 1003.1-2001 does not permit
|
|
this behavior.</p>
|
|
|
|
<h5><a name="tag_04_45_18_44"></a>Write Line Number</h5>
|
|
|
|
<p>Historically, the <i>ex</i> <b>=</b> command, when executed in <i>ex</i> mode in an empty edit buffer, reported 0, and from open
|
|
or visual mode, reported 1. For consistency and simplicity of specification, IEEE Std 1003.1-2001 does not permit this
|
|
behavior.</p>
|
|
|
|
<h5><a name="tag_04_45_18_45"></a>Execute</h5>
|
|
|
|
<p>Historically, <i>ex</i> did not correctly handle the inclusion of text input commands (that is, <b>append</b>, <b>insert</b>,
|
|
and <b>change</b>) in executed buffers. IEEE Std 1003.1-2001 does not permit this exclusion for consistency.</p>
|
|
|
|
<p>Historically, the logical contents of the buffer being executed did not change if the buffer itself were modified by the
|
|
commands being executed; that is, buffer execution did not support self-modifying code. IEEE Std 1003.1-2001 requires
|
|
conformance to historical practice.</p>
|
|
|
|
<p>Historically, the <b>@</b> command took a range of lines, and the <b>@</b> buffer was executed once per line, with the current
|
|
line ( <tt>'.'</tt> ) set to each specified line. IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<p>Some historical implementations did not notice if errors occurred during buffer execution. This, coupled with the 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>.
|
|
IEEE Std 1003.1-2001 requires that implementations stop buffer execution if any error occurs, if the specified line
|
|
doesn't exist, or if the contents of the edit buffer itself are replaced (for example, the buffer executes the <i>ex</i>
|
|
<b>:edit</b> command).</p>
|
|
|
|
<h5><a name="tag_04_45_18_46"></a>Regular Expressions in ex</h5>
|
|
|
|
<p>Historical practice is that the characters in the replacement part of the last <b>s</b> command-that is, those matched by
|
|
entering a <tt>'˜'</tt> in the regular expression-were not further expanded by the regular expression engine. So, if the
|
|
characters contained the string <tt>"a.,"</tt> they would match <tt>'a'</tt> followed by <tt>".,"</tt> and not <tt>'a'</tt>
|
|
followed by any character. IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<h5><a name="tag_04_45_18_47"></a>Edit Options in ex</h5>
|
|
|
|
<p>The following paragraphs describe the historical behavior of some edit options that were not, for whatever reason, included in
|
|
IEEE Std 1003.1-2001. Implementations are strongly encouraged to only use these names if the functionality described here
|
|
is fully supported.</p>
|
|
|
|
<dl compact>
|
|
<dt><b>extended</b></dt>
|
|
|
|
<dd>The <b>extended</b> edit option has been used in some implementations of <a href="../utilities/vi.html"><i>vi</i></a> to
|
|
provide extended regular expressions instead of basic regular expressions This option was omitted from
|
|
IEEE Std 1003.1-2001 because it is not widespread historical practice.</dd>
|
|
|
|
<dt><b>flash</b></dt>
|
|
|
|
<dd>The <b>flash</b> edit option historically caused the screen to flash instead of beeping on error. This option was omitted from
|
|
IEEE Std 1003.1-2001 because it is not found in some historical implementations.</dd>
|
|
|
|
<dt><b>hardtabs</b></dt>
|
|
|
|
<dd>The <b>hardtabs</b> edit option historically defined the number of columns between hardware tab settings. This option was
|
|
omitted from IEEE Std 1003.1-2001 because it was believed to no longer be generally useful.</dd>
|
|
|
|
<dt><b>modeline</b></dt>
|
|
|
|
<dd>The <b>modeline</b> (sometimes named <b>modelines</b>) edit option historically caused <i>ex</i> or <a href=
|
|
"../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
|
|
security problem, and vendors are strongly encouraged to delete it from historical implementations.</dd>
|
|
|
|
<dt><b>open</b></dt>
|
|
|
|
<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
|
|
omitted because these commands are required by IEEE Std 1003.1-2001.</dd>
|
|
|
|
<dt><b>optimize</b></dt>
|
|
|
|
<dd>The <b>optimize</b> edit option historically expedited text throughput by setting the terminal to not do automatic
|
|
<carriage-return>s when printing more than one logical line of output. This option was omitted from
|
|
IEEE Std 1003.1-2001 because it was intended for terminals without addressable cursors, which are rarely, if ever, still
|
|
used.</dd>
|
|
|
|
<dt><b>ruler</b></dt>
|
|
|
|
<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
|
|
current row/column ruler for the user. This option was omitted from IEEE Std 1003.1-2001 because it is not widespread
|
|
historical practice.</dd>
|
|
|
|
<dt><b>sourceany</b></dt>
|
|
|
|
<dd>The <b>sourceany</b> edit option historically caused <i>ex</i> or <a href="../utilities/vi.html"><i>vi</i></a> to source
|
|
start-up files that were owned by users other than the user running the editor. This option is a security problem, and vendors are
|
|
strongly encouraged to remove it from their implementations.</dd>
|
|
|
|
<dt><b>timeout</b></dt>
|
|
|
|
<dd>The <b>timeout</b> edit option historically enabled the (now standard) feature of only waiting for a short period before
|
|
returning keys that could be part of a macro. This feature was omitted from IEEE Std 1003.1-2001 because its behavior is
|
|
now standard, it is not widely useful, and it was rarely documented.</dd>
|
|
|
|
<dt><b>verbose</b></dt>
|
|
|
|
<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
|
|
<a href="../utilities/vi.html"><i>vi</i></a> to output error messages for common errors; for example, attempting to move the cursor
|
|
past the beginning or end of the line instead of only alerting the screen. (The historical <a href=
|
|
"../utilities/vi.html"><i>vi</i></a> only alerted the terminal and presented no message for such errors. The historical editor
|
|
option <b>terse</b> did not select when to present error messages, it only made existing error messages more or less verbose.) This
|
|
option was omitted from IEEE Std 1003.1-2001 because it is not widespread historical practice; however, implementors are
|
|
encouraged to use it if they wish to provide error messages for naive users.</dd>
|
|
|
|
<dt><b>wraplen</b></dt>
|
|
|
|
<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
|
|
an automatic margin measured from the left margin instead of from the right margin. This is useful when multiple screen sizes are
|
|
being used to edit a single file. This option was omitted from IEEE Std 1003.1-2001 because it is not widespread
|
|
historical practice; however, implementors are encouraged to use it if they add this functionality.</dd>
|
|
</dl>
|
|
|
|
<h5><a name="tag_04_45_18_48"></a>autoindent, ai</h5>
|
|
|
|
<p>Historically, the command <b>0a</b> did not do any autoindentation, regardless of the current indentation of line 1.
|
|
IEEE Std 1003.1-2001 requires that any indentation present in line 1 be used.</p>
|
|
|
|
<h5><a name="tag_04_45_18_49"></a>autoprint, ap</h5>
|
|
|
|
<p>Historically, the <b>autoprint</b> edit option was not completely consistent or based solely on modifications to the edit
|
|
buffer. Exceptions were the <b>read</b> command (when reading from a file, but not from a filter), the <b>append</b>,
|
|
<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
|
|
<b>tag</b> command, which was affected by <b>autoprint</b>. IEEE Std 1003.1-2001 requires conformance to historical
|
|
practice.</p>
|
|
|
|
<p>Historically, the <b>autoprint</b> option only applied to the last of multiple commands entered using vertical-bar delimiters;
|
|
for example, <b>delete</b> <newline> was affected by <b>autoprint</b>, but <b>delete|version</b> <newline> was not.
|
|
IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
|
|
<h5><a name="tag_04_45_18_50"></a>autowrite, aw</h5>
|
|
|
|
<p>Appending the <tt>'!'</tt> character to the <i>ex</i> <b>next</b> command to avoid performing an automatic write was not
|
|
supported in historical implementations. IEEE Std 1003.1-2001 requires that the behavior match the other <i>ex</i>
|
|
commands for consistency.</p>
|
|
|
|
<h5><a name="tag_04_45_18_51"></a>ignorecase, ic</h5>
|
|
|
|
<p>Historical implementations of case-insensitive matching (the <b>ignorecase</b> edit option) lead to counterintuitive situations
|
|
when uppercase characters were used in range expressions. Historically, the process was as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Take a line of text from the edit buffer.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Convert uppercase to lowercase in text line.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Convert uppercase to lowercase in regular expressions, except in character class specifications.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Match regular expressions against text.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>This would mean that, with <b>ignorecase</b> in effect, the text:</p>
|
|
|
|
<pre>
|
|
<tt>The cat sat on the mat
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>would be matched by</p>
|
|
|
|
<pre>
|
|
<tt>/^the/
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>but not by:</p>
|
|
|
|
<pre>
|
|
<tt>/^[A-Z]he/
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>For consistency with other commands implementing regular expressions, IEEE Std 1003.1-2001 does not permit this
|
|
behavior.</p>
|
|
|
|
<h5><a name="tag_04_45_18_52"></a>paragraphs, para</h5>
|
|
|
|
<p>The ISO POSIX-2:1993 standard made the default <b>paragraphs</b> and <b>sections</b> edit options implementation-defined,
|
|
arguing they were historically oriented to the UNIX system <i>troff</i> text formatter, and a "portable user" 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 cursor stop in
|
|
unexpected places. IEEE Std 1003.1-2001 specifies their values in the POSIX locale because the unusual grouping (they
|
|
only work when grouped into two characters at a time) means that they cannot be used for general-purpose movement, regardless.</p>
|
|
|
|
<h5><a name="tag_04_45_18_53"></a>readonly</h5>
|
|
|
|
<p>Implementations are encouraged to provide the best possible information to the user as to the read-only status of the file, with
|
|
the exception that they should not consider the current special privileges of the process. This provides users with a safety net
|
|
because they must force the overwrite of read-only files, even when running with additional privileges.</p>
|
|
|
|
<p>The <b>readonly</b> edit option specification largely conforms to historical practice. The only difference is that historical
|
|
implementations did not notice that the user had set the <b>readonly</b> edit option in cases where the file was already marked
|
|
read-only for some reason, and would therefore reinitialize the <b>readonly</b> edit option the next time the contents of the edit
|
|
buffer were replaced. This behavior is disallowed by IEEE Std 1003.1-2001.</p>
|
|
|
|
<h5><a name="tag_04_45_18_54"></a>report</h5>
|
|
|
|
<p>The requirement that lines copied to a buffer interact differently than deleted lines is historical practice. For 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 copied before a
|
|
report is written.</p>
|
|
|
|
<p>The requirement that the <i>ex</i> <b>global</b>, <b>v</b>, <b>open</b>, <b>undo</b>, and <b>visual</b> commands present reports
|
|
based on the total number of lines added or deleted during the command execution, and that commands executed by the <b>global</b>
|
|
and <b>v</b> commands not present reports, is historical practice. IEEE Std 1003.1-2001 extends historical practice by
|
|
requiring that buffer execution be treated similarly. The reasons for this are two-fold. Historically, only the report by the last
|
|
command executed from the buffer would be seen by the user, as each new report would overwrite the last. In addition, the standard
|
|
developers believed that buffer execution had more in common with <b>global</b> and <b>v</b> commands than it did with other
|
|
<i>ex</i> commands, and should behave similarly, for consistency and simplicity of specification.</p>
|
|
|
|
<h5><a name="tag_04_45_18_55"></a>showmatch, sm</h5>
|
|
|
|
<p>The length of time the cursor spends on the matching character is unspecified because the timing capabilities of 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 become
|
|
annoyed. Some implementations of <a href="../utilities/vi.html"><i>vi</i></a> have added a <b>matchtime</b> option that permits
|
|
users to set the number of 0,1 second intervals the cursor pauses on the matching character.</p>
|
|
|
|
<h5><a name="tag_04_45_18_56"></a>showmode</h5>
|
|
|
|
<p>The <b>showmode</b> option has been used in some historical implementations of <i>ex</i> and <a href=
|
|
"../utilities/vi.html"><i>vi</i></a> to display the current editing mode when in open or visual mode. The editing modes have
|
|
generally included "command" and "input", and sometimes other modes such as "replace" and "change". The string was usually
|
|
displayed on the bottom line of the screen at the far right-hand corner. In addition, a preceding <tt>'*'</tt> character often
|
|
denoted whether the contents of the edit buffer had been modified. The latter display has sometimes been part of the
|
|
<b>showmode</b> option, and sometimes based on another option. This option was not available in the 4 BSD historical implementation
|
|
of <a href="../utilities/vi.html"><i>vi</i></a>, but was viewed as generally useful, particularly to novice users, and is required
|
|
by IEEE Std 1003.1-2001.</p>
|
|
|
|
<p>The <b>smd</b> shorthand for the <b>showmode</b> option was not present in all historical implementations of the editor.
|
|
IEEE Std 1003.1-2001 requires it, for consistency.</p>
|
|
|
|
<p>Not all historical implementations of the editor displayed a mode string for command mode, differentiating command mode from
|
|
text input mode by the absence of a mode string. IEEE Std 1003.1-2001 permits this behavior for consistency with
|
|
historical practice, but implementations are encouraged to provide a display string for both modes.</p>
|
|
|
|
<h5><a name="tag_04_45_18_57"></a>slowopen</h5>
|
|
|
|
<p>Historically the <b>slowopen</b> option was automatically set if the terminal baud rate was less than 1200 baud, 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 inserting
|
|
characters in the middle of a line, characters after the cursor would not be pushed ahead, but would appear to be overwritten.
|
|
Second, when creating a new line of text, lines after the current line would not be scrolled down, but would appear to be
|
|
overwritten. In both cases, ending text input mode would cause the screen to be refreshed to match the actual contents of the edit
|
|
buffer. Finally, terminals that were sufficiently intelligent caused the editor to ignore the <b>slowopen</b> option.
|
|
IEEE Std 1003.1-2001 permits most historical behavior, extending historical practice to require <b>slowopen</b> behaviors
|
|
if the edit option is set by the user.</p>
|
|
|
|
<h5><a name="tag_04_45_18_58"></a>tags</h5>
|
|
|
|
<p>The default path for tags files is left unspecified as implementations may have their own <b>tags</b> implementations that do
|
|
not correspond to the historical ones. The default <b>tags</b> option value should probably at least include the file
|
|
<b>./tags</b>.</p>
|
|
|
|
<h5><a name="tag_04_45_18_59"></a>term</h5>
|
|
|
|
<p>Historical implementations of <i>ex</i> and <a href="../utilities/vi.html"><i>vi</i></a> ignored changes to the <b>term</b> edit
|
|
option after the initial terminal information was loaded. This is permitted by IEEE Std 1003.1-2001; however,
|
|
implementations are encouraged to permit the user to modify their terminal type at any time.</p>
|
|
|
|
<h5><a name="tag_04_45_18_60"></a>terse</h5>
|
|
|
|
<p>Historically, the <b>terse</b> edit option optionally provided a shorter, less descriptive error message, for some error
|
|
messages. This is permitted, but not required, by IEEE Std 1003.1-2001. Historically, most common visual mode errors (for
|
|
example, trying to move the cursor past the end of a line) did not result in an error message, but simply alerted the terminal.
|
|
Implementations wishing to provide messages for novice users are urged to do so based on the <b>edit</b> option <b>verbose</b>, and
|
|
not <b>terse</b>.</p>
|
|
|
|
<h5><a name="tag_04_45_18_61"></a>window</h5>
|
|
|
|
<p>In historical implementations, the default for the <b>window</b> edit option was based on the baud rate as follows:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>If the baud rate was less than 1200, the <b>edit</b> option <b>w300</b> set the window value; for example, the line:</p>
|
|
|
|
<pre>
|
|
<tt>set w300=12
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>would set the window option to 12 if the baud rate was less than 1200.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the baud rate was equal to 1200, the <b>edit</b> option <b>w1200</b> set the window value.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>If the baud rate was greater than 1200, the <b>edit</b> option <b>w9600</b> set the window value.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>The <b>w300</b>, <b>w1200</b>, and <b>w9600</b> options do not appear in IEEE Std 1003.1-2001 because of their
|
|
dependence on specific baud rates.</p>
|
|
|
|
<p>In historical implementations, the size of the window displayed by various commands was related to, but not 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 <b>visual 10</b>, but it
|
|
did not change the value of the <b>window</b> edit option. However, changing the value of the <b>window</b> edit option did change
|
|
the number of lines that were displayed when the screen was repainted. IEEE Std 1003.1-2001 does not permit this behavior
|
|
in the interests of consistency and simplicity of specification, and requires that all commands that change the number of lines
|
|
that are displayed do it by setting the value of the <b>window</b> edit option.</p>
|
|
|
|
<h5><a name="tag_04_45_18_62"></a>wrapmargin, wm</h5>
|
|
|
|
<p>Historically, the <b>wrapmargin</b> option did not affect maps inserting characters that also had associated <i>count</i>s; for
|
|
example <b>:map K 5aABC DEF</b>. Unfortunately, there are widely used maps that depend on this behavior. For
|
|
consistency and simplicity of specification, IEEE Std 1003.1-2001 does not permit this behavior.</p>
|
|
|
|
<p>Historically, <b>wrapmargin</b> was calculated using the column display width of all characters on the screen. For example, an
|
|
implementation using <tt>"^I"</tt> to represent <tab>s when the <b>list</b> edit option was set, where <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 2 for each
|
|
<tab>. The <b>number</b> edit option similarly changed the effective length of the line as well.
|
|
IEEE Std 1003.1-2001 requires conformance to historical practice.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="xcu_chap02.html#tag_02_09_01_01"><i>Command Search and Execution</i></a> , <a href="ctags.html"><i>ctags</i></a> , <a
|
|
href="ed.html"><i>ed</i></a> , <a href="sed.html"><i>sed</i></a> , <a href="sh.html"><i>sh</i></a> , <a href=
|
|
"stty.html"><i>stty</i></a> , <a href="vi.html"><i>vi</i></a> , the System Interfaces volume of IEEE Std 1003.1-2001, <a
|
|
href="../functions/access.html"><i>access</i>()</a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_22"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>The FUTURE DIRECTIONS section is added.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_45_23"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>This utility is marked as part of the User Portability Utilities option.</p>
|
|
|
|
<p>The obsolescent SYNOPSIS is removed, removing the <b>+</b> <i>command</i> and <b>-</b> options.</p>
|
|
|
|
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>In the <b>map</b> command description, the sequence <b>#</b> <i>digit</i> is added.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The <b>directory</b>, <b>edcompatible</b>, <b>redraw</b>, and <b>slowopen</b> edit options are added.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>The <i>ex</i> utility is extensively changed for alignment with the IEEE P1003.2b draft standard. This includes changes as
|
|
a result of the IEEE PASC Interpretations 1003.2 #31, #38, #49, #50, #51, #52, #55, #56, #57, #61, #62, #63, #64, #65, and #78.</p>
|
|
|
|
<p>The <b>-l</b> option is removed.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|