ex(1)
NAME
ex, edit − extended line-oriented text editor
SYNOPSIS
ex [-] [-v] [-r] [-R] [-+command] [-l] [-ttag] [-V] [-wsize] [-x] [file ...]
edit [-] [-v] [-r] [-R] [-+command] [-l] [-ttag] [-V] [-wsize] [-x] [file ...]
Remarks:
ex, edit, vedit, vi, and view are separate personalities of the same program. This manual entry describes the behavior of the ex personality. The edit personality is very similar to ex except that some of the editor configuration options have different defaults. On many HP-UX and other similar systems, the e and ex commands are synonymous.
DESCRIPTION
ex is a line-oriented text editor that supports both command and display editing (see vi(1)).
edit is identical to ex, except that the following configuration option defaults are altered to make the editor somewhat friendlier for beginning and casual users: report=1, novice, showmode, and report=1 (see Edit Options later in this entry).
The following command-line options are recognized:
- Suppress all interactive-user feedback. This is useful when editor commands are taken from scripts.
-v Invoke vi.
-r Recover file or files after an editor or system crash. If no file is specified a list of all saved files is printed.
-R Set "read-only" mode to prevent overwriting a file inadvertently.
+command Begin editing by executing the specified editor search or positioning command.
-l Lisp mode; indents appropriately for Lisp program source code; the () {} [[ and ]] commands in vi are modified to be meaningful for Lisp.
-t tag Edit the file containing tag, and position the editor at its definition (see the tag command below and ctags(1)).
-V Verbose mode; editor commands are displayed as they are executed when input from a user’s .exrc file or a source file (see the source command below).
-w size Set the value of the window editor option to size.
-x Encryption mode; the user is prompted for a key to initiate creation or editing of an encrypted file (see the crypt command below).
file specifies the file or files to be edited. If more than one file is specified, they are processed in the order given.
The name of the file being edited by ex is called the current file. Text from the current file is read into a buffer, and all editing changes are performed on this buffer. Changes do not affect the original file until the buffer is explicitly written back to the 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 current file name. Similarly, the # character is replaced by the alternate file name.
Twenty-six buffers named ASCII 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.
The read-only mode can be cleared from within the editor by setting the noreadonly edit option (see Edit Options below). Writing to a different file is allowed in read-only mode. Also, a write can be forced to a read-only file by using ! after the write command (see the write command below).
If an interrupt signal is received, and commands are being supplied from a keyboard, ex returns to the command level. If editor commands are coming from a file, an interrupt signal causes ex to abort.
If the system crashes or ex aborts due to an internal error or unexpected signal, ex attempts to preserve the buffer if any unwritten changes were made. Use the -r command-line option to retrieve the saved changes.
ex starts up in command mode, as indicated by the colon (:) prompt. ex switches to input mode whenever an append, insert, or change command is encountered. To terminate input mode and return to command mode, type a period (.) alone at the beginning of a line.
Command lines beginning with the double quote character (") 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 line because they cannot be terminated by a | character.
Addressing
ex recognizes the following line address forms:
. Dot (.) refers to the current line. There is always a current line whose position might be the result of an explicit movement by the user or the result of a command that affected multiple lines (in which case it is usually the last line affected).
n The nth line in the buffer. Lines are numbered sequentially, starting at line 1.
$ The last line in the buffer.
% Abbreviation for 1,$, meaning the entire buffer.
+n
-n
An offset relative to the current line. (For example, the forms .+3, +3, and +++ are equivalent.)
/re/
?re?
Line containing the pattern re, scanning forward (/ re /) or backward (? re ?). The trailing / or ? can be omitted if the line is only being printed. If re is omitted, ex uses the more recently set of either the substitution string or scanning string (see Regular Expressions below).
’x Lines can be marked using single ASCII lowercase letters (see the mark command below); ’x refers to line marked x. In addition, the previous current line is marked before each non-relative motion. This line can be referred to by using ’ for x (thus ” refers to the previous current line).
Addresses for commands consist of a series of line addresses (specified as above), separated by 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 buffer. A null (missing) address in a list defaults to the current line.
Command Names and Abbreviations
The command names enclosed within parenthesis in the table below are available only in their abbreviated forms.
| Command | Abbr. | Command | Abbr. | Command | Abbr. |
| abbreviate | ab | open | o | unabbreviate | una |
| append | a | next | n | undo | u |
| args | ar | number | # nu | unmap | unm |
| change | c | preserve | pre | version | ve |
| chdir | chd cd | p | visual | vi | |
| copy | co t | put | pu | write | w |
| crypt | cr X | quit | q | xit | x |
| delete | d | read | r | yank | ya |
| edit | e ex | recover | rec | (window) | z |
| file | f | rewind | rew | (escape) | ! |
| global | g v | set | se | (lshift) | < |
| insert | i | shell | sh | (rshift) | > |
| join | j | source | so | (scroll) | ^D |
| list | l | stop | st ^Z | (line number) | = |
| map | substitute | s & ~ | (execute buffer) | * @ | |
| mark | k ma | suspend | su ^Z | ||
| move | m | tag | ta |
Command Descriptions
In the following, line is a single-line address, given in any of the forms described in the Addressing section above. range is a pair of line addresses separated by a comma or semicolon (Addressing explains the difference between the two). count is a positive integer specifying the number of lines to be affected by the command. flags is 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.
When count is used, 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.)
These modifiers are all optional. Defaults are as follows, unless otherwise stated: the default for line is the current line; the default for range is the current line only (.,.); the default for count is 1; the default for flags is null.
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)
abbreviate ab[breviate] word rhs
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 rhs (right-hand string).
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 buffer. The last input line becomes the current line, or the target line if no lines are input.
Appending ! to the command toggles the autoindent edit option setting for this insert only.
args ar[gs]
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 edit 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 buffer 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 buffer. (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 Return is pressed), encryption mode is canceled and the buffer is written out in plain-text 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 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 buffer is not encrypted until the current buffer is discarded (or written out) and editing begins on a new file. When creating a new file that requires encryption protection, ensure that the buffer file is also encrypted by specifying the -x option when invoking the editor.
delete range d[elete] buffer count
The specified lines are deleted from the buffer. 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 buffer 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 buffer unless it is executed from within vi, in which case the current line is the first line of the buffer. 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 position.
global range g[lobal][!] /re/ command ...
range v /re/ command ...
Perform command on lines within range (or on the entire buffer 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 below). Then the given command or 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. Edit 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 edit option setting for this insert only.
join range j[oin][!] count flags
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[!] [x| # n] rhs
The map command is used to define macros for use in visual mode. The first argument, x, can be a single character or a multi-character sequence. In the special sequence, #n, n is a digit referring to the function key n. When x or the function key corresponding to #n is typed in visual mode, map interprets the action as though rhs were typed. If ! is appended to the command map, the mapping is effective during input mode rather than command mode. Special characters, white space, and new-line must be escaped with a ^V to be entered in the arguments. The first argument cannot contain the colon (:) as the first character, nor can multicharacter sequences begin with an alphabetic character. See also the Edit Options timeout, timeoutlen, keyboardedit, and keyboardedit! below.
mark line ma[rk] x
line k x
(The letter k is an alternative abbreviation for the mark command.) The specified line is given the specified mark x, which must be a single ASCII lowercase letter (a-z) (x must be preceded by a space or tab). The current line position is not affected.
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 buffer having been modified since the last write (and discards any changes unless the autowrite edit 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 for the optional regular expression in line, the cursor is placed at the start of the matching pattern. The visual mode command Q exits open mode. For more information, see vi(1).
preserve pre[serve]
The current editor buffer is saved as if the system had just crashed. This command is used in emergencies, for example when a write does not work and the buffer cannot be saved in any other way.
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.
quit q[uit][!]
Terminate the edit. If the buffer 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 buffer 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 buffer. 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 buffer 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. Any warnings can be overridden by appending a !.
set se[t] [?][all] parameter
With no arguments, the set command prints those editor configuration options whose values have been changed from the default settings; if all is specified, it prints all current configuration option values.
Giving an option name followed by a ? causes the current value of that option to be printed. The ? is necessary only for Boolean-valued options. Boolean options are given values by the form se option to turn them on, or se nooption to turn them off; string and numeric options are assigned by the form se option=value. More than one parameter can be given; interpretation is left-to-right.
See Edit Options below for further details about options.
shell sh[ell]
The user is put into the command interpreter specified by the shell edit option (see below). Editing is resumed on exit from the command interpreter.
source so[urce] file
Read and execute commands from the specified file. so commands can be nested.
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 below.) Any character other than a letter or a digit can be used to delimit the pattern instead of the /. If options includes the letter g (global), all instances of the pattern in the line are substituted. If the option c (confirm) is included, the user is queried about whether to perform each individual substitution, as follows: Before each substitution the line is typed with the pattern to be replaced marked with carat characters (^); a response of y causes the substitution to be performed, while any other input aborts 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 below).
If the alternative forms s or & 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.
If the alternative forms sr or ~ 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 alternative form s\?repl is equivalent to s/scan-re/repl/, where scan-re is the previous scanning string.
The alternative form s\&repl is equivalent to /subs-re/repl/, where subs-re is the previous substitution string.
suspend su[spend][!]
stop st[op][!]
^Z
Suspend the editor job and return to the calling shell. ^Z and the stop command are alternative names for the suspend command. ^Z is the user process control suspend character which is typically the character control-Z ( ASCII SUB ) (see stty(1)). This command is disabled if the calling shell does not support job control or has disabled it.
The buffer 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 buffer has been modified since the last write. To override this action, append the ! character to the suspend or stop command.
tag ta[g][!] tag
The files specified by the tags edit option (see below) are searched sequentially until a tag definition with the name of tag is found. If found, edit the file and position the editor at the address specified by the tag definition.
The buffer is written to the current file before the new file is edited if a file different from the current file is being edited, the autowrite editor option is set, the readonly editor option not set, and the buffer has been modified since the last write. To override this action, append the ! character to the 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][!] x
The macro definition for x is removed (see the map command above).
version ve[rsion]
Print the current version of the editor.
visual line vi[sual] type count flags
Enter visual mode at the specified line. The type is optional, and can be one of the designated characters +, -, ., or ^, as in the z command, to specify the position of the specified line on the screen window (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 edit option window. The flags # and l (ell) cause lines in the visual window to be displayed in the corresponding mode (see number and list commands). The Q command exits visual mode. For more information, see vi(1).
write range w[rite][!][ >>] file
range wq[!][>>] file
Write the specified lines (or the entire buffer, if no range is given) out to file, printing the 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 equivalent to w! followed by q; and wq>> is equivalent to w>> followed by q.
xit x[it][!][ >>] file"
If changes have been made to the buffer, a write command is executed with any options (such as !, >>, or file) used by the write command. Then (in any case) the quit command is executed.
yank range ya[nk] buffer count
Place the specified lines in the named buffer. 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).
(window) line z type count flags
The number of lines specified by count are displayed. The default for count is the value of the edit option window.
If type is omitted, count lines following the specified line (default current line) are printed.
If type is specified, it must be one of the following designated characters: +, -, ., ^, or =. + displays a window of lines following the addressed line, - causes the addressed line to be placed at the bottom of the window of displayed lines, . causes the addressed line to be placed at the center of the window, ^ displays a window of lines that are two windows prior to the addressed line, and = displays the addressed line at the center of the window with a line of dashes above and below the addressed line.
The last line printed becomes the current line, except for the = type, in which case the addressed line becomes the current line.
(escape) ! command
The remainder of the line after the ! is passed to the system command interpreter for execution. A warning is issued if the buffer has been changed since the last write. A single ! is printed when the command completes. The current line position is not affected.
Within the text of command, % and # are expanded as filenames, and ! is replaced with the text of the previous ! command (thus !! repeats the previous ! command). When such expansion is performed, the expanded line is echoed.
(escape) range ! command
In this form of the ! command, the specified lines (there is no default; see previous paragraph) are passed to the command interpreter as standard input; the resulting output replaces the specified lines.
(lshift) range < count flags
Shift the specified lines to the left; the number of spaces to be shifted is determined by the edit option shiftwidth. Only white space (blanks and tabs) is lost in shifting; other characters are not affected. The last line changed becomes the current line.
(rshift) range > count flags
Shift the specified lines to the right by inserting white space (see previous paragraph for further details).
(scroll) ^D
Ctrl-D (ASCII EOT) prints the next n lines, where n is the value of the edit option scroll.
(line number) line = flags
Print the line number of the specified line (default last line). The current line position is not affected.
(exec buffer) * [buffer]
@ [buffer]
Execute the contents of the named buffer as an editor command. There is no difference between the * and the @ forms of this command. If a buffer is not specified or buffer is * or @, the buffer last named in the exec buffer command is executed.
Regular Expressions
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.
\> The \> matches the end of a “word” (see previous paragraph).
~ 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 bracket-expression special characters.
\{...\} The constructs \{m\}, \{m,\}, and \{m,n\} are not supported.
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
The character & (\& if nomagic is set) in the replacement string stands for the text matched by the pattern to be replaced. The character ~ (\~ if nomagic is set) is replaced by the replacement part of the previous substitute command. The sequence \n, where n is an integer, is replaced by the text matched by the pattern 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 such conversion on, until the sequence \E or \e is encountered, or the end of the replacement string is reached.
Edit Options
The command ex has a number of options that modify its behavior. These options have default settings, which can be changed using the set command (see above). Options can also be set at startup by putting a set command string in the environment variable EXINIT, or in the file .exrc in the HOME directory, or in .exrc in the current directory. If EXINIT exists, the .exrc file in the HOME directory is not executed. If the current directory is not the HOME directory and the exrc editor option (see below) is set, the .exrc file in the current directory is executed after EXINIT or the HOME directory .exrc.
The editor obtains the horizontal and vertical size of the terminal screen from the terminfo database (see terminfo(4)). These values can be overridden by setting the COLUMNS and LINES environment variables. See the window option below for more information.
Options are Boolean unless otherwise specified.
autoindent, ai If autoindent is set, each line in insert mode is indented (using blanks and tabs) to align with the previous line. (Indentation begins after the line appended, or before the line inserted or the first line changed.) Additional indentation can be provided as usual; succeeding lines are automatically indented to the new alignment. Reducing the indent is achieved by typing ^D one or more times; the cursor is moved back shiftwidth spaces for each ^D. (A ^ followed by a ^D removes all indentation temporarily for the current line; a 0 followed by a ^D removes all indentation.)
autoprint, ap The current line is printed after each command that changes buffer text (autoprint is suppressed in global commands).
autowrite, aw The buffer is written to the current file if the buffer has been modified and a next, rewind, or ! command is given.
beautify, bf Cause all control characters other than tab, new-line, and form-feed to be discarded from the input text.
directory, dir Specify the directory to which the editor buffer should be placed. This option only takes effect when a new buffer is created. It should be set in EXINIT or .exrc to affect the location of the buffer file for the edit file specified on the command line.
If the specified directory is set from EXINIT or a .exrc file and is not writable by the user, the editor quits; if set interactively by the user, the editor issues an error message.
doubleescape When set, two consecutive ESC (escape) characters are required to leave input mode. In input mode, a single ESC character followed by a different character causes vi(1) to issue an audible or visual warning (see the flash edit option) and insert both characters into the buffer. This option is not set by default.
The character sequences transmitted by keyboard editing keys of some terminals are identical to some sequences of vi(1) user commands. If the mapping of these keys is enabled (see the keyboardedit and keyboardedit! options), vi(1) might not be able to reliably distinguish between the character sequence transmitted by an editing key and the same character sequence typed by a user. This problem is most likely to occur when the user is typing ESC to terminate input mode immediately followed by another vi(1) command. By setting the doubleescape option, the ambiguity of this case is removed.
edcompatible, ed Cause the presence of g and c suffixes on substitute commands to be remembered, and toggled by repeating the suffixes.
errorbells, eb When set, error messages are preceded with a bell only on terminals that do not support a standout or highlighting mode such as inverse video. If the terminal supports highlighting, the bell is never used prior to error messages and this option has no effect. Note that visual-mode errors are signaled by the bell (regardless of the setting of this option) without an accompanying error message.
exrc When set, the .exrc file in the current directory is processed during editor initialization if the current directory is not the HOME directory. This option is not set by default and must be set in the EXINIT environment variable or the HOME directory .exrc file to have any effect. See the Edit Options introductory text above.
flash, fl When set, the screen flashes instead of beeping, provided an appropriate flash_screen entry is present in the /usr/lib/terminfo/* database for the terminal being used.
hardtabs, ht Define the spacing between hardware tab settings and the number of spaces used by the system when expanding tab characters. Tab stops are placed in each column number (starting at the left edge of the screen) that corresponds to an integer multiple of the numeric value of this option.
ignorecase, ic All uppercase characters in the text are mapped to lowercase in regular expression matching. Also, all uppercase characters in regular expressions are mapped to lowercase, except in character class specifications.
keyboardedit When set, any keyboard editing key mappings that are loaded automatically at initialization for command-mode use are enabled. If not set, these mappings are disabled (but not deleted). Use the map command to get a list of the currently enabled command-mode mappings. This option is set by default.
keyboardedit! When set, the keyboard editing key mappings automatically loaded at initialization for insert-mode use are enabled. If not set, these mappings are disabled (but not deleted). Use the map! command to list the currently enabled insert mode mappings. This option is not set by default for terminals whose keyboard editing keys send HP -style escape sequences (an ESC followed by a single letter). This option is set by default for all other terminals.
lisp Autoindent mode, and the ( ) { } [[ ]] commands in visual mode are suitably modified for lisp code.
list All printed lines are displayed with tabs shown as ^I, and the end of line marked by a $.
magic Change the interpretation of characters in regular expressions and substitution replacement strings (see the relevant sections above).
mesg If set, other users can use the write command (see write(1)) to send messages to your terminal, possibly disrupting the screen display. Unsetting this option blocks write permission to your terminal from other system users while you are using the editor.
modelines, ml If set when the editor reads in a file, any ex commands embedded in the first five and last five lines of the file are executed after .exrc and EXINIT commands are processed but before editing control is given to the user. The ex commands must be prefixed by ex: or vi: and terminated by : in a single line. Any number of other characters with the exception of the colon (:) can precede or follow the embedded command.
novice Use the version of the editor available for novices, known as edit or vedit.
number, nu Cause lines to be printed with line numbers.
optimize,opt Suppress automatic carriage returns on terminals that do not support direct cursor addressing. This streamlines text output in certain situations such as when printing multiple lines that contain leading white space.
paragraphs, para The value of this option is a string whose successive pairs of characters specify the names of text-processing macros that begin paragraphs. (A macro appears in the text in the form .xx, where the . is the first character in the line.)
If any macros have a single-character name, use a space character to substitute for the missing second character in the name. When typing a space character in such situations, the space must be preceded by a backslash (\) to prevent the editor from interpreting it as a delimiter.
prompt When set, command mode input is prompted for with a colon (:); when unset, no prompt is displayed.
readonly, ro Set the read-only flag for the file being edited, thus preventing accidental overwriting at the end of the session. This option is equivalent to invoking vi or ex with the -R option or using the view command.
redraw The editor simulates an intelligent terminal on a dumb terminal. (Since this is likely to require a large amount of output to the terminal, it is useful only at high transmission speeds.)
remap If set, macro translation allows for macros defined in terms of other macros; translation continues until the final product is obtained. If unset, a one-step translation only is done.
report The value of this option gives the number of lines that must be changed by a command before a report is generated on the number of lines affected.
scroll The value of this option determines the number of lines scrolled by a ^D command and the number of lines displayed by the z command (twice the value of scroll).
sections The value of this option is a string, in that successive pairs of characters specify the names of text-processing macros that begin sections. (See paragraphs option above.)
shell, sh The value of this option specifies the file name of the user shell to be used for the ! shell escape and shell commands. It is set by default to the value of the user’s SHELL environment variable, if set, and otherwise to /bin/sh.
shiftwidth, sw The value of this option gives the width of a software tab stop, and is used during autoindent and by the shift commands.
showmatch, sm When a ) or } is typed while in visual mode, the matching ( or { is shown if it is still on the screen.
showmode, smd When set, showmode displays the current editor mode (such as INPUT MODE) in the lower right-hand corner of the screen during the visual and open commands.
slowopen, slow In visual mode, slowopen prevents screen updates during input to improve throughput on unintelligent terminals.
tabstop, ts The value of this option specifies the software tab stops to be used by the editor to expand tabs in the input file.
taglength, tl Specify the maximum number of characters in a tag that should be treated as significant. Characters beyond the limit are ignored. A value of zero (default value) means that all characters in the tag are significant.
tags Specify which files should be used by the tag command and the -t option. The default is tags /usr/lib/tags. Each line of a tags file contains the following three fields separated by one or more space or tab characters: the tag name, the name of the file to be edited, and an address specification associated with the tag. A tags file must be sorted in order by tag name (see EXTERNAL INFLUENCES below).
The ctags command (see ctags(1)) can be used to create tags files from C, Pascal and FORTRAN source files.
term Define the type of terminal being used with the editor. The value is obtained from the TERM environment variable by default. There is no difference between the term and ttytype editor options. Setting either one results in both being changed.
terse When set, error messages are shorter.
timeout , to When set, all the characters of a multicharacter macro name (the first argument to the map command) must be received within the amount of time specified by the timeoutlen option to be accepted as a match for the macro and mapped to the defined string. If not set, no limit is placed on how long vi waits for the completion of a macro name. This option is set by default.
timeoutlen The value of this option specifies in milliseconds (ms) the length of the macro timeout window (see the timeout option). The value must be at least 1 ms and the default is 500 ms. The value of this option has no effect unless the timeout option is enabled.
ttytype, tty Define the type of terminal being used with the editor. The value is obtained from the TERM environment variable by default. There is no difference between the term and ttytype editor options. Setting either one results in both being changed.
warn Warn if there has been no write since last change before a ! or shell command escape.
window, wi The number of lines in a text window in visual mode. The default value is set to one less than the size of your terminal screen (as defined by the LINES environment variable, if set, or the terminfo(4) data base otherwise). However, if the terminal baud rate (see stty(1) is set to less than 1200 or 2400, the default value is reduced to a maximum of 8 or 16 lines, respectively. The default value can be overridden by specifying a window size via the -w option when invoking the editor.
w300 If the terminal baud rate is less than 1200, set the window editor option to the value specified.
w1200 If the terminal baud rate is greater than or equal to 1200 but less than 2400, set the window editor option to the value specified.
w9600 If the terminal baud rate is greater than or equal to 2400, set the window editor option to the value specified.
wrapscan, ws When set, editor searches using /re/ (or ?re?) resume from the beginning (or end) of the file upon reaching the end (or beginning) of the file (that is, the scan “wraps around”). When unset, editor searches stop at the beginning or the end of the file, as appropriate.
wrapmargin, wm In visual mode, if the value of this option is greater than zero (that is, wrapmargin=n), a newline is automatically added to an input line at a word boundary, so that lines end at least n spaces from the right margin of the terminal screen.
writeany, wa Inhibits the checks otherwise made before write commands, allowing a write to any file (provided the system allows it).
EXTERNAL INFLUENCES
Environment Variables
LC_COLLATE determines the collating sequence used in evaluating regular expressions and in processing the tags file.
LC_CTYPE determines the interpretation of text as single and/or multi-byte characters, the classification of characters as uppercase or lowercase letters, the shifting of the case of letters, and the characters matched by character class expressions in regular expressions.
LANG determines the language in which messages are displayed.
If LC_COLLATE or LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, the editor behaves as if all internationalization variables are set to "C". See environ(5).
When set, the TMPDIR environment variable specifies a directory to be used for temporary files, overriding the default directory /tmp.
International Code Set Support
Single- and multi-byte character code sets are supported.
WARNINGS
The undo command causes all marks to be lost on lines that are changed and then restored.
The z command prints a number of logical rather than physical lines. More than a screenful of output might result if long lines are present.
Null characters are discarded in input files and cannot appear in resultant files.
On some systems, recovery of an edit with the -r option might be possible only if certain system-dependent actions were taken when the system was restarted.
On HP terminals, the attribute field of any function key specified via a map #n ... command should be set to normal rather than to the default of transmit.
For information about line-length limits, file size limits, etc., see WARNINGS section of vi(1).
AUTHOR
ex was developed by the University of California, Berkeley. The 16-bit extensions to ex are based in part on software of the Toshiba Corporation.
FILES
/usr/lib/terminfo/*/* describes capabilities of terminals
./.exrc editor initialization file
$HOME/.exrc editor initialization file
/usr/lib/exstrings error messages
/usr/lib/exrecover recover command
/usr/lib/expreserve preserve command
/tmp/Ex2nnnnn editor temporary
/tmp/Rx2nnnnn named buffer temporary
/usr/preserve preservation directory
SEE ALSO
ctags(1), ed(1), expreserve(1), stty(1), vi(1), write(1), terminfo(4), environ(5), lang(5), regexp(5).
The Ultimate Guide to the vi and ex editors, Benjamin/Cummings Publishing Company, Inc., ISBN 0-8053-4460-8, HP part number 97005-90015.
STANDARDS CONFORMANCE
ex: SVID2, XPG2, XPG3
Hewlett-Packard Company — HP-UX Release 9.0: August 1992