Commit | Line | Data |
---|---|---|
b0a60d57 KT |
1 | .th ED I 1/15/73 |
2 | .if t .ds q \(aa | |
3 | .if n .ds q ' | |
4 | .sh NAME | |
5 | ed \*- editor | |
6 | .sh SYNOPSIS | |
7 | .bd ed | |
8 | [ | |
9 | .bd \*- | |
10 | ] [ name ] | |
11 | .sh DESCRIPTION | |
12 | .it Ed | |
13 | is the standard text editor. | |
14 | .s3 | |
15 | If a | |
16 | .it name | |
17 | argument is given, | |
18 | .it ed | |
19 | simulates an | |
20 | .it e | |
21 | command (see below)\| on the named file; that is to say, | |
22 | the file is read into | |
23 | .it ed's | |
24 | buffer so that it can be edited. | |
25 | The optional | |
26 | .bd \*- | |
27 | simulates an | |
28 | .bd os | |
29 | command (see below)\| | |
30 | which suppresses the printing | |
31 | of characters counts by | |
32 | .it e, | |
33 | .it r, | |
34 | and | |
35 | .it w | |
36 | commands. | |
37 | .s is suppressed. | |
38 | .s3 | |
39 | .it Ed | |
40 | operates on a copy of any file it is editing; changes made | |
41 | in the copy have no effect on the file until a \fIw\fR (write)\| | |
42 | command is given. | |
43 | The copy of the text being edited resides | |
44 | in a temporary file called the | |
45 | .it buffer. | |
46 | There is only | |
47 | one buffer. | |
48 | .s3 | |
49 | Commands to | |
50 | .it ed | |
51 | have a simple and regular structure: zero or | |
52 | more | |
53 | .it addresses | |
54 | followed by a single character | |
55 | .it command, | |
56 | possibly | |
57 | followed by parameters to the command. | |
58 | These addresses specify one or more lines in the buffer. | |
59 | Every command which requires addresses has default addresses, | |
60 | so that the addresses can often be omitted. | |
61 | .s3 | |
62 | In general, only one command may appear on a line. | |
63 | Certain commands allow the input of text. | |
64 | This text is placed in the appropriate place in the buffer. | |
65 | While | |
66 | .it ed | |
67 | is accepting text, it is said | |
68 | to be in | |
69 | \fIinput mode.\fR | |
70 | In this mode, no commands are recognized; | |
71 | all input is merely collected. | |
72 | Input mode is left by typing a period `\fB.\fR' alone at the | |
73 | beginning of a line. | |
74 | .s3 | |
75 | .it Ed | |
76 | supports a limited form of | |
77 | .it "regular expression" | |
78 | notation. | |
79 | A regular expression is an expression which specifies | |
80 | a set of strings of characters. | |
81 | A member of this set of strings is said to be | |
82 | .it matched | |
83 | by the regular expression. | |
84 | The regular expressions allowed by | |
85 | .it ed | |
86 | are constructed as follows: | |
87 | .s3 | |
88 | .lp +6 3 | |
89 | 1. An ordinary character (not one of those discussed below)\| | |
90 | is a regular expression and matches that character. | |
91 | .s3 | |
92 | .lp +6 3 | |
93 | 2. A circumflex `^' at the beginning of a regular expression | |
94 | matches the null character at the beginning of a line. | |
95 | .s3 | |
96 | .lp +6 3 | |
97 | 3. A currency symbol `$' at the end of a regular expression | |
98 | matches the null character at the end of a line. | |
99 | .s3 | |
100 | .lp +6 3 | |
101 | 4. A period `\fB.\fR' matches any character but a new-line character. | |
102 | .s3 | |
103 | .lp +6 3 | |
104 | 5. A regular expression followed by an asterisk `*' | |
105 | matches any number of adjacent occurrences (including zero)\| | |
106 | of the regular expression it follows. | |
107 | .s3 | |
108 | .lp +6 3 | |
109 | 6. A string of characters enclosed in square brackets | |
110 | `[ ]' matches any character in the string but no others. | |
111 | If, however, the first character of the string is a circumflex | |
112 | `^' the regular expression matches any character but new-line | |
113 | and the characters in the string. | |
114 | .s3 | |
115 | .lp +6 3 | |
116 | 7. The concatenation of regular expressions is a regular | |
117 | expression which matches the concatenation of the strings | |
118 | matched by the components of the regular expression. | |
119 | .s3 | |
120 | .lp +6 3 | |
121 | 8. The null regular expression standing alone | |
122 | is equivalent to the last regular expression encountered. | |
123 | .s3 | |
124 | .i0 | |
125 | Regular expressions are used in addresses to specify | |
126 | lines and in one command | |
127 | (see | |
128 | .it s | |
129 | below)\| | |
130 | to specify a portion of a line which is to be replaced. | |
131 | .s3 | |
132 | If it is desired to use one of | |
133 | the regular expression metacharacters as an ordinary | |
134 | character, that character may be preceded by `\\'. | |
135 | This also applies to the character bounding the regular | |
136 | expression (often `/')\| and to `\\' itself. | |
137 | .s3 | |
138 | Addresses are constructed as follows. | |
139 | To understand addressing in | |
140 | .it ed | |
141 | it is necessary to know that at any time there is a | |
142 | \fIcurrent line.\fR | |
143 | Generally speaking, the current line is | |
144 | the last line affected by a command; however, | |
145 | the exact effect on the current line | |
146 | by each command is discussed under the description of | |
147 | the command. | |
148 | .s3 | |
149 | .lp +6 3 | |
150 | 1. The character `\fB.\fR' addresses the current line. | |
151 | .s3 | |
152 | .lp +6 3 | |
153 | 2. The character `^' addresses the line immediately before the current line. | |
154 | .s3 | |
155 | .lp +6 3 | |
156 | 3. The character `$' addresses the last line of the buffer. | |
157 | .s3 | |
158 | .lp +6 3 | |
159 | 4. A decimal number | |
160 | .it n | |
161 | addresses the | |
162 | \fIn\fR-th | |
163 | line of the buffer. | |
164 | .s3 | |
165 | .lp +6 3 | |
166 | 5. `\*q\fIx\fR' addresses the line associated (marked)\| with the | |
167 | mark name character \fIx\fR | |
168 | which must be a printable character. | |
169 | Lines are marked with the | |
170 | .it k | |
171 | command described below. | |
172 | .s3 | |
173 | .lp +6 3 | |
174 | 6. A regular expression enclosed in slashes `/' addresses | |
175 | the first line found by searching toward the end of the | |
176 | buffer and stopping at the first line containing a | |
177 | string matching the regular expression. | |
178 | If necessary the search wraps around to the beginning of the | |
179 | buffer. | |
180 | .s3 | |
181 | .lp +6 3 | |
182 | 7. A regular expression enclosed in queries `?' addresses | |
183 | the first line found by searching toward the beginning of | |
184 | the buffer and stopping at the first line found containing | |
185 | a string matching the regular expression. | |
186 | If necessary | |
187 | the search wraps around to the end of the buffer. | |
188 | .s3 | |
189 | .lp +6 3 | |
190 | 8. An address followed by a plus sign `+' | |
191 | or a minus sign `\*-' followed by a decimal number specifies that address plus | |
192 | (resp. minus)\| the indicated number of lines. | |
193 | The plus sign may be omitted. | |
194 | .s3 | |
195 | .i0 | |
196 | Commands may require zero, one, or two addresses. | |
197 | Commands which require no addresses regard the presence | |
198 | of an address as an error. | |
199 | Commands which accept one or two addresses | |
200 | assume default addresses when insufficient are given. | |
201 | If more addresses are given than such a command requires, | |
202 | the last one or two (depending on what is accepted)\| are used. | |
203 | .s3 | |
204 | Addresses are separated from each other typically by a comma | |
205 | `\fB,\fR'. | |
206 | They may also be separated by a semicolon | |
207 | `\fB;\fR'. | |
208 | In this case the current line `\fB.\fR' is set to | |
209 | the previous address before the next address is interpreted. | |
210 | This feature can be used to determine the starting | |
211 | line for forward and backward searches (`/', `?')\|. | |
212 | The second address of any two-address sequence | |
213 | must correspond to a line following the line corresponding to the first address. | |
214 | .s3 | |
215 | In the following list of | |
216 | .it ed | |
217 | commands, the default addresses | |
218 | are shown in parentheses. | |
219 | The parentheses are not part of | |
220 | the address, but are used to show that the given addresses are | |
221 | the default. | |
222 | .s3 | |
223 | As mentioned, it is generally illegal for more than one | |
224 | command to appear on a line. | |
225 | However, any command may be suffixed by `p' (for `print')\|. | |
226 | In that case, the current line is printed after the command | |
227 | is complete. | |
228 | .ne 6 | |
229 | .s3 | |
230 | .lp +10 5 | |
231 | ( \fB. \fR)\|a | |
232 | .lp +10 5 | |
233 | <text> | |
234 | .lp +10 5 | |
235 | .li | |
236 | \fB.\fR | |
237 | .lp +10 5 | |
238 | The append command reads the given text | |
239 | and appends it after the addressed line. | |
240 | `\fB.\fR' is left | |
241 | on the last line input, if there | |
242 | were any, otherwise at the addressed line. | |
243 | Address `0' is legal for this command; text is placed | |
244 | at the beginning of the buffer. | |
245 | .s3 | |
246 | .lp +10 5 | |
247 | ( \fB. \fR, \fB. \fR)\|c | |
248 | .lp +10 5 | |
249 | <text> | |
250 | .lp +10 5 | |
251 | .li | |
252 | \fB.\fR | |
253 | .lp +10 5 | |
254 | The change | |
255 | command deletes the addressed lines, then accepts input | |
256 | text which replaces these lines. | |
257 | `\fB.\fR' is left at the last line input; if there were none, | |
258 | it is left at the first line not changed. | |
259 | .s3 | |
260 | .lp +10 5 | |
261 | ( \fB. \fR, \fB. \fR)\| d | |
262 | .br | |
263 | The delete command deletes the addressed lines from the buffer. | |
264 | The line originally after the last line deleted becomes the current line; | |
265 | if the lines deleted were originally at the end, | |
266 | the new last line becomes the current line. | |
267 | .s3 | |
268 | .lp +10 5 | |
269 | e filename | |
270 | .br | |
271 | The edit | |
272 | command causes the entire contents of the buffer to be deleted, | |
273 | and then the named file to be read in. | |
274 | `\fB.\fR' is set to the last line of the buffer. | |
275 | The number of characters read is typed. | |
276 | `filename' is remembered for possible use as a default file name | |
277 | in a subsequent | |
278 | .it r | |
279 | or | |
280 | .it w | |
281 | command. | |
282 | .s3 | |
283 | .lp +10 5 | |
284 | f filename | |
285 | .br | |
286 | The filename command prints the currently remembered file name. | |
287 | If `filename' is given, | |
288 | the currently remembered file name is changed to `filename'. | |
289 | .s3 | |
290 | .lp +10 5 | |
291 | (1,$)\|g/regular expression/command list | |
292 | .br | |
293 | In the global | |
294 | command, the first step is to mark every line which matches | |
295 | the given regular expression. | |
296 | Then for every such line, the | |
297 | given command list is executed with `\fB.\fR' initially set to that line. | |
298 | A single command or the first of multiple commands | |
299 | appears on the same line with the global command. | |
300 | All lines of a multi-line list except the last line must be ended with `\\'. | |
301 | .it A, | |
302 | .it i, | |
303 | and | |
304 | .it c | |
305 | commands and associated input are permitted; | |
306 | the `\fB.\fR' terminating input mode may be omitted if it would be on the | |
307 | last line of the command list. | |
308 | The (global)\| commands, | |
309 | .it g, | |
310 | and | |
311 | .it v, | |
312 | are not permitted in the command list. | |
313 | .s3 | |
314 | .lp +10 5 | |
315 | ( \fB. \fR)\|i | |
316 | .lp +10 5 | |
317 | <text> | |
318 | .lp +10 5 | |
319 | .li | |
320 | \1f. | |
321 | .br | |
322 | This command inserts the given text before the addressed line. | |
323 | `\fB.\fR' is left at the last line input; if there were none, | |
324 | at the addressed line. | |
325 | This command differs from the | |
326 | .it a | |
327 | command only in the placement of the | |
328 | text. | |
329 | .s3 | |
330 | .lp +10 5 | |
331 | ( \fB. \fR)\|k\fIx\fR | |
332 | .br | |
333 | The mark command associates or marks the addressed line with | |
334 | the single character mark name | |
335 | .it x. | |
336 | The ten most recent mark names are remembered. | |
337 | The current mark names may be printed with the | |
338 | .it n | |
339 | command. | |
340 | .s3 | |
341 | .lp +10 5 | |
342 | ( \fB. \fR, \fB. \fR)\|m\fIa\fR | |
343 | .br | |
344 | The move command will reposition the addressed lines after the line | |
345 | addressed by | |
346 | .it a. | |
347 | The last of the moved lines becomes the current line. | |
348 | .s3 | |
349 | .lp +10 5 | |
350 | n | |
351 | .br | |
352 | The \fIn\fR command will print the current mark names. | |
353 | .s3 | |
354 | .lp +10 5 | |
355 | os | |
356 | .lp +10 5 | |
357 | ov | |
358 | .br | |
359 | After | |
360 | .it os | |
361 | character counts printed by | |
362 | .it "e, r," | |
363 | and | |
364 | .it w | |
365 | are suppressed. | |
366 | .it Ov | |
367 | turns them back on. | |
368 | .s3 | |
369 | .lp +10 5 | |
370 | ( \fB. \fR, \fB. \fR)\|p | |
371 | .br | |
372 | The print command prints the addressed lines. | |
373 | `\fB.\fR' | |
374 | is left at the last line printed. | |
375 | The | |
376 | .it p | |
377 | command | |
378 | .it may | |
379 | be placed on the same line after any command. | |
380 | .s3 | |
381 | .lp +10 5 | |
382 | q | |
383 | .br | |
384 | The quit command causes | |
385 | .it ed | |
386 | to exit. | |
387 | No automatic write | |
388 | of a file is done. | |
389 | .s3 | |
390 | .lp +10 5 | |
391 | ($)\|r filename | |
392 | .br | |
393 | The read command | |
394 | reads in the given file after the addressed line. | |
395 | If no file name is given, | |
396 | the remembered file name, if any, is used | |
397 | (see | |
398 | .it e | |
399 | and | |
400 | .it f | |
401 | commands)\|. | |
402 | The remembered file name is not changed unless | |
403 | `filename' is the very first file name | |
404 | mentioned. | |
405 | Address `0' is legal for | |
406 | .it r | |
407 | and causes the | |
408 | file to be read at the beginning of the buffer. | |
409 | If the read is successful, the number of characters | |
410 | read is typed. | |
411 | `\fB.\fR' is left at the last line read in from the file. | |
412 | .s3 | |
413 | .lp +10 5 | |
414 | ( \fB. \fR, \fB. \fR)\|s/regular expression/replacement/ or, | |
415 | .lp +10 5 | |
416 | ( \fB. \fR, \fB. \fR)\|s/regular expression/replacement/g | |
417 | .br | |
418 | The substitute command searches each addressed | |
419 | line for an occurrence of the specified regular expression. | |
420 | On each line in which a match is found, | |
421 | all matched strings are replaced by the replacement specified, | |
422 | if the global replacement indicator `g' appears after the command. | |
423 | If the global indicator does not appear, only the first occurrence | |
424 | of the matched string is replaced. | |
425 | It is an error for the substitution to fail on all addressed lines. | |
426 | Any character other than space or new-line | |
427 | may be used instead of `/' to delimit the regular expression | |
428 | and the replacement. | |
429 | `\fB.\fR' is left at the last line substituted. | |
430 | .s3 | |
431 | An ampersand `&' appearing in the replacement | |
432 | is replaced by the regular expression that was matched. | |
433 | The special meaning of `&' in this context may be | |
434 | suppressed by preceding it by `\\'. | |
435 | .s3 | |
436 | .lp +10 5 | |
437 | (1,$)\|v/regular expression/command list | |
438 | .br | |
439 | This command is the same as the global command | |
440 | except that the command list is executed | |
441 | with `\fB.\fR' initially set to every line | |
442 | .it except | |
443 | those | |
444 | matching the regular expression. | |
445 | .s3 | |
446 | .lp +10 5 | |
447 | (1,$)\|w filename | |
448 | .br | |
449 | The write command writes the addressed lines onto | |
450 | the given file. | |
451 | If the file does not exist, | |
452 | it is created mode 666 (readable and writeable by everyone)\|. | |
453 | The remembered file name is | |
454 | .it not | |
455 | changed unless | |
456 | `filename' is the very first file name mentioned. | |
457 | If no file name is given, | |
458 | the remembered file name, if any, is used | |
459 | (see | |
460 | .it e | |
461 | and | |
462 | .it f | |
463 | commands)\|. | |
464 | `\fB.\fR' is unchanged. | |
465 | If the command is successful, the number of characters written is | |
466 | typed. | |
467 | .s3 | |
468 | .lp +10 5 | |
469 | ($)\|= | |
470 | .br | |
471 | The line number of the addressed line is typed. | |
472 | `\fB.\fR' is unchanged by this command. | |
473 | .s3 | |
474 | .lp +10 5 | |
475 | !UNIX command | |
476 | .br | |
477 | The remainder of the line after the `!' is sent | |
478 | to UNIX to be interpreted as a command. | |
479 | `\fB.\fR' is unchanged. | |
480 | The entire shell syntax is not | |
481 | recognized. | |
482 | See msh(VII) for the restrictions. | |
483 | .s3 | |
484 | .lp +10 5 | |
485 | ( \fB.\fR+1 )\|<newline> | |
486 | .br | |
487 | An address alone on a line causes the addressed line to be printed. | |
488 | A blank line alone is equivalent to `.+1p'; it is useful | |
489 | for stepping through text. | |
490 | .s3 | |
491 | .i0 | |
492 | If an interrupt signal (ASCII DEL)\| is sent, | |
493 | .it ed | |
494 | will print a `?' and return to its command level. | |
495 | .s3 | |
496 | If invoked with the command name `\*-', | |
497 | (see init(VII)\|)\| | |
498 | .it ed | |
499 | will sign on with the message `Editing system' | |
500 | and print `*' as the command level prompt character. | |
501 | .s3 | |
502 | .it Ed | |
503 | has size limitations on the maximum number of lines that can be edited, | |
504 | on the maximum number of characters in a line, | |
505 | in a global's command list, | |
506 | in a remembered file name, | |
507 | and in the size of the temporary file. | |
508 | The current sizes are: | |
509 | 4000 lines per file, | |
510 | 512 characters per line, | |
511 | 256 characters per global command list, | |
512 | 64 characters per file name, | |
513 | and 64K characters in the temporary file (see BUGS)\|. | |
514 | .sh FILES | |
515 | /tmp/etm?, temporary | |
516 | .br | |
517 | /etc/msh, to implement the `!' command. | |
518 | .sh DIAGNOSTICS | |
519 | `?' for | |
520 | errors in commands; | |
521 | `TMP' for temporary file overflow. | |
522 | .sh BUGS | |
523 | The temporary file can grow to no more than 64K bytes. |