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