.if !\n(xx .so tmac.e .SH Initialization .PP When it is first invoked, .EX will use the home directory data base .I htmp to set the .I home directory option and to set the .I ttytype option, reflecting the kind of terminal in use. If there is a file .B \&.exrc in the user's home directory, then .EX will .I source to that file. Options setting commands placed there will thus be executed before each editor session. .SH Entering the editor .PP .Ex is entered by a command of the form .DS \fBex\fR [ \fB\-\fR ] [ \fB\-o\fR ] [ \fB\-n\fR ] [ \fB\-p\fR ] [ [ \fB\-r\fR ] \fIname\fR ... ] .DE Brackets here indicate optional arguments. The .B \- option suppresses all interactive-user feedback and is useful in processing editor scripts in command files. The .B \-p option suppresses the .I prompt . The .B \-n option is implied by the .B \- option and causes the editor to do no .B \&.exrc or terminal-type dependent start-up processing. The .B \-o option causes .EX to set the terminal type dependent options based on the characteristics of the diagnostic output if the standard output is not a terminal. Finally, the .B \-r option is used in recovering after an editor or system crash. See the section on crash recovery below. .SH File manipulation .PP .Ex is normally editing the contents of a single file, whose name is recorded in the .I current file name. .Ex performs all editing actions in a buffer (actually a temporary file) into which the text of the file is initially read. Changes made to the buffer have no effect on the file being edited unless and until the buffer contents are written out to the file with a .I write command. After the buffer contents are written, the previous contents of the written file are no longer accessible. .PP A file argument on the command line causes that file to be initially edited. Its name becomes the current file name, and its contents are read into the buffer. .SH Edited file notion .PP Most of the time the current file is considered to be .I edited . This means that the contents of the buffer are logically connected with the current file name, so that writing the current buffer contents onto that file, even if it exists, is a reasonable action. If the current file is not .I edited then .EX will not normally write on it if it already exists. This protects the user against accidental destruction of files. In all normal editing patterns, the current file is considered .I edited . .SH Alternate file .PP Each time a new value is given to the current file, the previous current file is saved as the .I alternate file. Similarly if a file is mentioned but does not become the current file, it is saved as the alternate file. The character `\(ga' substitutes for the alternate file in forming new filenames. This makes it easy to deal alternately with two files and eliminates the need for retyping the name supplied on an .I edit command after a ``No write since last change'' diagnostic is received. .SH Filename formation .PP Filenames within the editor may be specified using the normal .UX expansion conventions: `\*(**' matches any sequence of characters in a file name, `?' matches any single character, and `[\fIclass\fR]' matches the set of characters in the class, with single characters specifying themselves, and ranges of the form `a\-z' permitted, this example matching all letters.\u\s-2\(dg\s0\d .FS \(dg Note that an initial character `.' in a filename must always be specified explicitly, as must all `/'s in path names. .FE .PP In addition to these metacharacters, the character `%' in filenames is replaced by the .I current file name and the character `\`' by the .I alternate file name. If it is necessary for one of the characters `*', `?' `[' `%', `\`' or `\e' to appear in a filename, it may be escaped by preceding it with a `\e'. .SH Multiple files .PP If more than one file is given on the command line, then the first file is edited as described above. The remaining arguments are placed with the first file in the .I "argument list" . The current argument list may be displayed with the .I args command. The next file in the argument list may be edited with the .I next command. The argument list may also be respecified by specifying a list of names to the .I next command. These names are expanded, the resulting list of names becomes the new argument list, and .EX edits the first file on the list. .SH Errors .PP When errors occur .I ex normally rings the terminal bell and prints an error diagnostic. If the primary input is from a file, editor processing will terminate. .SH Interrupts .PP If .EX receives an interrupt signal (\s-2ASCII DEL\s0) it prints ``Interrupt'' and returns to its command level. If the primary input is a file, then .I ex will exit when this occurs. .SH Hangups .PP If a hangup signal is received and the buffer has been modified since it was last written out .EX attempts a .I preserve command. If this command fails then .EX will not unlink the editor buffer in the directory where it was being kept. In either case a .I recover command can be used to continue the work where it left off. .SH Crash recovery .PP If the editor or system crashes, or if the phone is hung up accidentally, then you should be able to recover the work you were doing, to within a few (maximum of 15) lines of changes of the place where you were. To recover a file you can use the .I recover command, or the .B \-r option, as in .DS .B "ex \-r resume" .DE if you were editing the file .I resume . In order to recover you must have had a current file name when the crash occurred, and respecify this name. After recovering the file you should check that it is indeed ok before writing it over its previous contents. If an error occurs during the recovery operation this means that the buffer was not in a consistent state at the time of the crash and that you will not be able to recover in this way.