BSD 1 development
[unix-history] / exrefm / exrefm2.n
CommitLineData
2fd0a8e1
BJ
1.if !\n(xx .so tmac.e
2.SH
3Initialization
4.PP
5When it is first invoked,
6.EX
7will use the home directory data base
8.I htmp
9to set the
10.I home
11directory option and to set the
12.I ttytype
13option, reflecting the kind of terminal in use.
14If there is a file
15.B \&.exrc
16in the user's home directory,
17then
18.EX
19will
20.I source
21to that file.
22Options setting commands placed there will thus be executed before
23each editor session.
24.SH
25Entering the editor
26.PP
27.Ex
28is entered by a command of the form
29.DS
30\fBex\fR [ \fB\-\fR ] [ \fB\-o\fR ] [ \fB\-n\fR ] [ \fB\-p\fR ] [ [ \fB\-r\fR ] \fIname\fR ... ]
31.DE
32Brackets here indicate optional arguments.
33The
34.B \-
35option suppresses all interactive-user feedback
36and is useful in processing editor scripts in command files.
37The
38.B \-p
39option suppresses the
40.I prompt .
41The
42.B \-n
43option is implied by the
44.B \-
45option and causes the editor to do no
46.B \&.exrc
47or terminal-type dependent start-up processing.
48The
49.B \-o
50option causes
51.EX
52to set the terminal type dependent options based on the
53characteristics of the diagnostic output if the standard
54output is not a terminal.
55Finally, the
56.B \-r
57option is used in recovering after an editor or system crash.
58See the section on crash recovery below.
59.SH
60File manipulation
61.PP
62.Ex
63is normally editing the contents of a single file,
64whose name is recorded in the
65.I current
66file name.
67.Ex
68performs all editing actions in a buffer
69(actually a temporary file)
70into which the text of the file is initially read.
71Changes made to the buffer have no effect on the file being
72edited unless and until the buffer contents are written out to the
73file with a
74.I write
75command.
76After the buffer contents are written,
77the previous contents of the written file are no longer accessible.
78.PP
79A file argument on the command line causes that file to be initially
80edited.
81Its name becomes the current file name,
82and its contents are read into the buffer.
83.SH
84Edited file notion
85.PP
86Most of the time the current file is considered to be
87.I edited .
88This means that the contents of the buffer are logically
89connected with the current file name,
90so that writing the current buffer contents onto that file,
91even if it exists,
92is a reasonable action.
93If the current file is not
94.I edited
95then
96.EX
97will not normally write on it if it already exists.
98This protects the user against accidental destruction of files.
99In all normal editing patterns,
100the current file is considered
101.I edited .
102.SH
103Alternate file
104.PP
105Each time a new value is given to the current file,
106the previous current file is saved as the
107.I alternate
108file.
109Similarly if a file is mentioned but does not become the current file,
110it is saved as the alternate file.
111The character `\(ga' substitutes for the alternate file in
112forming new filenames.
113This makes it easy to deal alternately with
114two files and eliminates the need for retyping the
115name supplied on an
116.I edit
117command after a ``No write since last change''
118diagnostic is received.
119.SH
120Filename formation
121.PP
122Filenames within the editor may be specified using the normal
123.UX
124expansion conventions:
125`\*(**' matches any sequence of characters in a file name,
126`?' matches any single character,
127and `[\fIclass\fR]' matches the set of characters in the class,
128with single characters specifying themselves, and ranges of the
129form `a\-z' permitted, this example matching all letters.\u\s-2\(dg\s0\d
130.FS
131\(dg Note that an initial character `.' in a filename must
132always be specified explicitly,
133as must all `/'s in path names.
134.FE
135.PP
136In addition to these metacharacters,
137the character `%' in filenames is replaced by the
138.I current
139file name and the character
140`\`' by the
141.I alternate
142file name.
143If it is necessary for one of the characters
144`*', `?' `[' `%', `\`' or `\e'
145to appear in a filename, it may be escaped by preceding it with a
146`\e'.
147.SH
148Multiple files
149.PP
150If more than one file is given on the command line,
151then the first file is edited as described above.
152The remaining arguments are placed with the first file in the
153.I "argument list" .
154The current argument list may be displayed with the
155.I args
156command.
157The next file in the argument list may be edited with the
158.I next
159command.
160The argument list may also be respecified by specifying
161a list of names to the
162.I next
163command.
164These names are expanded,
165the resulting list of names becomes the new argument list,
166and
167.EX
168edits the first file on the list.
169.SH
170Errors
171.PP
172When errors occur
173.I ex
174normally rings the terminal bell and prints an error diagnostic.
175If the primary input is from a file, editor processing will terminate.
176.SH
177Interrupts
178.PP
179If
180.EX
181receives an interrupt signal
182(\s-2ASCII DEL\s0)
183it prints ``Interrupt''
184and returns to its command level.
185If the primary input is a file, then
186.I ex
187will exit when this occurs.
188.SH
189Hangups
190.PP
191If a hangup signal is received and the buffer has been modified since
192it was last written out
193.EX
194attempts a
195.I preserve
196command.
197If this command fails then
198.EX
199will not unlink the editor buffer in the
200directory where it was being kept.
201In either case a
202.I recover
203command can be used to continue the work where it left off.
204.SH
205Crash recovery
206.PP
207If the editor or system crashes,
208or if the phone is hung up accidentally,
209then you should be able to recover
210the work you were doing, to within a few (maximum of 15) lines of
211changes of the place where you were.
212To recover a file you can use the
213.I recover
214command,
215or the
216.B \-r
217option, as in
218.DS
219.B "ex \-r resume"
220.DE
221if you were editing the file
222.I resume .
223In order to recover you must have had a current file name when
224the crash occurred, and respecify this name.
225After recovering the file you should check that it is indeed ok before
226writing it over its previous contents.
227If an error occurs during the recovery operation this means that
228the buffer was not in a consistent state at the time of the crash
229and that you will not be able to recover in this way.