ex is a line-based text editor.
Only users who have accessed the POSIX shell via rlogin can use ex (except in line mode).
ex offers you various operating modes:
In the ex input mode you enter text directly.
In the ex command mode you enter commands. Among other things, commands enable you to:
position the cursor
search for (and replace) text patterns with the aid of regular expressions
switch to another file
invoke a shell
You also have the option of switching from the line editor ex to the screen editor vi.
Layout of this description
The description of how to call ex on POSIX shell level is followed by the sections:
Functionality of ex
Operating modes of ex
Saving the editor buffer and quitting ex
Presetting ex
Current and alternate files
Regular expressions
Replacement strings
Buffers
Error and signal handling
ex commands
Addressing
Parameters
Commands
ex options
Syntax
ex[ option] file... |
option
(silent) All interactive output of the editor is suppressed. The -s option must be set when ex is to read its commands from a command script. The -s option has replaced the old - option.
(tag) ex loads the file containing the tag for editing and positions the tag definition under the cursor at the center of the screen. The tags file containing the search strings for the definitions must be in the same directory. This option is typically used by C programmers to quickly locate the definition of a function or macro on calling the editor. The tags file needed for this purpose must first be built with the ctags command.
(recover) Restores the ex session in which you were editing file if ex or the system crashed during your session. Changes that are only in the editor buffer are not copied to the edited file after a system or ex editor crash. POSIX does, however, try to save the buffer contents by creating a copy of it, if possible. file is recovered, including any changes made prior to the crash, and is retrieved into the vi buffer. You can now continue editing the file or save the changes in another file.
Lists the names of all files saved following an editor or system crash.
Sets the value of the ex window option (see "ex command and display editor") to n.
(readonly) The named file is opened in readonly mode. This mode prevents the original file from being accidentally overwritten, but allows you to write the buffer contents to a file with another name. Caution!
(vi) Invokes the vi editor. A detailed description of vi is provided in this manual (see vi on "vi screen oriented (visual) display editor").
Positions the editor at a specific line of the file to be edited or executes an ex command when ex is invoked. If you position the editor at a line, the selected line will be displayed in the center of the screen. By contrast, if you have an ex command executed, the editor will be positioned at the last line of the file after executing the command, unless the ex command you specify (e.g. search) positions the editor itself. command not specified: command specified:
n must be an integer. ex is positioned to the nth line of the file.
ex-command can be any ex command. The ex command must be quoted (using single or double quotes) in order to prevent it from being interpreted by the shell. If the editor is not already positioned as a result of an ex command, ex will be positioned to the last line of the file. Example When ex is called with:
the file appointments is opened, and the cursor is positioned at the first line that contains the word tuesday.
Name of the file that you wish to edit. If you specify a number of files, these files will be processed in the order in which they are listed. The ex command n can be used to switch to the next file. file not specified: Caution! |
Functionality of ex
ex always works on a buffer, not on files. When you start an ex session, a working copy of the file you are editing is read into the editor buffer. All the editing changes you make are initially performed in this buffer and are not saved until you use the w (write) command to copy the buffer contents back into the original file. Null ASCII characters (see section “ASCII character set (ISO 646)”) are discarded in input files and thus cannot appear in output files. |
Operating modes of ex
ex offers you two file editing modes:
You can also switch from ex to the vi editor, which provides you with additional operating modes (for more details see vi, “vi modes” (vi screen oriented (visual) display editor)). When ex is invoked, it comes up in command mode, as indicated by the prompt : displayed on the screen. The commands a (append), i (insert), and c (change) can be used to switch to the input mode, which enables you to add or modify text in the buffer (see “Commands”). In input mode, all subsequent input characters, including various non-printing characters, are written into the buffer. Commands are not interpreted as such. You can exit from input mode by entering a period (.) in the first column and then pressing the enter key. |
Saving the editor buffer and quitting ex
ex must be in command mode to save the editor buffer or to quit the ex editor. Use the following command to save the contents of your editor buffer to the file edited or that specified:
(write) The contents of the editor buffer are saved to the file specified. file not specified: You can quit ex using one of the following options: (quit) Quit ex. This works only if the editor buffer has not been modified at all or if the modified editor buffer has been saved to a file.
(quit) Quit ex. Unsaved modifications made to the editor buffer are not saved.
Quit ex and write the modified editor buffer to the edited file.
(write and quit) Quit ex and write the modified editor buffer to the file specified. file not specified: Caution! |
Presetting ex
The ex editor can, to some extent, be adapted to suit your requirements and working habits. This entails using the ex command se (set), which allows you to set or change specific options (see “ex options”). The changes you make remain in effect for the current session. Details on how to change default settings permanently can be found in the vi command description (see "vi screen oriented (visual) display editor"). |
Current and alternate file
The file (or its copy) being edited by ex at any given moment is referred to as the current file. The alternate file is the file most recently mentioned in an editing command. If you switch to the alternate file, the file you switch from becomes the new alternate file. When specifying files, you can use the % character for the current file and the # character for the alternate file. These characters are replaced in file names by the names of the current file and the alternate file, respectively. Example
backs up the current file to a file with the same name but with the extension .bak. |
Regular expressions
The interpretation of metacharacters in regular expressions depends on whether or not the magic option has been set for the ex editor (see “ex options”). When magic is set: character An ordinary character stands for itself. The following are metacharacters, not ordinary characters: (caret) at the beginning of a pattern (dollar sign) at the end of a pattern (asterisk) anywhere except at the beginning of a pattern (period) at any position in a pattern (left square bracket) at any position in a pattern (tilde) at any position in a pattern Metacharacters have special meanings and must be escaped with a backslash \ if they are to lose their special meanings. ^ at the beginning of a pattern stands for the beginning of the line. $ at the end of a pattern stands for the end of the line. stands for any one character. \< matches the beginning of a word. The word must begin with a letter, digit, or underscore and be preceded by the beginning of the line or a character other than the above. \> matches the end of a word.
Any character contained in string, where string is not a sequence of blank characters. The following characters have special meanings within string:
If these characters are escaped by a backslash, they lose their special meanings. Zero, one or more occurrences of the regular expression preceding the * character. Matches the replacement string used in the last s command (substitute, see “Commands”).
A regular expression pattern can be enclosed in parentheses escaped by backslashes. This serves only to identify them for substitution actions (see Replacement strings below).
A sequence of two regular expressions r and s is a regular expression in itself. rs matches all strings which consist of a string matching r followed by a string matching s. When nomagic is set: If nomagic has been set, the only characters that have special meanings are:
The following characters only have a special meaning if they have been escaped by a preceding backslash \:
|
Replacement strings
The ampersand character & (with a preceding backslash, i.e. \&, if nomagic is set) in the replacement string stands for the text matched by the pattern, i.e. the text to be replaced. The tilde ~ (\~ if nomagic is set) is replaced by the replacement string used in the previous s (substitute) command. The sequence \n, where n is an integer, is replaced by the text that is matched by the pattern enclosed in the nth set of parentheses \(...\). If the replacement string includes the sequence \u or \l, the character that immediately follows \u (upper) or \l (lower) in the replacement string will be converted to uppercase (for u) or lowercase (for l) if this character is a letter. The sequence \U or \L converts into uppercase or lowercase all letters until the end of the replacement string or until the sequence \E or \e is encountered. |
Buffers
ex uses one unnamed and 26 named buffers, named a through z. You can use these buffers to copy text with ya (yank), to save deleted text with d (delete), and to subsequently retrieve this text with pu (put). The d, pu, and ya commands use the unnamed buffer unless you explicitly name a buffer. In other words, if you do not specify a buffer for a delete operation, for example, the material you delete will be saved in the unnamed buffer. You can save blocks of text in up to 26 buffers. The buffers are designated in either lowercase or uppercase letters from a-z (or A-Z). If you use lowercase letters, the old contents of the buffer will be overwritten by the new text, i.e. the old contents are deleted. If you use uppercase letters, the old buffer contents are not overwritten; the new text is appended to the old one instead. |
Error and signal handling
When an error occurs during an ex session, ex sends the BEL character (acoustic signal; see section “ASCII character set (ISO 646)”) to the terminal and prints an error message. If an interrupt signal is received, ex returns to command mode, allowing you to enter a new ex command. |
Entering commands
Unlike most vi commands, which are interpreted and executed by vi immediately, ex commands must be "dispatched" by pressing the enter key. Command lines which start with double quotes " are ignored. This means that you can use lines of this kind to insert comment lines in a command script. |
Addressing
An address is used to specify a particular line. Some ex commands expect one or more addresses as input. The specified line or line range (an inclusive range of all lines from the first address to the second) is then processed by the ex command. For ex, there is at all times a current line. This is explicitly addressed by a period (.). As a rule, the current line is the line last processed by a command or the line to which the editor has been explicitly positioned (e.g. by a search command). Addresses must be separated from one another by a comma or a semicolon. Such address lists are evaluated by ex from left to right.
If more addresses are given than the command requires, then all but the last address (when a line is expected) or the last two addresses (if a range is expected) are ignored. When a command requires two addresses, the first line that is addressed must precede the second one in the buffer. If you do not specify any address (null address), ex will use the current line by default.
|
Parameters
The following parameters are used with ex commands:
A single line address, which you can specify in any of the forms described earlier in the Addressing section. line not specified:
A pair of line addresses that defines an inclusive range of lines. The addresses can be separated by a comma or a semicolon. A range should not be specified together with a number n, since the last address of the specified range will then be interpreted as the first address of a range of n lines that begins with the last address. In other words, you would end up addressing a range that comes after the one intended. This has been taken into account in the ex command syntax. range not specified:
A positive integer. In n you specify the number of lines to be processed. n not specified:
One or a combination of the ex commands # (see nu), p, and l. These commands display a line in a specific format and are executed after the preceding ex command completes.
The blanks need not always be specified. However, in the interest of clarity, they have not been indicated as optional here. Any number of plus or minus characters may be combined with these parameters. |
Commands
Overview of ex commands and their abbreviations
No command specified If you specify only a line or a range, the command p (print) is automatically assumed and executed. If a null line is entered, the next line is printed (equivalent to .+1p) CTRL+D (ASCII EOT) prints the next n lines, where n is the value of the ex option scroll.
(abbreviate) This command is only effective in vi mode! If you enter word in the vi input mode as a complete word (i.e. not as a word fragment), it is replaced by the string text. If text is to include special characters, e.g.newline, these characters must be preceded by CTRL+V.
(append) Causes ex to enter input mode, placing the input text after the specified line. Use a line value of 0 to put a line at the beginning of the buffer. The last line of new input becomes the new current line. If there is no new input, the target line becomes the current line.
(arguments) Prints the argument list from the command line of the ex call, enclosed in square brackets [...].
(change) ex switches to input mode. n lines or the lines in range are replaced by the lines you enter next.
(chd/cd - change directory) ex changes the current working directory to directory. directory not specified:
(copy) Copies the lines specified by range to after line. If line is assigned a value of 0, the range of lines (i.e. text) will be copied to the beginning of the buffer.
(delete) The lines in range, or n lines from the given line, are deleted from the buffer. If a named buffer is specified, the deleted text is saved in it. You can use the ex command pu to retrieve the contents of this buffer if you wish. The first line following the deleted material becomes the current line, unless the deleted lines were at the end of the buffer. In that case, the last line in the buffer becomes the current line.
(edit) The named file is edited. If the current buffer has been modified since the last w (write) command, ex warns you and aborts the command. You can, however, force the execution of the e command by appending an exclamation mark to the e: e! file. The current line is the last line of the buffer; however, if this command is called from vi, the current line becomes the first line of the buffer. +line The specified line becomes the current line. line can be given as:
(file) Prints the current file name and other information, e.g. the number of lines and the position of the current line. name specified:
(global) First marks all lines within the given range that match the pattern specified in RE; then applies the given cmds to the each of marked lines in turn, with each marked line becoming the current line while it is being edited. The commands given in cmds may be specified on separate lines, provided newline characters are escaped with a backslash. If cmds are omitted, all lines will be printed. The a(ppend), c(hange), and i(nsert) commands are allowed; the terminating period at the end of cmds may be omitted. The visual command is also permitted, and takes input from the display terminal. The following commands are not permitted in cmds: global and undo. The following edit options are not allowed in cmds: autoprint, autoindent and report. Example
All occurrences of * in the first column ^ of line 1 and of all lines through to the end of the file ($) are replaced by a plus character (+) by the substitute command (s).
(insert) ex enters input mode; the input text is placed before the specified line. The last line inserted becomes the current line, but if no text is inserted, the line before the target line becomes the current line. Input is terminated by a period (.) entered in column 1.
(join) Joins the lines in range, or n lines from line, into one line. The command inserts at least one blank between two previously split lines; two blanks are provided if a line ends with a period. If a following line begins with a right parenthesis, no blanks are inserted. Extra white space at the start of a line is discarded. Appending an exclamation mark to the j command (j!) produces a simpler join with no white space processing.
(list) Displays the specified lines. Tab characters are replaced by
Only works with vi! Format 1: Macro definitions for vi command mode This format of the map command is used to define macros for use in the vi command mode. The first argument x is a single character, or the sequence #n, where n is a digit that refers to function key n. When this character or function key is typed in vi command mode, vi responds as if the corresponding commands were entered. The specified commands are interpreted as a sequence of vi commands. If special characters, white space, or newline characters are to be used in the commands, they must be escaped with CTRL+V. Example 1 You want to define a macro which replaces an * occurring at the beginning of a line (column 1) by a blank
Example 2 You now want to define a macro and bind it to function key F1. This macro is to search for the next line that begins with a particular regular expression RE and then automatically delete this line.
Format 2: Macro definitions for vi input mode This format of the map command defines macros for use in vi input mode (see If x is not to be replaced by text, it must be escaped by preceding it with CTRL+V. Formats 1 and 2: Macro definitions can be cancelled with:
(mark) Marks the specified line with the character x, which must be a single lowercase letter. The x must be preceded by a blank or tab. The current line position is not affected.
(move) Moves the specified lines (range) to after the target line. The first of the moved lines becomes the current line.
file not specified: file specified:
(number) Prints the lines, each preceded by its line number. The only useful flag in this case is l. The last line printed becomes the current line.
(preserve) The current editor buffer is saved as though the system had just crashed. The pre command is for use in emergencies, e.g. when a w (write) does not work because the disk is full, and the buffer contents cannot be saved in any other way.
(print) Prints the specified lines, with non-printing characters printed as control characters in the form
(put) Lines deleted with d (delete) or copied to a buffer with y (yank) are put back in after the specified line. buffer represents a buffer name from a to z. buffer not specified:
(quit) Quits the editor. If the buffer has been modified since the last w (write) command, a warning is printed and the q command fails. You can, however, force the execution of the q command by appending an exclamation mark to the q: q!. All changes not saved with w will then be discarded.
(read) Places a copy of the specified file in the buffer after the target line. Use a value of 0 to place text at the beginning of the buffer. If there is no current file at this point (e.g. when ex is called without a file name), then file becomes the current file. The last line read becomes the current line; in vi mode, the first line read becomes the current line. file not specified: If file is given as !cmd, then cmd is interpreted as a POSIX command and passed to the shell. The output of the command is then read in to the buffer.
Recovers file from the save area after an editor or system crash.
(rewind) The argument list (see ar) is rewound, and the first file in the list is edited. If the buffer has been modified since the last w (write) command, a warning is printed and the rew command is not executed. You can, however, force the execution of the rew command by appending an exclamation mark to the rew command: rew!. All changes not saved with w are then discarded.
(set) The set command can be used to display or set options. There are two types of options: those that have "Boolean" (i.e. on or off) values and those that do not. One example of a Boolean parameter is the number option. If this option is set, line numbers are displayed; when nonumber is set, no line numbers are displayed. By contrast, the report option is non-Boolean. The value of this option (default = 5) defines the number of lines that must be changed by a command before ex and vi issue a message. parameter
The values of all options are displayed.
The current value of the specified option is displayed.
Only for options with Boolean values: The option is set.
Only for options with Boolean values: The option is not set.
Only for options with non-Boolean values: The option is assigned the specified value. parameter not specified: More detailed information on ex options is provided in the corresponding section.
If the SHELL variable is set, the shell defined in that variable is invoked; otherwise, the Bourne shell sh. When you exit the shell, you will be returned to the editing session at the point you left off.
Reads and executes commands from the specified file. Such so commands may be nested.
(substitute) The first occurrence of a pattern that matches RE (regular expression) in each line of the given range is replaced by the string repl (see “Regular expressions” and “Replacement strings”). The range is either given in range or specified as n lines from the specified line. /RE/repl not specified: options
(unabbreviate) word is deleted from the list of abbreviations set up by ab.
(undo) Reverses the changes made by the previous editing command. g (global) and vi (visual) are considered single commands in this case. Commands which affect the external environment, such as w (write), e (edit), and n (next), cannot be undone. An undo can itself be reversed with a follow-up u. All markers for lines changed and subsequently restored are lost with u.
(unmap) Removes the macro definition created by map for x.
(vice versa) This is the same as the global command, except that cmds are applied to all lines that do not match the pattern RE.
Prints the current version of the editor.
Enters vi mode at the specified line. The type is optional and may be given as a minus sign (-) or a period (.), as in the z 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. n specifies an initial window size; the default is the value of the ex option window. The command Q exits vi mode and returns you to ex. For further information, see vi on "vi screen oriented (visual) display editor".
Format 1: Write to a file (write) The specified range is written to the named file, and the number of lines and characters written is printed. If an alternate file is specified, and the file exists, the command will fail in order to prevent the alternate file from being accidentally overwritten. The execution of w can, however, be forced by appending an exclamation mark to the command: w!. To append to the file, use the form w>>. If the file does not exist, an error message is issued. If !cmd is specified instead of file, then cmd is interpreted as a POSIX command. The command interpreter is invoked, and the specified range is passed as standard input to the command. range not specified: file not specified: Format 2: Write to a file and quit ex (write and quit) The command wq is equivalent to a w followed by a q; wq! is equivalent to w! followed by q.
(exit) Writes out the buffer if changes have been made since the last w and then (in any case) quits.
Copies (yanks) the specified range, or n lines from the specified line, to the named buffer. buffer not specified:
(window) Displays n lines from the area in which line is located. n not specified: type type is an optional parameter and can be specified as follows:
The last line printed becomes the current line. type not specified: Caution: ex prints the number of logical rather than physical lines. More than a screen full of output may result if there are lines which are longer than the screen width.
(escape) The remainder of the line after the exclamation mark is passed to the system command interpreter for execution. A warning is issued if the buffer has been changed since the last w (write) command. The specified command is then executed. If the command output has not been redirected, it is displayed on the screen, but does not change the file. The command itself may, however, modify the file, e.g. Within the text of command, the percent sign % and the hash character # are expanded as file names (see “Current and alternate file” ). An exclamation mark in command is replaced with the text of the previous ! command. Thus, !! means "repeat the preceding command". If any such expansion is done, the expanded line will be echoed.
(escape) In this form of the ! command, the lines specified in range are passed to the command as standard input and replaced by the output of the command. range not specified: "
(resubst) Repeats the previous s (substitute) command, as if & were replaced by the previous s/RE/repl/. The same effect is obtained by omitting the /RE/repl/ string in an s command.
(lshift) Shifts the defined line range (or the n lines that follow line) to the left by the number of spaces specified by the shiftwidth option. White space (blanks and tabs) is lost in the shift process; other characters are not affected. The last line changed becomes the current line.
(rshift) Shifts the defined line range (or the n lines that follow line) to the right by the number of spaces specified by the shiftwidth option. White space (blanks and tabs) is not lost, but inserted as required.
(line number) Prints the line number of the specified line. The current line position is not affected. line not specified: |
ex options
ex provides a number of options with which you can govern the behavior of both the ex and (more importantly) the vi editors (see vi, “Customizing the vi environment” (vi screen oriented (visual) display editor)). All options have default settings; these settings are valid at the time ex or vi is invoked. Use the ex command se (set) if you wish to have all options displayed: The above command can also be used to change one or more options: This command shows the vi input mode in the status line and sets the number of lines scrolled by the CTRL+D key to 15. The command: displays all options set to non-default values. There are two types of options: those that have "Boolean" (i.e. on or off) values and those that do not. One example of a Boolean parameter is the showmode option. When this option is not set, it is named noshowmode. The scroll option, by contrast, is an example of a non-Boolean parameter. autoindent, ai If autoindent is set, each line in insert mode is aligned with the beginning of the previous line; tabs and blanks are inserted to produce this alignment. The starting indentation of a line is determined by the line it is appended after (a), the line it is inserted before (i), or the first line to be changed (c). Extra indentation can be provided as usual; succeeding lines will automatically be indented to the new alignment. To reduce the level of indentation, you can press CTRL+D one or more times to move the start of the line to the left to positions which are multiples of shiftwidth. Thus if the current cursor position is 25 and shiftwidth is set to 10, pressing CTRL+D once will move the cursor to the left to position 20, while pressing it twice will take the cursor to position 10. A caret ^followed by a CTRL+D removes all indetation temporarily for the current line; a 0 (zero) followed by a CTRL+D removes all indentation. autoprint, ap Prints the current line after each command that changes buffer text. autoprint is suppressed during global search and replace operations (see g, s and v). autowrite, aw Writes the buffer to the current file if the buffer has been modified, and an e (edit),n (next), rew (rewind) or ! (escape) command has been given. beautify, bf Causes all control characters other than tab, newline and form feed to be discarded from the input text. directory=dirdir=dir The value of dir specifies the directory which is to hold the editor buffer. If the user does not have write permission for this directory, the editor quits. edcompatible, ed Causes the presence of g and c suffixes on s (substitute) commands to be remembered for use as toggles. errorbells, eb Rings the terminal bell before displaying error messages in the last line (usually in reverse video). exrc, ex This option has been deactivated for security reasons. It normally causes .exrc files in the current directory to be evaluated. flash, fl (default) If the terminfo description contains an entry for flashing the screen to indicate an error, this option can be used to inform users when they have made an invalid entry. hardtabs=numberht=number If the terminal has hardware tabs, this option can be used to set the number of spaces to which the tab stops are set (to optimize screen output). ignorecase, ic Treats all uppercase characters in the text as lowercase when a search is made. Uppercase characters in regular expressions are also mapped to lowercase, except in character class expressions. lisp Activates the autoindent option and modifies the vi commands left parenthesis (, right parenthesis ), left brace {, right brace }, double left brackets [[, and double right brackets ]] suitably. list All printed lines will be displayed with tabs shown as magic (default) Changes interpretation of characters in regular expressions and substitution replacement strings (see the relevant sections). mesg (default) Grants/denies other users permission to write to the terminal (e.g. with the write command). modelines (default) The first and last five lines of a file that is read in are interpreted as editor commands and executed if they are in the form: novice Defines the level of detail for error messages. number, nu Causes lines to be printed with line numbers. optimize, opt Allows you to set the terminal with or without automatic carriage returns (to optimize output). paragraphs=string The value of this option is a string in which each successive pair of characters specifies the name of an nroff macro that begins a paragraph. A macro appears in the text in the form .XX, where the . is the first character in the line. prompt (default) When prompt is set, the : prompt is displayed in command mode; otherwise, there is no command-mode prompt. readonly If readonly is set, the editor can only be used to read files, not to make changes to the text. If noreadonly is set, you can make changes to files. redraw (default) 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 (default) If remap is set, macro translation allows for macros defined in terms of other macros; translation continues until the final product is obtained. Only one step of translation is performed if noremap is set. report=n When the number of lines changed, deleted, or copied by the last command exceeds n, a message is issued in the status line. scroll=n The value n specified for scroll determines the number of lines that the screen will scroll when a CTRL+D command is entered. It also controls the number of lines displayed by a z command (twice the value of scroll). sections=string The value assigned to this option is a string in which each successive pair of characters specifies the name of an nroff macro which begins a section. A macro appears in the text in the form .XX, where the . is the first character in the line. shiftwidth=n The value n specified for sw is used for the spacing of tab stops used by the tab key, the autoindent option, and by the < and > (shift) commands. showmatch, sm When a right parenthesis ) or right brace } is entered in vi, the matching left parenthesis ( or left brace { is shown, provided the matching character is still on the screen. showmode, smd When smd is set, an indication is provided in the status line as to whether vi is in vi input mode. slowopen, slow In vi, prevents screen updates during input to improve throughput on unintelligent terminals. tabstop=n n specifies the software tab spacing to be used by the editor when expanding tabs in the input file. taglength=number Defines how many characters are to be considered significant in searches with the :tag command. A value of 0 means that all characters are to be considered. tags=files Names of tag files, separated by blanks. term=string string tells vi what type of terminal is being used. (The default is the value of the environment variable TERM.) terse Setting terse causes shorter error messages to be issued. timeout Sets/cancels a timeout period. ttytype=string string tells vi what type of terminal is being used. (The default is the value of the environment variable TERM.) warn (default) When warn is set, the warning No write since last change is issued if a :! command is given before the most recent changes to the editor buffer have been saved with w. window=n The number of lines in a vi text window. wrapmargin=n Only effective in vi. If n>0, a newline is automatically added to an input line at a word boundary such that lines end at least n spaces from the right margin of the terminal screen. The setting of automatic line breaks can be deactivated by setting the value of n to 0 (default). wrapscan, ws (default) Setting wrapscan causes searches begun by the /.../ or ?...? commands to wrap around from the end of a buffer to the beginning (or vice-versa). When nows is set, the search runs through to the end or beginning of the buffer as appropriate and then terminates. writeany, wa When nowa is set, a check is performed before a w command to determine whether the file exists. This is to prevent an existing file from being accidentally overwritten. You can override the overwrite protection with w!. Setting wa inhibits the normally provided overwrite protection. |
Error
When an error occurs, ex sends the acoustic signal BEL (see section “ASCII character set (ISO 646)”) to the terminal and prints a message. If an interrupt signal is received, ex returns to command level, allowing you to enter a new ex command. If the editor input is from a file, ex exits at the interrupt signal. If ex detects an internal error, it attempts to preserve the buffer if the most recent changes have not been saved. If you wish to access the backed up data, you must call ex with the-r option. |
File
$HOME/.exrc File containing default values for ex and vi. These defaults are overridden if conflicting settings have been assigned to EXINIT. |
Variable
TERM The type of data terminal used must be defined in the environment variable TERM. EXINIT Environment variable with default values for ex and vi. These defaults always apply. PATH Determine the search path for the shell command specified in the editor commands shell, read and write. HOME Determine a pathname of a directory that will be searched for an editor startup file named .exrc. SHELL Determine 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 no SHELL variable is set, or it is set to a null string, the sh utility will be used. COLUMNS Override the system-selected horizontal screen size. LINES Override the system-selected vertical screen size, used as the number of lines in a screenful and the vertical size in visual mode. |
Locale
The following environment variables affect the execution of ex: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_COLLATE Determine the locale for the behavior of ranges, equivalence classes and multicharacter collating elements within regular expressions. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
See also
ed, vi |