 |
Index for Section 1 |
|
 |
Alphabetical listing for E |
|
 |
Bottom of page |
|
ex(1)
NAME
ex - Edits lines in a file interactively, with screen display.
SYNOPSIS
ex [-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 standards
as follows:
ex: XCU5.0
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
OPTIONS
-c subcommand
Executes the specified ex subcommand (command) before editing begins.
This subcommand may actually consist of several commands separated by
vertical line (|) characters.
-l Indents appropriately for LISP code, and accepts the (, ), {, }, [, and
] characters (parentheses, braces, and brackets) as text rather than
interpreting them as vi subcommands. The LISP modifier is active in
open or visual modes.
-r [file]
Recovers file after an editor or system crash. If you do not specify
file, a list of all saved files is displayed.
-R Sets the readonly option, preventing you from altering the file.
-s Does not display the file name or the : prompt upon entering ex.
(Silent mode.)
-t tag
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.
-v Invokes the visual editor. When the -v option is specified, an
enlarged set of subcommands is available, including screen editing and
cursor movement features. See the vi(1) reference page.
-w number
Sets the default window size to number lines.
-x [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.
- Suppresses all interactive user feedback. If you use this option, file
input/output errors do not generate an error message.
+[subcommand]
Performs 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 separated by
vertical line (|) characters.
OPERANDS
file
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
specified 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 efficiently,
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 subcommand 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 subcommand. 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 subcommand 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 subcommands). 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
Command mode
When you start the ex editor, it is in command mode. Enter ex
subcommands at the : (colon) prompt. Pressing <Esc> cancels a partial
subcommand.
Text entry mode
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.
Visual and open mode
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 otherwise.
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 modifiers:
line
Specifies a single address; the default is the current line.
range
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.
count
Specifies a positive integer that determines the number of lines
affected by the command. The default is 1.
flags
Adds numbers 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.
buffer
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 repository for all text deleted (with the delete or
visual mode d command), or yanked (with the yank or visual mode y
command) when a buffer is not specified.
Following is the list of valid subcommands:
ab[brev] word abbrev
Adds the specified abbreviation to the current abbreviation list.
[line] a[ppend][!]
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.
ar[gs]
Writes the argument list (the list of arguments on startup) with the
current argument inside [ and ] (left and right brackets). The
argument list can later be replaced by the arguments of the next
subcommand. 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.
chd[ir][!] [directory]
cd[!] [directory]
Changes the current working directory to directory. If the current
buffer has been modified since the last write, the subcommand issues a
warning and fails. You can override this warning by appending an !
(exclamation point) to the subcommand name.
[range] co[py] line [flags]
[range] t line [flags]
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.
[range] d[elete] [buffer] [count] [flags]
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.
e[dit][!] [+line] [file]
ex[!] [+line] [file]
Edits file. If the current buffer has been modified since the last
write, the subcommand writes a warning and terminates. You can
override 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. Preceding 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.
f[ile] [file]
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.
[range] g[lobal] /pattern/ [subcommands]
[range] v /pattern/ [subcommands]
Marks the lines within the given range that match (g) or do not match
(v) the given pattern. 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 visual 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 subcommand.
[line] i[nsert][!]
Enters input mode and places the input text before the specified line.
The ! (exclamation point) toggles the autoindent editor option setting
for the execution of this subcommand.
[range] j[oin][!] [count] [flags]
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 discarded.
Appending an ! (exclamation point) character to the join subcommand
causes a simpler join with no whitespace processing, independent of the
current locale.
[range] l[ist] [count] [flags]
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 written.
map[!] [x rhs]
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. Nonprintable characters, except for the Tab character, require
escaping with <Ctrl-V> (or <Ctrl-Q>) to be entered in the arguments.
On certain block mode terminals, the mapping need not occur immediately
(for example, it might occur after the terminal transmits a group of
characters to the system), but it modifies 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.
[line] ma[rk] x
[line] k x
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 character at the current column
of the current line.
[range] m[ove] line
Moves the specified lines (range) after the target line (line). The
current line is the first of the moved lines.
n[ext][!] [file ...]
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
terminates. You can override this action by appending the !
(exclamation 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.
[range] nu[mber] [count] [flags]
[range] # [count] [flags]
Writes the selected lines, each preceded with its line number in
decimal. Nonprintable characters, 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 subcommand. The current
line is the last line written.
[line] o[pen] /pattern/ [flags]
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.
pre[serve]
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.
[range] p[rint] [count] [flags]
Writes the addressed lines. Nonprintable characters, except for the
Tab character, are written as multicharacter sequences. Long lines are
folded. The only meaningful flags are # and l. The current line is
the last line written.
[line] pu[t] [buffer]
Puts back deleted or yanked lines after the specified line. A buffer
can be specified; otherwise, the text in the unnamed buffer (where
deleted or yanked text is placed by default) is restored. The current
line is the first line put back.
q[uit][!]
Terminates the editing session. If the current buffer has been
modified 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 subcommand
name.
[line] r[ead][!] [file]
Places a copy of the specified file in the current buffer after the
target line (line 0 places text at the beginning). If no file is
named, the current file is the default. If there is no current file,
the specified file becomes the current 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) character.
rec[over] file
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.
rew[ind][!]
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.
se[t] [option[=[value]] ... [nooption ...] [option? ...] [all]
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.
sh[ell]
Invokes the program named in the SHELL environment variable with the
argument -i (interactive mode). You can resume editing when the program
exits.
so[urce] file
Reads and executes subcommands from the file specified by the mandatory
file argument. Such source subcommands can be nested.
[range] s[ubstitute] [/pattern/repl/[options] [count] [flags]
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 substitution the line is
written with ^ characters written on the following 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 variable and
the wrapscan option.
su[spend][!]
st[op][!]
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 suspension.
ta[g][!] tagstring
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 indicated 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.
una[bbrev] word
Deletes word from the list of abbreviations, as described by the abbrev
subcommand.
u[ndo]
Reverses the changes made by the previous editing subcommand (one that
changes the contents of the buffer). For this purpose, global and
visual are considered single subcommands. An undo can be reversed.
Commands that affect the external environment, such as write, edit, and
next cannot be undone.
unm[ap][!] x
If no ! (exclamation point) is specified, removes the command-mode
macro definition for x; otherwise, removes the input-mode macro
definition for x. See the map subcommand.
[line] vi[sual] [type] [count] [flags]
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) reference page.)
[range] w[rite][!] [>>] [file]
[range] w[rite] [!] [file]
[range] wq[!] [>>] [file]
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 subcommand 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.
[range] x[it][!] [file]
Performs 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 subcommand. This
subcommand is affected by the writeany and readonly editor options.
X [Tru64 UNIX] Prompts you to enter an encryption key. Only the first
six characters of this key are significant. When the ex command writes
a file after the encryption key is specified, the output is written in
encrypted form. Subsequent edits of the file require the use of the -x
option to display the file in its unencrypted form.
[range] ya[nk] [buffer] [count]
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).
[line] z [type] [count] [flags]
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 argument 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:
- (dash)
Places line at the bottom of the screen.
+ (plus sign)
Places line at the top of the screen.
. (period)
Places line in the middle.
^ (circumflex)
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.
= (equal sign)
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.
! subcommand
[range]! subcommand
Passes the remainder of the line after the ! (exclamation point)
character to the program named in the SHELL environment variable for
execution. A warning 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 escaping 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 resulting output replaces the specified
lines.
[range] < [count] [flags]
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.
[range] > [count] [flags]
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.
[range] & [options] [count] [flags]
[range] s[ubstitute] [options] [count] [flags]
[range] ~ [options] [count] [flags]
Repeats the previous substitute subcommand, as if (&) were replaced by
the previous s/pattern/repl/ subcommand. (The same effect can be
obtained by omitting the /pattern/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 subcommand, not necessarily the one used in the last substitute
subcommand. For example, in the following sequence, the ~ (tilde) is
equivalent to s/green/blue/:
s/red/blue/
/green
~
[line] = [flags]
Writes the line number of the specified line (the default is the last
line). The current line position is not affected.
<Ctrl-d>
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 written.
@ buffer
* buffer
Executes each line of the named buffer as an ex subcommand. 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
<Return>
Displays next line
Subcommand Addresses
$ The last line
+ The next line
- The previous line
+n The nth line forward
-n The nth previous line
% The first through last lines
number
Line number
. The current line
x-number
The numberth line before line x
x,y Lines x through y
'm The line marked with m
'' The previous context
/pattern$
The next line with pattern at end of line
/^pattern
The next line with pattern at start of line
/pattern
The next line with pattern
?pattern
The previous line with pattern
Scanning Pattern Formation
^ The beginning of the line
$ The end of the line
. Any character
\< The beginning of the word
\> The end of the word
[string]
Any character in string
[^string]
Any character not in string
[x-y]
Any character between x and y, inclusive
* Any number of the preceding character
~ The replacement part of the last substitute subcommand.
\(pattern\)
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 .exrc 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
.exrc file each time you invoke it. Here is an example of an .exrc file:
set ai aw
set wm=5
Users with both an .exrc file and an EXINIT environment variable will find
that the ex editor no longer reads the .exrc 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 .exrc 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 .exrc file if its mode grants
write permission to anyone other than the owner; this restriction prevents
certain security breaches. No overt indication is given when such a refusal
occurs.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ASYNCHRONOUS EVENTS
The following actions are taken upon receipt of signals:
SIGINT
When an interrupt 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 editor option.)
SIGCONT
The screen is refreshed if in visual mode.
SIGHUP
If the current 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:
COLUMNS
Overrides the system-selected horizontal screen size.
EXINIT
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.
HOME
Determines the path name of a directory searched at startup for a file
named .exrc.
LANG
Provides a default value for the internationalization variables that
are unset or null. If LANG is unset or null, the corresponding value
from the default locale is used. If any of the internationalization
variables contain an invalid setting, the utility behaves as if none of
the variables had been defined.
LC_ALL
If set to a non-empty string value, overrides the values of all the
other internationalization variables.
LC_COLLATE
Determines the locale for the behavior of ranges, equivalence classes,
and multicharacter collating elements within regular expressions.
LC_CTYPE
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 classification of
characters as upper- or lower-case letters, the case conversion of
letters, and the detection of word boundaries.
LINES
Overrides the system-selected vertical screen size, used as the number
of lines in a screenful and the vertical screen size in visual mode.
LC_MESSAGES
Determines the locale for the format and contents of diagnostic
messages written to standard error.
NLSPATH
Determines the location of message catalogues for the processing of
LC_MESSAGES.
PATH
Determines the search path for the shell command specified in the
editor commands shell, read and write and the visual-mode command !.
SHELL
Determines the preferred command line interpreter 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 sh command will be used.
TERM
Determines the name of the terminal type. If this variable is unset or
null, a default terminal type that provides most capabilities is used.
FILES
/usr/lbin/exrecover
recover subcommand
/usr/lbin/expreserve
preserve subcommand
/usr/share/lib/terminfo/?/*
Terminal information database
./.exrc or $HOME/.exrc
Editor startup file
/tmp/Exnnnnn
Editor temporary file
/tmp/Rxnnnnn
Names buffer temporary file
/var/preserve
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)
 |
Index for Section 1 |
|
 |
Alphabetical listing for E |
|
 |
Top of page |
|