ex(1)ex(1)NAMEex - Edits lines in a file interactively, with screen display.
SYNOPSISex [-lRsv] [-c subcommand] [-w number] [-x] [+ [subcommand]] [-v] [-]
[file...]
ex [-lRsv] [-t tag] [-v] [-x] [file...]
ex [-r[file]] [-lRsv] [-v] [-x] [file]
STANDARDS
Interfaces documented on this reference page conform to industry stan‐
dards as follows:
ex: XCU5.0
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
OPTIONS
Executes the specified ex subcommand (command) before editing begins.
This subcommand may actually consist of several commands sepa‐
rated by vertical line (|) characters. Indents appropriately
for LISP code, and accepts the (, ), {, }, [, and ] characters
(parentheses, braces, and brackets) as text rather than inter‐
preting them as vi subcommands. The LISP modifier is active in
open or visual modes. Recovers file after an editor or system
crash. If you do not specify file, a list of all saved files is
displayed. Sets the readonly option, preventing you from alter‐
ing the file. Does not display the file name or the : prompt
upon entering ex. (Silent mode.) Loads the file that contains
tag and positions the editor at tag. To use this option, you
must first create a database of function names and locations
using the ctags command. Invokes the visual editor. When the
-v option is specified, an enlarged set of subcommands is avail‐
able, including screen editing and cursor movement features.
See the vi(1) reference page. Sets the default window size to
number lines. [Tru64 UNIX] Prompts for an encryption key, then
unencrypts the file. If the file specified is not encrypted or
the incorrect key is entered, garbled text is displayed. Sup‐
presses all interactive user feedback. If you use this option,
file input/output errors do not generate an error message. Per‐
forms the ex subcommand before editing begins. When subcommand
is not entered, a + (plus sign) sets the current line to the
bottom of the file. Normally ex sets the current line to the
last line of the file, or to some specified tag or pattern.
This subcommand may actually consist of several commands sepa‐
rated by vertical line (|) characters.
OPERANDS
The file argument specifies the file or files to be edited. If you
supply more than one file, the ex editor edits each file in the speci‐
fied order.
DESCRIPTION
The ex command is a line-oriented text editor that is a subset of the
vi screen editor.
[Tru64 UNIX] The ex editor is similar to ed, but is more powerful,
providing multiline displays and access to a screen editing mode. You
may prefer to call vi directly to have environment variables set for
screen editing. Also edit, a limited subset of ex, is available for
novices or casual use.
[Tru64 UNIX] To determine how your terminal can perform more effi‐
ciently, ex uses the terminal capability database terminfo and the type
of terminal you are using from the TERM environment variable.
The ex editor has the following features: [Tru64 UNIX] The X subcom‐
mand encrypts a file. Ensure that you remember the encryption key
specified when using this subcommand as there is no simple means of
unencrypting the file if the key is forgotten. Only the first six
characters of the key are significant. The z subcommand lets you
access windows of text, and you can scroll through text by pressing
<Ctrl-d> and <Ctrl-u> (visual (-v) mode only). The undo subcommand
allows you to reverse the last subcommand, even if it is an undo sub‐
command. Thus, you can switch back and forth between the latest change
in the edit file and the last prior file status and view the effect of
a subcommand without that effect being permanent. Commands that affect
the external environment cannot be undone, however. The undo subcom‐
mand causes all marks to be lost on lines changed and then restored if
the marked lines were changed. It does not clear the buffer modified
condition.
The ex command displays changed lines and indicates when more than a
few lines are affected by a subcommand. You can: Retrieve your work
(except changes that were in the buffer) if the system or the editor
crashes by reentering the editor with the -r option and the file name.
Edit a sequence or group of files. You can use the next subcommand to
edit each file on the command line in turn, or to specify a list of
file names to edit (using the shell pattern matching syntax). The
wildcard character % (percent sign) represents the name of the current
edit file and can be used to form file names. Copy and move text
within a file and between files (see the co, d, ya, and pu subcom‐
mands). You use a group of buffers (that have the names of the ASCII
letter a to z) to move text. You can temporarily place text in these
buffers and copy or reinsert it in a file, or you can carry it over to
another file. The buffers are cleared when you quit the editor. The
editor does not notify you if text is placed in a buffer and not used
before exiting the editor. Use patterns that match words. A pattern
can be a fixed character string or a regular expression.
A regular expression is a string constructed of special pattern-
matching characters. Using a regular expression to locate text
in a file gives you more flexibility than trying to locate a
fixed character string. For more information about regular
expressions, see grep.
Editing Modes
When you start the ex editor, it is in command mode. Enter ex subcom‐
mands at the : (colon) prompt. Pressing <Esc> cancels a partial sub‐
command. Entered by a, i, and c. In this state, you can enter text.
Entry state ends normally with a line that has only a (period) on it or
ends abruptly if you press the Interrupt key sequence. Entered by vi,
vi., vi-, or o. Each of the first three commands gives you a full
screen vi editor, but puts the current line in a different place on
entry. Enter vi to put the current line at the top of the screen;
enter vi. to put the current line in the middle of the screen; and
enter vi- to put the current line at the bottom of the screen.
The o command opens a one-line window. All three commands share
the input state of the vi editor. Press <Esc> to exit text
entry mode. To return to the ex command state at the current
line, enter Q while in command mode.
Limits of ex
The ex editor has the following maximum limits: [Tru64 UNIX] 2048
bytes per line [Tru64 UNIX] 256 bytes per global command list [Tru64
UNIX] 128 bytes in the previous inserted and deleted text [Tru64
UNIX] 128 bytes in a shell escape command [Tru64 UNIX] 128 bytes in a
string-valued option [Tru64 UNIX] 100 bytes in a tag name [Tru64
UNIX] 128 map macros with 2048 bytes total
Subcommands
The ex subcommands affect the current line unless you specify other‐
wise. For information about how to address lines in a file, see edit
and vi. For a complete description of edit options, see Setting
Options on the vi(1) reference page.
You can use optional modifiers with some of the subcommands specified
in this section. Any or all modifiers specified by each subcommand can
be used or omitted. Following is a description of the optional modi‐
fiers: Specifies a single address; the default is the current line.
Specifies a line or pair of line addresses separated by a comma (,) or
semicolon (;). The default for range is the current line only (.,.).
A percent sign (%) denotes the range (1,$). If the starting address of
the range specified exceeds the ending address, the range is invalid
and the command is not performed. If more than the expected number of
addresses are provided in a range, the greatest valid number of the
last ones provided are used. For example, 1, 3, 5p prints lines 3 to 5
inclusive (because two is the greatest valid number in the range
accepted by print. Specifies a positive integer that determines the
number of lines affected by the command. The default is 1. Adds num‐
bers to the list-format output where flag is character #, p, or l. The
use of flags applies to all lines written by the list, number, open,
print, substitute, visual, &, and z commands. For all other commands,
it applies to the current line at the completion of the command. Also,
any number or + or - characters cannot be specified after flags. This
causes the line written not to be affected by the command, but rather
affects the line addressed by the offset as described above. The
default is null. Specifies one of a number of named areas for saved
text. The named buffers are specified by the lowercase letters of the
POSIX locale. Specifying the buffer optional modifier causes the area
of text affected by the command to be stored into the buffer as it was
before the command took effect. This argument is also used with the
put command and the visual mode put commands (p and P) to specify the
buffer that provides the text to insert.
If the buffer name is specified in uppercase, and the buffer is
to be modified (using a deletion or yanking command), the buffer
is appended to rather than being overwritten. If the buffer is
not to be modified (as in a visual mode put command), the buffer
name can be specified in lowercase or uppercase with the same
results. There is also one unnamed buffer which is the reposi‐
tory for all text deleted (with the delete or visual mode d com‐
mand), or yanked (with the yank or visual mode y command) when a
buffer is not specified.
Following is the list of valid subcommands: Adds the specified abbrevi‐
ation to the current abbreviation list. Enters input mode and places
text after the specified line. To place the text at the beginning of
the buffer, specify line 0. The ! (exclamation point) toggles the
autoindent editor option setting for the execution of this subcommand.
Writes the argument list (the list of arguments on startup) with the
current argument inside [ and ] (left and right brackets). The argu‐
ment list can later be replaced by the arguments of the next subcom‐
mand. Enters input mode and replaces the lines in range with the input
text. The current line is the last line input. The ! (exclamation
point), toggles the autoindent editor option setting for the execution
of this subcommand. Changes the current working directory to direc‐
tory. If the current buffer has been modified since the last write,
the subcommand issues a warning and fails. You can override this warn‐
ing by appending an ! (exclamation point) to the subcommand name.
Places a copy of the lines in range after the specified line. Line 0
causes the lines to be placed at the beginning of the buffer. Deletes
the specified lines from the buffer. If you specify a named buffer,
the deleted text is placed there; otherwise, the deleted text is placed
in the unnamed buffer. The current line is the line following the
deleted lines, or the last line if the deleted lines were at the end.
Edits file. If the current buffer has been modified since the last
write, the subcommand writes a warning and terminates. You can over‐
ride this action by appending an ! (exclamation point) character to
the subcommand (for example, e!file).
If the +line argument is specified, the current line is the
specified position, where line can be a number (or $) or can be
specified as /pattern or ?pattern. Preceding the pattern with a
/ (slash) starts a search from the beginning of the file. Pre‐
ceding the pattern with a ? (question mark) starts a search
from the end of the file. This subcommand is affected by the
autowrite and writeany editor options. Writes the current path
name, the number of lines, and the current position (if no file
argument was specified). If file is specified, ex changes the
current file name to file without changing the contents of the
buffer or the previous current file. Marks the lines within the
given range that match (g) or do not match (v) the given pat‐
tern. Then executes the ex subcommands with the current line
set to each marked line.
You can specify multiple subcommands, one per line, by escaping
each newline character with a \ (backslash). If the subcommands
argument is not specified, each line is written. For the
append, change, and insert subcommands, the input text is
included as part of the global subcommand; in this case, you can
omit the terminating period if it ends subcommands. The visual
subcommand can be specified as part of subcommands. In this
mode, input is taken from the terminal. Entering a Q from vis‐
ual mode selects the next line matching the pattern and reenters
visual mode, until the list is exhausted.
You cannot use the global subcommand and the undo subcommand in
the subcommands argument. The autoprint, autoindent, and report
editor options are inhibited for the duration of the g or v sub‐
command. Enters input mode and places the input text before the
specified line. The ! (exclamation point) toggles the autoin‐
dent editor option setting for the execution of this subcommand.
Joins the text from the specified lines together into one line.
In the POSIX locale, when the last character on the first line
of a pair of lines to be joined is a (period), two spaces are
added following the period; when the last character of the first
line is a space or when the first character on the second line
of the pair is a ) (right parenthesis), no spaces are added;
otherwise, one space is added following the last character of
the first line. Extra spaces at the start of a line are dis‐
carded.
Appending an ! (exclamation point) character to the join sub‐
command causes a simpler join with no whitespace processing,
independent of the current locale. Writes the addressed lines;
nonprintable characters are written as multicharacter sequences.
The end of the line is marked with a $ (dollar sign).
Long lines are folded. The current line is the last line writ‐
ten. Defines macros for use in visual mode. The first argument
must be a single character or the sequence #digit (one of the
terminal's numbered function keys). When this character or
function key is entered in visual mode, the action is as if the
corresponding rhs had been entered. If the ! (exclamation
point) character is appended to the subcommand name map, the
mapping is effective during input mode rather than command mode.
This allows x to have two different macro definitions at the
same time: one for command mode and one for input mode. Non‐
printable characters, except for the Tab character, require
escaping with <Ctrl-V> (or <Ctrl-Q>) to be entered in the argu‐
ments. On certain block mode terminals, the mapping need not
occur immediately (for example, it might occur after the termi‐
nal transmits a group of characters to the system), but it modi‐
fies the file as if it occurred immediately.
The map subcommand with no arguments writes all of the macros
currently defined. If an ! (exclamation point) is appended to
the subcommand, only the macros effective during input mode are
written; otherwise, only the macros effective during command
mode are written. Gives the specified line the specified mark
x, which must be a single lowercase letter of the POSIX locale.
The current line position is not affected. The expression 'x
can then be used as an address in any subcommand requiring one.
For example, the following subcommand deletes all of the lines
from the current one to the marked line: .,'xd
In addition, see the vi `` and '' subcommands for uses of the
mark in visual mode. If the 'x subcommand is used in nonvisual
mode, the character marked is the first nonspace character of
the current line; otherwise, the character marked is the charac‐
ter at the current column of the current line. Moves the speci‐
fied lines (range) after the target line (line). The current
line is the first of the moved lines. Edits the next file from
the argument list. If the current buffer has been modified
since the last write, the subcommand writes a warning and termi‐
nates. You can override this action by appending the ! (excla‐
mation point) character to the subcommand name (n!). You can
replace the argument list by specifying a new one as arguments
to this subcommand. Editing then starts with the first file on
this new list. The current line is reset as described for the
edit subcommand. This subcommand is affected by the autowrite
and writeany editor options. Writes the selected lines, each
preceded with its line number in decimal. Nonprintable charac‐
ters, except for <Tab>, are expanded as specified by the print
subcommand.
The only meaningful flag is l, which allows additional expanded
writing of tabs and End-of-Line characters by the list subcom‐
mand. The current line is the last line written. Enters open
mode, which is equivalent to visual mode with a one-line window.
All visual mode subcommands are available. If a match is found
for the optional regular expression in line, the cursor is
placed at the start of the matching pattern. The visual mode
subcommand Q (see vi) exits open mode. Saves the current buffer
in a form that can later be recovered by using ex-r or by using
the recover subcommand. After the file has been preserved, a
mail message is sent to the user. The message contains the name
of the file, the time of preservation, and an ex subcommand for
recovering the file. Additional information can be included in
the mail message. Writes the addressed lines. Nonprintable
characters, except for the Tab character, are written as multi‐
character sequences. Long lines are folded. The only meaningful
flags are # and l. The current line is the last line written.
Puts back deleted or yanked lines after the specified line. A
buffer can be specified; otherwise, the text in the unnamed buf‐
fer (where deleted or yanked text is placed by default) is
restored. The current line is the first line put back. Termi‐
nates the editing session. If the current buffer has been modi‐
fied since the last write, the subcommand writes a warning and
terminates. You can override this warning and force an exit,
discarding changes, by appending the character ! to the subcom‐
mand name. Places a copy of the specified file in the current
buffer after the target line (line 0 places text at the begin‐
ning). If no file is named, the current file is the default.
If there is no current file, the specified file becomes the cur‐
rent file. If there is neither current file nor file argument,
the subcommand fails.
The current line is the last line read. In visual mode, the
current line is the first line read. If file is preceded by !,
file is taken to be an operating system command and passed to
the program named in the SHELL environment variable. The
resulting output is read in to the buffer. You can override the
special meaning of ! by escaping it with a \ (backslash) char‐
acter. Attempts to recover file if it was saved as the result
of a preserve subcommand, the receipt of a signal, or a system
or editor crash. The current line is reset as described for the
read subcommand. Rewinds the argument list; that is, sets the
current file to the first file in the argument list. This is
equivalent to a next subcommand with the current argument list
as its argument. If the current buffer has been modified since
the last write, the subcommand writes a warning and terminates.
You can override the action by appending the ! (exclamation
point) character to the subcommand name (rew!). The current
line is reset as described for the read editor subcommand. This
subcommand is affected by the autowrite and writeany editor
options. When no arguments are specified, writes those options
whose values have been changed from the default settings; when
the argument all is specified, writes all of the option values.
Specifying an option name followed by the ? character causes
the current value of that option to be written. The ? can be
separated from the option name by zero or more spaces. The ? is
necessary only for Boolean valued options. Boolean options can
be given values by the form se option to turn them on or se
nooption to turn them off; string and numeric options can be
assigned by the form se option=value. Spaces in strings can be
included as they are by preceding each such character with a \
(backslash). More than one option can be set or listed by a
single set subcommand by specifying multiple arguments, each
separated from the next by one or more spaces. Invokes the pro‐
gram named in the SHELL environment variable with the argument
-i (interactive mode). You can resume editing when the program
exits. Reads and executes subcommands from the file specified
by the mandatory file argument. Such source subcommands can be
nested. Replaces the first instance of pattern by the string
repl on each specified line. If the /pattern/repl/ argument is
not present, the /pattern/repl/ from the previous substitute
subcommand is used.
If options includes the letter g (global), all nonoverlapping
instances of the pattern in the line are substituted. If the
option letter c (confirm) is included, then before each substi‐
tution the line is written with ^ characters written on the fol‐
lowing line, adjacent to and identifying the pattern to be
replaced; an affirmative response causes the substitution to be
done, while any other input causes it to abort. An affirmative
response consists of a line with the affirmative response (as
defined by the current locale) at the beginning of the line.
Such a line is subject to editing in the same way as the command
line (the / or : line at the bottom of the screen).
The current line is the last line substituted. When the c
option is used, typing the Interrupt character or receiving the
SIGINT signal stops the substitute operation, and ex returns to
command mode. All substitutions completed before the interrupt
occurred are retained and none are made after that point. The
current line is the last line substituted.
This subcommand is affected by the LC_MESSAGES environment vari‐
able and the wrapscan option. Allows control to return to the
invoking process; ex suspends itself as if it had received the
SIGTSTP signal. The suspension occurs only if job control is
enabled in the invoking shell.
Following either suspend or stop with the character ! affects
the operation of the autowrite editor option for this subcommand
only.
The current suspend character (see stty) also causes the suspen‐
sion. Searches for the tag string, which can be in a different
file. If the tag is in a different file, the new file is opened
for editing. If the current buffer has been modified since the
last write, the subcommand writes a warning and terminates. You
can override the action by appending the ! character to the
subcommand name. The current line is reset to the line indi‐
cated by the tag. This subcommand is affected by the autowrite,
tags, and writeany editor options.
The tag subcommand searches for tagstring in the tag file
referred to by the tags editor option until a reference to
tagstring is found. The file pointed to by this reference is
loaded into the buffer, and the current line is set to the first
occurrence of the pattern specified in the tags file associated
with the supplied tagstring. If the tags file contained a line
number reference, the current line is set to that line. If the
pattern or line number is not found, the subcommand writes an
error message. If a file referred to by the tags editor option
does not exist or is not readable, the subcommand also writes an
error message. Deletes word from the list of abbreviations, as
described by the abbrev subcommand. Reverses the changes made
by the previous editing subcommand (one that changes the con‐
tents of the buffer). For this purpose, global and visual are
considered single subcommands. An undo can be reversed. Com‐
mands that affect the external environment, such as write, edit,
and next cannot be undone. If no ! (exclamation point) is
specified, removes the command-mode macro definition for x; oth‐
erwise, removes the input-mode macro definition for x. See the
map subcommand. Enters visual mode with the current line set to
line. The type argument is optional, and can be a - (minus
sign), (period), + (plus sign), or ^ (circumflex), as in the z
subcommand, to specify the position of the specified line on the
screen window. (The default is to place the line at the top of
the screen window.) The count argument specifies the number of
lines that are initially written; the default is the value of
the window editor option. The Q subcommand exits visual mode.
(For more information about the Q subcommand, see the vi(1) ref‐
erence page.) Writes the specified lines (the whole buffer, if
range is not specified) out to the file represented by path name
file, writing to standard output the number of lines and bytes
written.
If file is specified and is not the current file, and the file
named by file exists, then the write fails. If the current file
has been changed by the file subcommand and that file exists,
the write fails. In either case, you can force the write by
appending the ! (exclamation point) character to the subcommand
name. You can append to an existing file by appending >> to the
subcommand name.
If the file argument is preceded by an ! (exclamation point)
character, the program named in the SHELL environment variable
is invoked with file as its second argument, and the specified
lines are passed as standard input to the subcommand. The ! in
this usage must be separated from the write subcommand by at
least one space character. You can override the special meaning
of ! by escaping it with a \ (backslash) character. This sub‐
command is affected by the writeany and readonly editor options.
The subcommand wq is equivalent to a w followed by a q; wq! is
equivalent to w! followed by q. If the current buffer has no
path name associated with it, the write subcommand fails. Per‐
forms a write subcommand if any changes have been made to the
current buffer since the last write to any file.
Unless the subcommand fails because an attempt to write lines to
a file did not succeed, the ex program exits after an x subcom‐
mand. This subcommand is affected by the writeany and readonly
editor options. [Tru64 UNIX] Prompts you to enter an encryp‐
tion key. Only the first six characters of this key are signifi‐
cant. When the ex command writes a file after the encryption
key is specified, the output is written in encrypted form. Sub‐
sequent edits of the file require the use of the -x option to
display the file in its unencrypted form. Places the specified
lines in the named buffer. If no buffer is specified, the
unnamed buffer is used (where the most recently deleted or
yanked text is placed by default). If type is omitted, count
lines following the specified line are written. The default for
count is the value of the window editor option. The type argu‐
ment changes the position where line is written on the screen by
affecting the number of lines written before and after line.
If type is specified, it is one of the following: Places line at
the bottom of the screen. Places line at the top of the screen.
Places line in the middle. Writes out count lines starting
count*2 lines before the addressed line; the net effect of this
is that a z^ subcommand following another z subcommand writes
the previous page. Centers the addressed line on the screen
with a line of - (dash) characters written immediately before
and after it. The number of preceding and following lines of
text written are reduced to account for these lines of hyphens.
In all cases, the current line is the last line written, with
the exception of the = type, which causes the current line to be
that addressed in the subcommand. Passes the remainder of the
line after the ! (exclamation point) character to the program
named in the SHELL environment variable for execution. A warn‐
ing is issued if the buffer has been changed since the last
write. A single ! character is written when the subcommand
completes. The current line position is not affected.
Within the text of subcommand, % (percent sign) and # (number
sign) are expanded as path names (the current and alternative
path names, respectively), and ! is replaced with the text of
the previous ! subcommand. (Thus, !! repeats the previous !
subcommand.) If any such expansion is performed, the expanded
line is echoed.
You can override the special meanings of %, #, and ! by escap‐
ing them with a \ (backslash) character. This subcommand is
affected by the autowrite and writeany editor options.
In the second form of the ! subcommand, the remainder of the
line after the ! is passed to the program named in the SHELL
environment variable, as described previously. The specified
lines are provided to the program as standard input; the result‐
ing output replaces the specified lines. Shifts the specified
lines to the left; the number of character positions to be
shifted is determined by the shiftwidth editor option. Only
leading spaces are lost in shifting; other characters are not
affected. The current line is the last line changed. Shifts
the specified lines to the right, by inserting spaces, using
tabs where possible, as determined by the shiftwidth editor
option. Empty lines are not changed. The current line is the
last line changed. Repeats the previous substitute subcommand,
as if (&) were replaced by the previous s/pattern/repl/ subcom‐
mand. (The same effect can be obtained by omitting the /pat‐
tern/repl/ string in the substitute subcommand.) The version of
the subcommand using ~ (tilde) is the same as & and s, but the
pattern used is the last regular expression used in any subcom‐
mand, not necessarily the one used in the last substitute sub‐
command. For example, in the following sequence, the ~ (tilde)
is equivalent to s/green/blue/:
s/red/blue/ /green ~ Writes the line number of the specified
line (the default is the last line). The current line position
is not affected. Writes the next n lines, where n is the value
of the editor option scroll. The subcommand is invoked with the
End-of-File character. The current line is the last line writ‐
ten. Executes each line of the named buffer as an ex subcom‐
mand. If no buffer is specified, or is specified as @ or *, the
last buffer executed is used. If there is no last buffer, an
error occurs. Displays addressed lines with line numbers Starts
comment Displays next line
Subcommand Addresses
The last line The next line The previous line The nth line forward The
nth previous line The first through last lines Line number The current
line The numberth line before line x Lines x through y The line marked
with m The previous context The next line with pattern at end of line
The next line with pattern at start of line The next line with pattern
The previous line with pattern
Scanning Pattern Formation
The beginning of the line The end of the line Any character The begin‐
ning of the word The end of the word Any character in string Any char‐
acter not in string Any character between x and y, inclusive Any number
of the preceding character The replacement part of the last substitute
subcommand. A regular expression pattern can be enclosed in escaped
parentheses to identify them for substitution actions.
Startup Files
When you customize ex from the ex command line, the customized editor
is in effect until you exit the editor. If you want to reuse such
things as option settings and key mappings, you must put them in the
file in your home directory or define the EXINIT environment variable.
The ex editor processes the commands given in the EXINIT variable or
reads the file each time you invoke it. Here is an example of an file:
set ai aw set wm=5
Users with both an file and an EXINIT environment variable will find
that the ex editor no longer reads the file. This change was made to
meet the specifications of XPG4.
The standard provides for an approximation of the old behavior. A new
variable, named exrc, is defined. When this variable is set by the
commands in the EXINIT environment variable, the editor reads in the
current directory for additional startup commands. For example:
setenv EXINIT 'set ai terse magic bf wm=1 exrc'
Additionally, the editor refuses to read the file if its mode grants
write permission to anyone other than the owner; this restriction pre‐
vents certain security breaches. No overt indication is given when such
a refusal occurs.
EXIT STATUS
The following exit values are returned: Successful completion. An
error occurred.
If the environment variable STDS_FLAG is set to ALL, the exit
status will be set to 1 whenever a read only option with write
fails.
ASYNCHRONOUS EVENTS
The following actions are taken upon receipt of signals: When an inter‐
rupt occurs, ex alerts the terminal and writes a message. The current
editor command is aborted and ex returns to the command level and
prompts for another command. If the standard input is not a terminal
device, ex exits at the interrupt and returns a non-zero exit status.
(The alerting action can be modified by the use of the errorbells edi‐
tor option.) The screen is refreshed if in visual mode. If the cur‐
rent buffer has changed since the last e or w command, ex attempts to
save the current file in a state such that it can be recovered later by
an ex-r or vi -r command.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of ex: Over‐
rides the system-selected horizontal screen size. Determines a list of
ex commands to be executed at startup before the first file is read.
The list can include multiple commands separated by a vertical line (|)
character. Determines the path name of a directory searched at startup
for a file named Provides a default value for the internationalization
variables that are unset or null. If LANG is unset or null, the corre‐
sponding value from the default locale is used. If any of the interna‐
tionalization variables contain an invalid setting, the utility behaves
as if none of the variables had been defined. If set to a non-empty
string value, overrides the values of all the other internationaliza‐
tion variables. Determines the locale for the behavior of ranges,
equivalence classes, and multicharacter collating elements within regu‐
lar expressions. Determines the locale for the interpretation of
sequences of bytes of text data as characters (for example, single-byte
as opposed to multibyte characters in arguments and input files), the
behavior of character classes within regular expressions, the classifi‐
cation of characters as upper- or lower-case letters, the case conver‐
sion of letters, and the detection of word boundaries. Overrides the
system-selected vertical screen size, used as the number of lines in a
screenful and the vertical screen size in visual mode. Determines the
locale for the format and contents of diagnostic messages written to
standard error. Determines the location of message catalogues for the
processing of LC_MESSAGES. Determines the search path for the shell
command specified in the editor commands shell, read and write and the
visual-mode command !. Determines the preferred command line inter‐
preter for use in !, shell, read and other commands with an operand of
the form !string. For the shell command the program will be invoked
with the single argument -i, for all others it will be invoked with the
two arguments -c and string. If this variable is null or not set, the
POSIX compliant sh command will be used. Resolves the behavior of the
command in some scenarios that cause noncompliance with POSIX stan‐
dards. Setting this variable to ALL enables the command to overcome all
instances of noncompliance. Determines the name of the terminal type.
If this variable is unset or null, a default terminal type that pro‐
vides most capabilities is used.
FILES
recover subcommand preserve subcommand Terminal information database
Editor startup file Editor temporary file Names buffer temporary file
Preservation directory
SEE ALSO
Commands: ctags(1), edit(1), ed(1), grep(1), sed(1), stty(1), vi(1)
Files: terminfo(4)
Environment: environ(5)
Standards: standards(5)ex(1)