ex(1) ex(1)
NAME [Toc] [Back]
ex, edit - extended line-oriented text editor
SYNOPSIS [Toc] [Back]
ex [-] [-l] [-r] [-R] [-t tag] [-v] [-wsize] [-x] [-C] [+command]
[file ...]
XPG4 Synopsis [Toc] [Back]
ex [-rR] [-s | -v] [-c command] [-t tag] [-w size] [file ...]
Obsolescent Options [Toc] [Back]
ex [-rR] [-| -v] [+command] [-t tag] [-w size] [file ...]
edit [-] [-l] [-r] [-R] [-t tag] [-v] [-wsize] [-x] [-C] [+command]
[file ...]
Remarks [Toc] [Back]
The program names ex, edit, vi, view, and vedit are separate
personalities of the same program. This manual entry describes the
behavior of the ex/edit personality. On many HP-UX and other similar
systems, e is a synonym for ex.
DESCRIPTION [Toc] [Back]
The ex program is the line-oriented personality of a text editor that
also supports screen-oriented editing (see vi(1)).
(XPG4 only.) Certain block-mode terminals do not have all the
capabilities necessary to support the complete ex definition, such as
the full-screen editing commands (visual mode or open mode). When
these commands cannot be supported on such terminals, this condition
shall neither produce an error message such as "not an editor command"
nor report a syntax error.
The edit program is identical to ex, except that some editor option
defaults are altered to make the editor somewhat friendlier for
beginning and casual users (see Editor Options below).
Options and Arguments [Toc] [Back]
ex recognizes the following command-line options and arguments:
- (Obsolescent) Suppress all interactive-user feedback.
This is useful when editor commands are taken from
scripts.
-s (XPG4 only.)
Suppress all interactive-user feedback. This is useful
when editor commands are taken from scripts.
Ignore the value of the TERM and any implementation
terminal type and assume the terminal is a type incapable
Hewlett-Packard Company - 1 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
of supporting visual mode.
Suppress the use of the EXINIT environment variable and
the reading of the .exrc file.
-l Set the lisp editor option (see Editor Options below).
-r Recover the specified files after an editor or system
crash. If no file is specified, a list of all saved files
is printed. You must be the owner of the saved file in
order to recover it (superuser cannot recover files owned
by other users).
-R Set the readonly editor option to prevent overwriting a
file inadvertently (see Editor Options below).
-t tag (XPG4 only.) Edit the file containing the specified tag
and proceed as if the first command were :tag tag. The
tags represented by the -t tag and the ta command is
optional. It shall be provided on any system that also
provides a confirming implementation of ctags, Otherwise,
the use of the -t produces undefined results.
Execute the tag tag command to load and position a
predefined file. See the tag command in Command
Descriptions and the tags editor option in Editor Options
below.
-v Invoke visual mode (vi).
-w size Set the value of the window editor option to size (see
Editor Options below). If size is omitted, it defaults to
3.
-x Set encryption mode. You are prompted for a key to
initiate the creation or editing of an encrypted file (see
the crypt command in Command Descriptions below).
-C Encryption option. Same as the -x option, except that all
text read in is assumed to have been encrypted.
-c command (XPG4 only.)
+command (Obsolescent) Begin editing by executing the specified ex
search or positioning command.
file Specify the file or files to be edited. If more than one
file is specified, they are processed in the order given.
If the -r option is also specified, the files are read
from the recovery area.
Hewlett-Packard Company - 2 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
(XPG4 only.) If both the -t tag and -c command options are given, the
-t tag shall be processed first;i.e, the file containing the tag is
selected by the -t and then the command is executed.
Definitions [Toc] [Back]
Current file. The name of the file being edited by ex is called the
current file. Text from the current file is read into a work area,
and all editing changes are performed on this work area. Changes do
not affect the original file until the work area is explicitly written
back to the file. If the % character is used as a file name, it is
replaced by the current file name.
Alternate file. The alternate file is the name of the last file
mentioned in an editor command, or the previous current file name if
the last file mentioned becomes the current file. If the # character
is used as a file name, it is replaced by the alternate file name.
Buffers. Twenty-six buffers named a through z can be used for saving
blocks of text during the edit. If the buffer name is specified in
uppercase, text is appended to the existing buffer contents rather
than overwriting it.
Readonly flag. The readonly flag can be cleared from within the
editor by setting the noreadonly editor option (see Editor Options
below). Writing to a different file is allowed even when the readonly
flag is set. Also, a write can be forced to a readonly file by using
! after the write command (see the write command in Command
Descriptions below).
Interrupt. If an interrupt signal is received, and commands are being
supplied from a keyboard, ex returns to command mode. If editor
commands are coming from a file, an interrupt signal causes ex to
abort.
System crash. If the system crashes or ex aborts due to an internal
error or unexpected signal, ex attempts to preserve the work area if
any unwritten changes were made. Use the -r command-line option to
retrieve the saved changes.
Command mode/input mode. ex starts up in command mode, as indicated
by the colon (:) prompt. ex switches to input mode whenever an
append, change, or insert command is encountered. To terminate input
mode and return to command mode, type a period (.) alone at the
beginning of a line.
Comments. Command lines beginning with a quotation mark (") are
ignored (this is useful for placing comments in an editor script).
Multiple commands can be combined on a single line by separating them
with a vertical bar character (|). However, global commands,
comments, and the shell escape command must be the last command on a
Hewlett-Packard Company - 3 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
line because they cannot be terminated by a | character.
Addressing [Toc] [Back]
(XPG4 only.) Addressing in ex relates to the current line. In general,
the current line shall be the last line affected by the command; the
exact effect on the current line is discussed under the description of
each command. When the buffer contains no lines, the current line
shall be set to zero.
ex recognizes the following line address forms:
. Dot or period (.) refers to the current line.
There is always a current line whose position can
be the result of an explicit movement command or
the result of a command that affects multiple
lines (in which case it is usually the last line
affected).
n The nth line in the work area. Lines are numbered
sequentially, starting at line 1.
$ The last line in the work area.
% Abbreviation for 1,$, meaning the entire work
area.
+n, +[+]...
-n, -[-]... An offset relative to the current line or the
preceding line specification. + means forward; -
means backward. For example, the forms .+3, +3,
and +++ are equivalent.
/re/ The line containing the pattern re, scanning
?re? forward (/) or backward (?). The trailing / or ?
can be omitted if the line is only being
displayed. If re is omitted, ex uses the more
recently set of either the scanning string or the
substitution string (see Regular Expressions
below).
'x Lines can be marked using single lowercase letters
(see the mark command in Command Descriptions
below). 'x refers to the line marked with x. In
addition, the previous current line is marked
before each nonrelative motion. This line can be
referred to by using ' for x (thus '' refers to
the previous current line).
(XPG4 only.) Commands require zero, one or two
addresses. Commands that require zero addresses
shall regard the presence of an address as an
Hewlett-Packard Company - 4 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
error.
(XPG4 only.) Adjacent address in a range shall be separated from each
other by a comma (,) or a semicolon(;). In the latter case, the
current line(.) shall be set to the first address, and only then is
the second address calculated. This feature can be ued to determine
the starting line for forwards and backwards searches. The second
address of any two-address sequence shall correspond to the first
address. The first address shall be less than or equal to the second
address. The first address shall be greater than or equal to the first
line of the editing buffer, and the last address shall be less than or
equal to the last line of the editing buffer. Any other case shall be
an error.
Addresses for commands consist of a series of line addresses
(specified as above), separated by a comma (,) or semicolon (;). Such
address lists are evaluated left-to-right. When the separator is a
semicolon, the current line is set to the value of the previous
address before the next address is interpreted. If more addresses are
given than the command requires, then all but the last one or two are
ignored. Where a command requires two addresses, the first line
addressed must precede the second one in the work area. A null
(missing) address in a list defaults to the current line.
Regular Expression [Toc] [Back]
The editor maintains copies of two regular expression strings at all
times: the substitution string, and the scanning string. The
substitute command sets the substitution string to the regular
expression used. Both the global-command and the regular-expression
form of line addressing (see Addressing above) for all commands set
the scanning string to the regular expression used. These strings are
used as default regular expressions as described under Addressing, the
global command, and the substitute command.
The editor supports Basic Regular Expressions (see regexp(5)) with the
following modifications:
\< The \< matches the beginning of a "word"; that is,
the matched string must begin in a letter, digit, or
underline, and must be preceded by the beginning of
the line or a character other than the above. This
construct can only be used at the beginning of a
regular expression (as in \<word), but not in the
middle (word1 \<word2).
\> The \> matches the end of a "word" (see previous
paragraph). This construct can only be used at the
end of a regular expression (as in word\>), but not
in the middle (word1\> word2).
Hewlett-Packard Company - 5 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
~ Match the replacement part of the last substitute
command.
[string] The positional quoting within bracket expressions
defined by Basic Regular Expressions is replaced by
the use of the backslash (\) to quote bracketexpression
special characters.
nomagic When the editor option nomagic is set, the only
characters with special meanings are ^ at the
beginning of a pattern, $ at the end of a pattern,
and \. The characters ., *, [, and ~ lose their
special meanings unless escaped by a \.
Replacement Strings [Toc] [Back]
The character & in the replacement string stands for the text matched
by the pattern to be replaced. Use \& if the nomagic editor option is
set.
The character ~ is replaced by the replacement part of the previous
substitute command. Use \~ if the nomagic editor option is set.
The sequence \n, where n is an integer, is replaced by the text
matched by the subpattern enclosed in the nth set of parentheses \(
and \).
The sequence \u (\l) causes the immediately following character in the
replacement to be converted to uppercase (lowercase), if the character
is a letter. The sequence \U (\L) turns case conversion on, until the
sequence \E or \e is encountered, or the end of the replacement string
is reached.
Hewlett-Packard Company - 6 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
Command Names and Abbreviations [Toc] [Back]
The following table summarizes the line-mode commands. The commands
whose names are enclosed in parentheses are available only in their
abbreviated forms.
________________________________________________________________________
|Command Abbr. | Command Abbr. | Command Abbr. |
|____________________|_______________________|__________________________|
|abbreviate ab | next n | tag ta |
|append a | number nu # | unabbreviate una |
|args ar | open o | undo u |
|change c | pop | unmap unm |
|chdir chd cd | preserve pre | version ve |
|____________________|_______________________|__________________________|
|copy co t | print p | visual vi |
|crypt cr X | put pu | write w wq |
|delete d | quit q | xit x |
|edit e ex | read r | yank ya |
|file f | recover rec | |
|____________________|_______________________|__________________________|
|global g v | rewind rew | (execute buffer) * @ |
|insert i | set se | (line number) = |
|join j | shell sh | (left shift) < |
|list l | source so | (right shift) > |
|map | stop st ^Z | (scroll) ^D |
|____________________|_______________________|__________________________|
|mark ma k | substitute s sr & ~ | (shell escape) ! |
|move m | suspend su ^Z | (window) z |
|____________________|_______________________|__________________________|
Command Descriptions [Toc] [Back]
In the following command descriptions, some arguments appear
frequently. They are described below.
line A single line address, in any of the forms described in
Addressing above. The default is the current line.
range A pair of line addresses separated by a comma or
semicolon, as described in Addressing above. The
default is the current line (.,.).
count A positive integer specifying the number of lines to be
affected by the command. The default is 1 or the
number of lines in range.
When count is specified, range is ineffective.
Instead, only a line number should be specified to
indicate the first line affected by the command. (If a
range is given, the last line of the range is
interpreted as the starting line for the command.)
Hewlett-Packard Company - 7 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
flags One or more of the characters #, p, and l. The
corresponding command to print the line is executed
after the command completes. Any number of + or -
characters can also be given with these flags. The
default is no flags.
These modifiers are all optional.
When only a line or a range is specified (with a null command), the
implied command is print. If a null line is entered, the next line is
printed (equivalent to .+1p)
buffer XPG4 Feature. One of a number of named areas for
saving text. The named buffers are specified by the
lowercase letters of the POSIX locale. Specifying
buffer shall cause the area of the text affected by the
command to be stored into the buffer as it was before
the command took effect. This argument is also used on
the put command and the visual mode "put" commands (p
and P), to specify the buffer that shall provide the
text to insert.
If the buffer name is specified in uppercase, and the
buffer is to be modified, the buffer shall be appended
to rather than being overwritten. If the buffer is not
to be modified, the buffer name can be specified in
lowercase or uppercase with the same results. There
shall be also one unnamed buffer, which is the
repository for all text deleteed or yanked when no
buffer is specified.
There are also numbered buffers, 1 through 9, which
shall be accessible only from visual mode. These
buffers are special in that, in the visual mode, when
deleted text is placed in the unnamed buffer, it also
shall be placed in buffer 1, the previous contents
buffer 1 shall be placed in buffer 2 and so on. Any
text in the buffer 9 shall be lost. Text that is yanked
into the unnamed buffer shall not modify the numbered
buffers. Text cannot be placed directly into the
numbered buffered, although it can be retrieved from
them by using a visual mode "put" command with the
buffer name given as s number. When the buffer modifier
is not used in the commands below, the unnamed buffer
shall be the default.
word XPG4 Feature. 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 word or the file. ! A character that can be
Hewlett-Packard Company - 8 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
appended to the command to modify its operation, as
detailed in the individual command descriptions.
If both a count and range is specified for a command
that uses them, the number of lines affected shall be
taken from the count value rather than the range. The
starting line for the command shall be taken to be the
first line addressed by the range.
When only a line or range is specified with no command,
the implied command shall be either print, list, or
number ( p, l, or #). The command selected shall be
the last of these three commands to be used. When no
range or count is specified and the command line is a
blank line, the current line shall be written, and the
current line shall be set to .+1.
Zero or mode <blank> characters can precede or follow
the addresses, count or command name. Any object
following a command name (such as buffer, file etc)
that begins with an alphabetic character shall be
separated from the command name with at least one
<blank>.
For each of the commands listed below, the command can be entered as
the abbreviation (those characters in the Synopsis command word
preceding the [), the full command (all characters shown for the
command word, omitting the [ and ]), or any subset of the characters
of the full command down to the abbreviation.
abbreviate ab[breviate] word replacement
Add the named abbreviation to the current list. In
visual mode, if word is typed as a complete word
during input, it is replaced by the string
replacement.
append line a[ppend][!]
Enter input mode; the input text is placed after the
specified line. If line 0 is specified, the text is
placed at the beginning of the work area. The last
input line becomes the current line, or the target
line if no lines are input.
Appending ! to the command toggles the autoindent
editor option setting for this insert only.
args ar[gs]
Hewlett-Packard Company - 9 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
Prints the argument, placing the current argument
between [ and ].
change range c[hange][!] count
Enter input mode; the input text replaces the
specified lines. The last input line becomes the
current line; if no lines are input, the effect is
the same as a delete.
Appending ! to the command toggles the autoindent
editor option setting for this insert only.
chdir chd[ir][!] [directory]
cd[!] [ directory]
Change the working directory to directory. If
directory is omitted, the value of the HOME
environment variable is used. If the work area has
been modified since the last write and the name of
the file being edited does not begin with a slash
(/), a warning is issued and the working directory
is not changed. To force a change of directory in
this case, append the character ! to the command.
copy range co[py] line flags
range t line flags
A copy of the specified lines (range) is placed
after the specified destination line; line 0
specifies that the lines are to be placed at the
beginning of the work area. (The letter t is an
alternative abbreviation for the copy command.)
crypt cr[ypt]
X
The user is prompted for a key with which to enter
encryption mode. This command can also be used to
change the key entered from a previous crypt command
or the -x command line option. If no key is
supplied in response to the prompt (that is, only
carriage return is pressed), encryption mode is
canceled and the work area is written out in plaintext
form by subsequent write commands.
While in encryption mode, all file input is
decrypted using the current key. However, while an
input file is being processed, if a block of text
(approximately 1024 bytes) is encountered that
contains only 7-bit ASCII characters, that block of
Hewlett-Packard Company - 10 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
text is assumed to be plain-text and is not
decrypted. All file output, except that piped via a
! shell escape to another command, is encrypted
using the current key.
The temporary file used by the editor to manage the
work area is not encrypted until the current work
area is discarded (or written out) and editing
begins on a new file. When creating a new file that
requires encryption protection, ensure that the work
area file is also encrypted by specifying the -x
option when invoking the editor.
cr[ypt]
C
Encryption option. Same as the X command, except
that all text read in is assumed to have been
encrypted.
delete range d[elete] buffer count
The specified lines are deleted from the work area.
If a named buffer is specified, the deleted text is
saved in it. If no buffer is specified, the unnamed
buffer is used (that is, the buffer where the most
recently deleted or yanked text is placed by
default). The new current line is the line after
the deleted lines or the last line of the file if
the deleted lines were at the end of the file.
edit e[dit][!] [+ line] file
ex[!] [+ line] file
Begin editing a new file (ex is an alternative name
for the edit command). If the current work area has
been modified since the last write, a warning is
printed and the command is aborted. This action can
be overridden by appending the character ! to the
command (e! file). The current line is the last
line of the work area unless it is executed from
within vi, in which case the current line is the
first line of the work area. If the +line option is
specified, the current line is set to the specified
position, where line can be a number (or $) or
specified as /re or ?re.
file f[ile]
Print the current file name and other information,
including the number of lines and the current
Hewlett-Packard Company - 11 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
position.
global range g[lobal][!] /re/ command...
range v /re/ command...
Perform command on lines within range (or on the
entire work area if no range is given) that contain
re. First mark the lines within the given range
that match the pattern re. If the pattern is
omitted, the more recently set of either the
substitution string or the scanning string is used
(see Regular Expressions above). Then the given
commands are executed with . set to each marked
line. Any character other than a letter or a digit
can be used to delimit the pattern instead of the /.
command can be specified on multiple lines by hiding
new-lines with a backslash. If command is omitted,
each line is printed. append, change, and insert
commands are allowed; the terminating dot can be
omitted if it ends command or commands. The visual
command is also permitted (unless the global command
itself has been issued from visual mode), and takes
input from the terminal. (If command contains a
visual-mode command (that is, open or visual), the
visual-mode command must be terminated by the
visual-mode Q command in order to proceed to the
next marked line.)
The global command itself and the undo command are
not allowed in command. The editor options
autoprint, autoindent, and report are inhibited.
Appending a ! to the global command (that is,
g! ...) or using the alternate name v causes command
to be run on the lines within range that do not
match the pattern.
insert line i[nsert][!]
Enter input mode; the input text is placed before
the specified line. The last line input becomes the
current line, or the line before the target line, if
no lines are input.
Appending ! to the command toggles the autoindent
editor option setting for this insert only.
join range j[oin][!] count flags
Hewlett-Packard Company - 12 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
Join together the text from the specified lines into
one line. White space is adjusted to provide at
least one blank character (two if a period appears
at the end of a line, or none if the first character
of a line is a closing parenthesis ())). Extra
white space at the beginning of a line is discarded.
Appending a ! to the command causes a simpler join
with no white-space processing.
list range l[ist] ount flags
Print the specified lines with tabs displayed as ^I
and the end of each line marked with a trailing $.
(The only useful flag is # for line numbers.) The
last line printed becomes the current line.
map map key|#n action
map! key|#n action
The map and map! commands define macros for use in
visual mode. The first argument, key, can be a
single character or a multicharacter sequence. In
the special sequence, #n, n is a digit referring to
the function key n. Special characters, whitespace,
and newline must be escaped with a ^V to be entered
in the arguments. The key argument cannot contain a
colon (:) as its first character, nor can a
multicharacter sequence begin with an alphabetic
character.
Macros defined by map are effective in visual
command mode. Macros defined by map! are effective
in visual input mode. When key or the function key
corresponding to #n is entered, the editor
interprets the operation as though action were
typed.
The map or map! command without options displays the
corresponding current list of macros.
See also the editor options keyboardedit,
keyboardedit!, timeout, and timeoutlen in Editor
Options below.
mark line ma[rk] x
line k x
The specified line is given the specified mark x,
which must be a single lowercase letter (a-z). x
must be preceded by a space or tab. The current
Hewlett-Packard Company - 13 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
line position is not affected. k is an alternate
name for mark.
move range m[ove] line
Move the specified lines (range) to follow the
target line. The first line moved becomes the
current line.
next n[ext][!] [ file ...]
The next file from the command line argument list is
edited. Appending a ! to the command overrides the
warning about the work area having been modified
since the last write (and discards any changes
unless the autowrite editor option is set). The
argument list can be replaced by specifying a new
one on this command line.
number range nu[mber] count flags
range # count flags
(The # character is an alternative abbreviation for
the number command.) Print the lines, each preceded
by its line number (the only useful flag is l). The
last line printed becomes the current line.
open line o[pen] /re/ flags
Enter open mode, which is similar to visual mode
with a one-line window. All the visual-mode
commands are available. If a match is found in line
for the optional regular expression, the cursor is
placed at the start of the matching pattern. Use
the visual mode command Q to exit from open mode.
For more information, see vi(1).
pop pop[!]
Load the file whose name is stored at the top of the
tag stack and set the current line to the stored
location. The top entry of the tag stack is
deleted. (The current file name is placed on the
stack when you execute the line mode tag command or
the visual mode ^] command.)
! overrides the warning about the work area having
been modified since the last write; any changes are
discarded unless the autowrite editor option is
set).
Hewlett-Packard Company - 14 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
preserve pre[serve]
The current editor work area is saved as if the
system had just crashed. Use this command in
emergencies, for example when a write does not work
and the work area cannot be saved in any other way.
Use the -r command-line option to recover the file.
After the file has been preserved, a mail message
shall be sent to the user. The message shall contain
the name of the file, the time of preservation and
an ex command that could be used to recover the
file. Additional information may be included in the
mail message.
print range p[rint] count
Print the specified lines, with non-printing
characters printed as control characters in the form
^x; DEL is represented as ^?. The last line printed
becomes the current line.
put line pu[t] buffer
Place deleted or "yanked" lines after line. A
buffer can be specified; otherwise, the text in the
unnamed buffer (that is, the buffer in which deleted
or yanked text is placed by default) is restored.
The current line indicator shall be set to the first
line put back.
quit q[uit][!]
Terminate the edit. If the work area has been
modified since the last write, a warning is printed
and the command fails. To force termination without
preserving changes, append ! to the command.
read line r[ead] file
Place a copy of the specified file in the work area
after the target line (which can be line 0 to place
text at the beginning). If no file is named, the
current file is the default. If no current file
exists, file becomes the current file. The last
line read becomes the current line except in visual
mode where the first line read becomes the current
line.
If file is given as !string, string is interpreted
as a system command and passed to the command
interpreter; the resultant output is read into the
Hewlett-Packard Company - 15 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
work area. A blank or tab must precede the !.
recover rec[over][!] file
Recover file from the save area, after an accidental
hangup or a system crash. If the current work area
has been modified since the last write, a warning is
printed and the command is aborted. This action can
be overridden by appending the character ! to the
command (rec! file).
rewind rew[ind][!]
The argument list is rewound, and the first file in
the list is edited. This shall be equivalent to a
next command with the current argument list as its
operands. If the current buffer has been modified
since the last write, a warning shall be written and
the command shall be aborted. Any warnings can be
overridden by appending a !. The current indicator
line shall be affected by the editor options,
autowrite and writeany.
set se[t] [all]
se[t] [no]boolean-option?
se[t] value-option[?]
se[t] boolean-option
se[t] noboolean-option
se[t] value-option=value
Set and display the values of the editor options
(see Editor Options below).
With no arguments, the command prints those editor
options whose values have been changed from the
default settings. If all is specified, it prints
all current option values.
The second and third forms display the current value
of the specified option. The ? is necessary only
for Boolean options.
The fourth form turns a Boolean option on. The
fifth form turns a Boolean option off.
The sixth form assigns values to string and numeric
options. Spaces and tabs in strings must be escaped
with a leading backslash (\).
The last five forms can be combined; interpretation
is left-to-right.
Hewlett-Packard Company - 16 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
shell sh[ell]
Execute the command interpreter specified by the
shell editor option (see Editor Options below).
Editing is resumed when you exit from the command
interpreter.
source so[urce] file
Read and execute commands from the specified file.
so commands can be nested. The maximum supported
nesting depths is implementation defined, but shall
be at least one.
substitute range s[ubstitute] /re/repl/ options count flags
range s options count flags
range & options count flags
range sr options count flags
range ~ options count flags
range s\?repl
range s\&repl
On each specified line, the first instance of the
pattern re is replaced by the string repl. (See
Regular Expressions and Replacement Strings above.)
Any character other than a letter or a digit can be
used to delimit the pattern instead of the /.
If you include the g (global) option, all instances
of the pattern in the line are substituted.
If you include the c (confirm) option, you are
queried about whether to perform each individual
substitution, as follows: Before each substitution
the line is displayed with the pattern to be
replaced marked underneath with carets (^). Type y
to cause the substitution to be performed; any other
input to abort it. The last line substituted
becomes the current line.
If the substitution pattern re is omitted
(s//repl/), the more recently set of either the
substitution string or the scanning string is used
(see Regular Expressions above).
If the s or & forms of the command are used, the
substitution pattern defaults to the previous
substitution string and the replacement string
defaults to the previous replacement string used.
Hewlett-Packard Company - 17 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
If the sr or ~ forms of the command are used, the
substitution pattern defaults to the more recently
set of either the substitution string or the
scanning string and the replacement string defaults
to the previous replacement string used.
The form s\?repl is equivalent to s/scan-re/repl/,
where scan-re is the previous scanning string.
The form s\&repl is equivalent to s/subs-re/repl/,
where subs-re is the previous substitution string.
suspend su[spend][!]
stop st[op][!]
susp
Suspend the editor job and return to the calling
shell. stop and susp are equivalent to suspend.
susp is the user process control suspend character,
which is typically the character ^Z (ASCII SUB) (see
stty(1)). This command is disabled if the calling
shell does not support job control or has disabled
it.
The work area is written to the current file before
the editor is suspended if the autowrite editor
option is set, the readonly editor option is not
set, and the work area has been modified since the
last write. To override this action, append the !
character to the suspend or stop command.
tag ta[g][!] tag
Search the files specified by the tags editor option
(see Editor Options below) sequentially until a tag
definition for tag is found. If tag is found, load
the associated file into the work area and set the
current position to the address specified in the tag
definition.
The work area is written to the current file before
the new file is loaded if the new file is different
from the current file, the autowrite editor option
is set, the readonly editor option is not set, and
the work area has been modified since the last
write. To override this action, append the !
character to the command.
If the tagstack editor option is set, the current
file name and line number is pushed onto the tag
stack for later recall with the line mode pop
Hewlett-Packard Company - 18 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
command or the visual mode ^] command.
unabbreviate una[bbreviate] word
Delete word from the list of abbreviations (see the
abbreviate command above).
undo u[ndo]
Reverse the changes made by the previous editing
command. For this purpose, global and visual are
considered single commands. Commands that affect
the external environment, such as write, edit, and
next, cannot be undone. An undo can itself be
reversed.
unmap unm[ap][!] key
The macro definition for key is removed (see the map
command above).
version ve[rsion]
Print the current version information for the
editor.
visual line vi[sual] type count flags
Enter visual mode at the specified line.
The type can be one of the characters +, -, ., or ^,
as in the z (window) command, 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.
A count specifies an initial window size; the
default is the value of the editor option window.
The flags # and l (ell) cause the lines in the
visual window to be displayed in the corresponding
mode (see the number and list commands).
Use the Q command to exit visual mode. For more
information, see vi(1).
write [range] w[rite][!][>>] file
[range] wq[!][>>] file
Write the specified lines (or the entire work area,
if no range is given) out to file, printing the
Hewlett-Packard Company - 19 - HP-UX 11i Version 2: August 2003
ex(1) ex(1)
number of lines and characters written. If file is
not specified, the default is the current file (the
command fails with an error message if there is no
current file and no file is specified).
If an alternate file is specified and the file
exists, the write fails, but can be forced by
appending ! to the command. To append to an
existing file, append >> to the command. If the
file does not exist, an error is reported.
If the file is specified as !string, string is
interpreted as a system command, the command
interpreter is invoked, and the specified lines are
passed as standard input to the command.
The command wq is equivalent to a w followed by a q.
wq! is equivale
|