heirloom-ed
view ed.1 @ 1:db609ba8ab93
Added tag 0.1 for changeset 1493bea5ac22
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Mon, 05 Sep 2011 16:36:26 +0200 |
parents | |
children | a09d0630f05b |
line source
1 '\" t
2 .\" Sccsid @(#)ed.1 1.48 (gritter) 6/22/05
3 .\" Parts taken from ed(1), Unix 7th edition:
4 .\" Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" Redistributions of source code and documentation must retain the
10 .\" above copyright notice, this list of conditions and the following
11 .\" disclaimer.
12 .\" Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed or owned by Caldera
18 .\" International, Inc.
19 .\" Neither the name of Caldera International, Inc. nor the names of
20 .\" other contributors may be used to endorse or promote products
21 .\" derived from this software without specific prior written permission.
22 .\"
23 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
24 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
25 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
28 .\" LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
34 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 .TH ED 1 "6/22/05" "Heirloom Toolchest" "User Commands"
36 .if t .ds q \(aa
37 .if n .ds q '
38 .SH NAME
39 ed \- text editor
40 .SH SYNOPSIS
41 \fBed\fR [\fB\-\fR\ |\ \fB\-s\fR] [\fB\-p\fI\ prompt\fR] [\fIname\fR]
42 .SH DESCRIPTION
43 .I Ed
44 is the standard text editor.
45 .PP
46 If a
47 .I name
48 argument is given,
49 .I ed
50 simulates an
51 .I e
52 command (see below)\| on the named file; that is to say,
53 the file is read into
54 .IR ed 's
55 buffer so that it can be edited.
56 The optional
57 .B \-
58 or
59 .B \-s
60 suppresses the printing
61 of character counts by
62 .IR e ,
63 .IR r ,
64 and
65 .I w
66 commands,
67 and of the `!' after completion of a shell command.
68 .PP
69 With the
70 .B \-p
71 option,
72 the given
73 .I prompt
74 string is printed before each command is read.
75 .PP
76 .I Ed
77 operates on a copy of any file it is editing; changes made
78 in the copy have no effect on the file until a
79 .IR w ""
80 (write)\|
81 command is given.
82 The copy of the text being edited resides
83 in a temporary file called the
84 .IR buffer .
85 .PP
86 The editor supports format specifications as defined in
87 .IR fspec (5).
88 If the terminal is configured to expand tabulators
89 (as enabled with
90 .I stty tab3
91 or
92 .IR "stty \-tabs"),
93 and the first line of the file being edited
94 contains a format specification,
95 the
96 .I t
97 and
98 .I s
99 are interpreted,
100 that is, tabulators are expanded and lines are truncated
101 when printing to the terminal. For example,
102 .RS
103 <:t\-f s72:>
104 .sp
105 .RE
106 selects FORTRAN format and truncates lines at 72 characters.
107 No expansion or truncation is performed by
108 .I ed
109 when input is typed to the terminal.
110 .PP
111 Commands to
112 .I ed
113 have a simple and regular structure: zero or
114 more
115 .I addresses
116 followed by a single character
117 .I command,
118 possibly
119 followed by parameters to the command.
120 These addresses specify one or more lines in the buffer.
121 Missing addresses are supplied by default.
122 .PP
123 In general, only one command may appear on a line.
124 Certain commands allow the
125 addition of text to the buffer.
126 While
127 .I ed
128 is accepting text, it is said
129 to be in
130 .I "input mode."
131 In this mode, no commands are recognized;
132 all input is merely collected.
133 Input mode is left by typing a period `\fB.\fR' alone at the
134 beginning of a line.
135 .PP
136 .I Ed
137 supports a limited form of
138 .I "regular expression"
139 notation.
140 A regular expression specifies
141 a set of strings of characters.
142 A member of this set of strings is said to be
143 .I matched
144 by the regular expression.
145 In the following specification for regular expressions
146 the word `character' means any character but newline.
147 .B ed
148 uses simple regular expressions.
149 .SS "Simple Regular Expressions"
150 .IP 1.
151 Any character except a special character
152 matches itself.
153 Special characters are
154 the regular expression delimiter plus
155 .RB \e\|[\| .
156 and sometimes ^\|*\|$.
157 .IP 2.
158 A
159 .B .\&
160 matches any character.
161 .IP 3.
162 A \fB\e\fR followed by any character except a digit
163 or (\|) {\|} <\|> matches that character.
164 .IP 4.
165 A nonempty string
166 .I s
167 bracketed
168 \fB[\fI\|s\|\fB]\fR
169 (or
170 \fB[^\fIs\|\fB]\fR)
171 forms a \fIbracket expression\fR that
172 matches any character in (or not in)
173 .I s.
174 In
175 .I s,
176 \e has no special meaning, and ] may only appear as
177 the first letter.
178 A substring
179 \fIa\fB\-\fIb\fR,
180 with
181 .I a
182 and
183 .I b
184 in ascending ASCII order, stands for the inclusive
185 range of ASCII characters.
186 .IP 5.
187 A regular expression of form 1-4 followed by \fB*\fR matches a sequence of
188 0 or more matches of the regular expression.
189 .IP 6.
190 A regular expression of form 1-4
191 followed by \fB\e{\fIm\fB,\fIn\fB\e}\fR
192 forms an \fIinterval expression\fR that
193 matches a sequence of \fIm\fR through \fIn\fR matches, inclusive,
194 of the regular expression.
195 The values of \fIm\fR and \fIn\fR must be non-negative
196 and smaller than 256.
197 The form \fB\e{\fIm\fB\e}\fR matches exactly \fIm\fR occurrences,
198 \fB\e{\fIm\fB,\e}\fR matches at least \fIm\fR occurrences.
199 .IP 7.
200 The sequence \fB\e<\fR forces the match
201 to occur only at the beginning of a ``variable'' or ``word'';
202 that is, either at the beginning of a line,
203 or just before a letter, digit or underline
204 and after a character not one of these.
205 .IP 8.
206 The sequence \fB\e>\fR matches the end
207 of a ``variable'' or ``word'',
208 i.\|e. either the end of the line
209 or before character which is neither a letter,
210 nor a digit, nor the underline character.
211 .IP 9.
212 A regular expression,
213 .I x,
214 of form 1-11, parenthesized
215 \fB\e(\fI\|x\|\fB\e)\fR
216 is called a \fIsubexpression\fR and
217 matches what
218 .I x
219 matches.
220 .IP 10.
221 A \fB\e\fR followed by a digit
222 .I n
223 forms a \fIbackreference\fR and
224 matches a copy of the string that the
225 parenthesized regular expression beginning with the
226 .IR n th
227 \e( matched.
228 .IP 11.
229 A regular expression of form 1-11,
230 .I x,
231 followed by a regular expression of form 1-10,
232 .I y
233 matches a match for
234 .I x
235 followed by a match for
236 .I y,
237 with the
238 .I x
239 match being as long as possible while still permitting a
240 .I y
241 match.
242 .IP 12.
243 A regular expression of form 1-11 preceded by \fB^\fR
244 (or followed by \fB$\fR), is constrained to matches that
245 begin at the left (or end at the right) end of a line
246 (\fIanchoring\fR).
247 .IP 13.
248 A regular expression of form 1-12 picks out the
249 longest among the leftmost matches in a line.
250 .IP 14.
251 An empty regular expression stands for a copy of the
252 last regular expression encountered.
253 .PP
254 Regular expressions are used in addresses to specify
255 lines and in one command
256 (see
257 .I s
258 below)\|
259 to specify a portion of a line which is to be replaced.
260 If it is desired to use one of
261 the regular expression metacharacters as an ordinary
262 character, that character may be preceded by `\e'.
263 This also applies to the character bounding the regular
264 expression (often `/')\| and to `\e' itself.
265 .PP
266 To understand addressing in
267 .I ed
268 it is necessary to know that at any time there is a
269 .I "current line."
270 Generally speaking, the current line is
271 the last line affected by a command; however,
272 the exact effect on the current line
273 is discussed under the description of
274 the command.
275 Addresses are constructed as follows.
276 .TP
277 1.
278 The character `\fB.\fR' addresses the current line.
279 .TP
280 2.
281 The character `\fB$\fR' addresses the last line of the buffer.
282 .TP
283 3.
284 A decimal number
285 .I n
286 addresses the
287 .IR n -th
288 line of the buffer.
289 .TP
290 4.
291 `\fB\(fm\fIx\fR' addresses the line marked with the name
292 .IR x ,
293 which must be a lower-case letter.
294 Lines are marked with the
295 .I k
296 command described below.
297 .TP
298 5.
299 A regular expression enclosed in slashes `\fB/\fR' addresses
300 the line found by searching forward from the current line
301 and stopping at the first line containing a
302 string that matches the regular expression.
303 If necessary the search wraps around to the beginning of the
304 buffer.
305 .TP
306 6.
307 A regular expression enclosed in queries `\fB?\fR' addresses
308 the line found by searching backward from the current line
309 and stopping at the first line containing
310 a string that matches the regular expression.
311 If necessary
312 the search wraps around to the end of the buffer.
313 .TP
314 7.
315 An address followed by a plus sign `\fB+\fR'
316 or a minus sign `\fB\-\fR' followed by a decimal number
317 specifies that address plus
318 (resp. minus)\| the indicated number of lines.
319 The plus sign may be omitted.
320 .TP
321 8.
322 If an address begins with `\fB+\fR' or `\fB\-\fR'
323 the addition or subtraction is taken with respect to the current line;
324 e.g. `\-5' is understood to mean `\fB.\fR\-5'.
325 .TP
326 9.
327 If an address ends with `\fB+\fR' or `\fB\-\fR',
328 then 1 is added (resp. subtracted).
329 As a consequence of this rule and rule 8,
330 the address `\-' refers to the line before the current line.
331 Moreover,
332 trailing
333 `+' and `\-' characters
334 have cumulative effect, so `\-\-' refers to the current
335 line less 2.
336 .TP
337 10.
338 To maintain compatibility with earlier versions of the editor,
339 the character `\fB^\fR' in addresses is
340 equivalent to `\-'.
341 .PP
342 Commands may require zero, one, or two addresses.
343 Commands which require no addresses regard the presence
344 of an address as an error.
345 Commands which accept one or two addresses
346 assume default addresses when insufficient are given.
347 If more addresses are given than such a command requires,
348 the last one or two (depending on what is accepted)\| are used.
349 .PP
350 Addresses are separated from each other typically by a comma
351 `\fB,\fR'.
352 They may also be separated by a semicolon
353 `\fB;\fR'.
354 In this case the current line `\fB.\fR' is set to
355 the previous address before the next address is interpreted.
356 This feature can be used to determine the starting
357 line for forward and backward searches (`/', `?')\|.
358 The second address of any two-address sequence
359 must correspond to a line following the line corresponding to the first address.
360 .PP
361 Omission of the first address causes
362 the first line to be used with `,',
363 or the current line with `;', respectively;
364 if the second address is also omitted,
365 the last line of the buffer is used.
366 Thus a single `,' specifies the entire contents of the buffer,
367 and a single `;' specifies the contents
368 ranging from the current line to the last one.
369 .PP
370 In the following list of
371 .I ed
372 commands, the default addresses
373 are shown in parentheses.
374 The parentheses are not part of
375 the address, but are used to show that the given addresses are
376 the default.
377 .PP
378 As mentioned, it is generally illegal for more than one
379 command to appear on a line.
380 However, most commands may be suffixed by `p', `l', or `n',
381 in which case
382 the current line is either
383 printed, listed, or numbered respectively
384 in the way discussed below.
385 .TP 5
386 \fR(\|\fI.\|\fR)\fB\|a\fR
387 .br
388 .ns
389 .TP 5
390 <text>
391 .br
392 .ns
393 .TP 5
394 .B .
395 .br
396 The append command reads the given text
397 and appends it after the addressed line.
398 `\fB.\fR' is left
399 on the last line input, if there
400 were any, otherwise at the addressed line.
401 Address `0' is legal for this command; text is placed
402 at the beginning of the buffer.
403 .TP 5
404 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBc\fR
405 .br
406 .ns
407 .TP 5
408 <text>
409 .br
410 .ns
411 .TP 5
412 .B .
413 .br
414 The change
415 command deletes the addressed lines, then accepts input
416 text which replaces these lines.
417 `\fB.\fR' is left at the last line input; if there were none,
418 it is left at the line preceding the deleted lines.
419 .TP 5
420 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBd\fR
421 The delete command deletes the addressed lines from the buffer.
422 The line originally after the last line deleted becomes the current line;
423 if the lines deleted were originally at the end,
424 the new last line becomes the current line.
425 .TP 5
426 \fBe\ \fIfilename\fR
427 The edit
428 command causes the entire contents of the buffer to be deleted,
429 and then the named file to be read in.
430 `\fB.\fR' is set to the last line of the buffer.
431 The number of characters read is typed.
432 `\fIfilename\fR' is remembered for possible use as a default file name
433 in a subsequent
434 .I r
435 or
436 .I w
437 command.
438 If `\fIfilename\fR' is missing, the remembered name is used.
439 A `\fIfilename\fR' starting with a `\fB!\fR'
440 causes the output of the shell command following this character
441 to be read in.
442 .TP 5
443 \fBE\ \fIfilename\fR
444 This command is the same as
445 .IR e ,
446 except that no diagnostic results when no
447 .I w
448 has been given since the last buffer alteration.
449 .TP 5
450 \fBf\ \fIfilename\fR
451 The filename command prints the currently remembered file name.
452 If `\fIfilename\fR' is given,
453 the currently remembered file name is changed to `\fIfilename\fR'.
454 .TP 5
455 \fR(\fI1\fB,\fI$\fR)\|\fBg/\fIregular expression\fB/\fIcommand list\fR
456 In the global
457 command, the first step is to mark every line which matches
458 the given \fIregular expression\fR.
459 Then for every such line, the
460 given \fIcommand list\fR is executed
461 with `\fB.\fR' initially set to that line.
462 A single command or the first of multiple commands
463 appears on the same line with the global command.
464 All lines of a multi-line list except the last line must be ended with `\e'.
465 .I A,
466 .I i,
467 and
468 .I c
469 commands and associated input are permitted;
470 the `\fB.\fR' terminating input mode may be omitted if it would be on the
471 last line of the command list.
472 The commands
473 .I g
474 and
475 .I v
476 are not permitted in the command list.
477 .TP 5
478 \fR(\fI1\fB,\fI$\fR)\|\fBG/\fIregular expression\fB/\fR
479 The interactive global command
480 first marks every line matching the given \fIregular expression\fR.
481 Then each line is printed
482 and a command is read and executed for this line.
483 A single newline character causes the line to remain unchanged,
484 an isolated `\fB&\fR' repeats the command given for the previous line.
485 The command can be terminated by an interrupt signal.
486 .TP 5
487 .B h
488 This command prints a verbose description for the
489 last error encountered.
490 .TP
491 .B H
492 This command acts like the
493 .I h
494 command,
495 but also causes verbose descriptions to be printed
496 on all following error conditions.
497 Another
498 .I H
499 turns verbose mode off.
500 .TP 5
501 \fR(\|\fI.\|\fR)\|\fBi\fR
502 .br
503 .ns
504 .TP 5
505 <text>
506 .br
507 .ns
508 .TP 5
509 .B .
510 .br
511 This command inserts the given text before the addressed line.
512 `\fB.\fR' is left at the last line input, or, if there were none,
513 at the line before the addressed line.
514 This command differs from the
515 .I a
516 command only in the placement of the
517 text.
518 .TP 5
519 \fR(\|\fI.\|\fB,\|\fI.+1\fR)\|\fBj\fR
520 This command joins the addressed lines into a single line;
521 intermediate newlines simply disappear.
522 `\fB.\fR' is left at the resulting line.
523 .TP 5
524 \fR(\fI.\fR)\|\fBk\fIx\fR
525 The mark command marks the addressed line with
526 name
527 .IR x ,
528 which must be a lower-case letter.
529 The address form `\(fm\fIx\fR' then addresses this line.
530 .ne 2.5
531 .TP 5
532 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBl\fR
533 The list command
534 prints the addressed lines in an unambiguous way:
535 non-graphic control characters are printed in three-digit octal;
536 Long lines are folded.
537 The
538 .I l
539 command may be placed on the same line after any non-i/o
540 command.
541 .TP 5
542 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBm\fIa\fR
543 The move command repositions the addressed lines after the line
544 addressed by
545 .IR a .
546 The last of the moved lines becomes the current line.
547 .TP 5
548 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBn\fR
549 This command prints lines preceded by their line numbers.
550 It otherwise acts like the
551 .I p
552 command described below.
553 .TP 5
554 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBp\fR
555 The print command prints the addressed lines.
556 `\fB.\fR'
557 is left at the last line printed.
558 The
559 .I p
560 command
561 may
562 be placed on the same line after any non-i/o command.
563 .TP
564 .B P
565 This command causes a prompt to be printed
566 before following commands are read.
567 The default prompt is a `*' character,
568 but can be set with the
569 .I \-p
570 command line option (which also enables the prompt).
571 Another
572 .I P
573 disables the prompt.
574 .TP 5
575 .B q
576 The quit command causes
577 .I ed
578 to exit.
579 No automatic write
580 of a file is done.
581 .TP 5
582 .B Q
583 This command is the same as
584 .I q,
585 except that no diagnostic results when no
586 .I w
587 has been given since the last buffer alteration.
588 .TP 5
589 \fR(\fI$\fR)\|\fBr\ \fIfilename\fR
590 The read command
591 reads in the given file after the addressed line.
592 If no file name is given,
593 the remembered file name, if any, is used
594 (see
595 .I e
596 and
597 .I f
598 commands)\|.
599 The file name is remembered if there was no
600 remembered file name already.
601 Address `0' is legal for
602 .I r
603 and causes the
604 file to be read at the beginning of the buffer.
605 If the read is successful, the number of characters
606 read is typed.
607 `\fB.\fR' is left at the last line read in from the file.
608 A `filename' starting with a `\fB!\fR'
609 causes the output of the shell command following this character
610 to be read in.
611 .TP 5
612 \fR(\|\fI.\fB\|,\|\fI.\fR\|)\|\fBs/\fIregular expression\fB/\fIreplacement\fB/\fR or,
613 .br
614 .ns
615 .TP 5
616 \fR(\|\fI.\fB\|,\|\fI.\fR\|)\|\fBs/\fIregular expression\fB/\fIreplacement\fB/g\fR or,
617 .br
618 .ns
619 .TP 5
620 \fR(\|\fI.\fB\|,\|\fI.\fR\|)\|\fBs/\fIregular expression\fB/\fIreplacement\fB/\fInumber\fR
621 The substitute command searches each addressed
622 line for an occurrence of the specified regular expression.
623 On each line in which a match is found,
624 all matched strings are replaced by the replacement specified,
625 if the global replacement indicator
626 .RB ` g '
627 appears after the command.
628 If the global indicator does not appear, only the first occurrence
629 of the matched string is replaced;
630 if the \fInumber\fR indicator is given,
631 the numbered occurrence is replaced.
632 It is an error for the substitution to fail on all addressed lines.
633 Any character other than space or new-line
634 may be used instead of `/' to delimit the regular expression
635 and the replacement.
636 `\fB.\fR' is left at the last line substituted.
637 .IP
638 An ampersand
639 .RB ` & '
640 appearing in the replacement
641 is replaced by the string matching the regular expression.
642 The special meaning of `&' in this context may be
643 suppressed by preceding it by
644 .RB ` \e '.
645 The characters `\|\fB\e\fIn\fR'
646 where
647 .I n
648 is a digit,
649 are replaced by the text matched by the
650 .IR n -th
651 regular subexpression
652 enclosed between `\e(' and `\e)'.
653 When
654 nested, parenthesized subexpressions
655 are present,
656 .I n
657 is determined by counting occurrences of `\e(' starting from the left.
658 .IP
659 A substitution string consisting of a single
660 .RB ` % '
661 causes the string given on the previous substitution to be re-used.
662 .IP
663 Lines may be split by substituting new-line characters into them.
664 The new-line in the
665 replacement string
666 must be escaped by preceding it by
667 .RB ` \e '.
668 .TP 5
669 \fR(\|\fI.\|\fB,\|\fI.\|\fR)\|\fBt\|\fIa\fR
670 This command acts just like the
671 .I m
672 command, except that a copy of the addressed lines is placed
673 after address
674 .I a
675 (which may be 0).
676 `\fB.\fR' is left on the last line of the copy.
677 .TP 5
678 .B u
679 The undo command restores
680 the contents of the buffer
681 before the last command was executed.
682 If the undo command is given twice,
683 the current state is restored.
684 .TP 5
685 \fR(\fI1\fB,\fI$\fR)\|\fBv/\fIregular expression\fB/\fIcommand list\fR
686 This command is the same as the global command
687 .I g
688 except that the command list is executed
689 .I g
690 with `\fB.\fR' initially set to every line
691 .I except
692 those
693 matching the regular expression.
694 .TP 5
695 \fR(\fI1\fB,\fI$\fR)\|\fBV/\fIregular expression\fB/\fR
696 This command is the same as the interactive global command
697 .I G
698 except that the commands are read
699 .I g
700 with `\fB.\fR' initially set to every line
701 .I except
702 those
703 matching the regular expression.
704 .TP 5
705 \fR(\fI1\fB,\fI$\fR)\|\fBw\ \fIfilename\fR
706 .br
707 The write command writes the addressed lines onto
708 the given file.
709 If the file does not exist,
710 it is created mode 666 (readable and writable by everyone)\|.
711 The file name is remembered if there was no
712 remembered file name already.
713 If no file name is given,
714 the remembered file name, if any, is used
715 (see
716 .I e
717 and
718 .I f
719 commands)\|.
720 `\fB.\fR' is unchanged.
721 If the command is successful, the number of characters written is
722 printed.
723 A `filename' starting with a `\fB!\fR'
724 causes the string following this character
725 to be executed as a shell command
726 with the addressed lines as standard input.
727 .TP
728 \fR(\fI1\fB,\fI$\fR)\fBW\ \fIfilename\fR
729 This command is the same as
730 .I w,
731 except that the addressed lines are appended to the file.
732 .TP 5
733 \fR(\fI$\fR)\|\fB=\fR
734 The line number of the addressed line is typed.
735 `\fB.\fR' is unchanged by this command.
736 .TP 5
737 \fB!\fR<shell command>
738 The remainder of the line after the `!' is sent
739 to
740 .IR sh (1)
741 to be interpreted as a command.
742 .RB ` . '
743 is unchanged.
744 If the command starts with a
745 .RB ` ! ',
746 the previous command is inserted.
747 A
748 .RB ` % '
749 causes the current file name to be inserted.
750 .TP 5
751 \fR(\|\fI.+1\fR)\|<newline>
752 An address alone on a line causes the addressed line to be printed.
753 A blank line alone is equivalent to `.+1p'; it is useful
754 for stepping through text.
755 .PP
756 The following commands are extensions:
757 .TP 5
758 \fR(\|\fI.\|\fR)\fB\|b\fR[\fIcount\fR]
759 Prints a screenful of lines,
760 starting at the addressed one,
761 and browses forward in the buffer by this amount.
762 With the optional
763 .I count
764 argument, the screen size for this and following
765 .I b
766 commands is set to the given number of lines.
767 .TP 5
768 .B help
769 Causes a summary of
770 .I ed
771 commands along with short descriptions
772 to be printed on the terminal.
773 .TP 5
774 .B N
775 Makes the
776 .I p
777 command behave like the
778 .I n
779 command and vice-versa.
780 If given a second time,
781 the original semantics are restored.
782 .TP 5
783 \fR(\|\fI.\|\fR)\fB\|o\fR[\fIcount\fR]
784 Prints a screenful of lines centered around the addressed one.
785 The current line is not changed.
786 With the optional
787 .I count
788 argument, the amount of lines printed above and below
789 for this and following
790 .I o
791 commands is set to the given number.
792 .TP 5
793 .B z
794 Performs the same actions as a
795 .I w
796 command followed by a
797 .I q
798 command.
799 .PP
800 If an interrupt signal is sent,
801 .I ed
802 prints a `?' and returns to its command level.
803 .PP
804 An input line that consists exactly of the two characters `\e.'
805 causes a period `.' to be inserted with the
806 .IR a ,
807 .IR c ,
808 and
809 .IR i
810 commands.
811 .PP
812 Some size limitations:
813 The maximum number of bytes in the buffer
814 corresponds to the address size;
815 on machines with 32-bit addressing,
816 it is 2\ G bytes,
817 with 64-bit addressing,
818 it is 9\ E bytes.
819 The limit on the number of lines depends on the amount of core:
820 each line takes 2 words.
821 .PP
822 If a line contains a NUL character,
823 regular expressions cannot match beyond this character.
824 A substitute command deletes a NUL
825 and all following characters on the line.
826 NUL characters in command input are discarded.
827 If an input file does not end with a newline,
828 .I ed
829 prints a message and appends one.
830 .PP
831 Omission of the `/' character
832 following the regular expression or the replacement string
833 to the global and substitute commands
834 causes the affected lines to be printed.
835 Thus the following commands have the same effect:
836 .RS
837 g/pattern g/pattern/p
838 .br
839 s/pattern/repl s/pattern/repl/p
840 .br
841 s/pattern/ s/pattern//p
842 .RE
843 .SH "ENVIRONMENT VARIABLES"
844 .TP
845 .BR LANG ", " LC_ALL
846 See
847 .IR locale (7).
848 .TP
849 .B LC_CTYPE
850 Determines the mapping of bytes to characters
851 and the set of printable characters for the
852 .I l
853 command.
854 .TP
855 .B TMPDIR
856 Determines the location of the temporary file
857 if it contains the name of an accessible directory.
858 .SH FILES
859 /var/tmp/e*
860 .br
861 /tmp/e*
862 .br
863 ed.hup: work is saved here if terminal hangs up
864 .SH "SEE ALSO"
865 B. W. Kernighan,
866 .I
867 A Tutorial Introduction to the ED Text Editor
868 .br
869 B. W. Kernighan,
870 .I Advanced editing on UNIX
871 .br
872 bfs(1),
873 grep(1),
874 sed(1),
875 sh(1)
876 .SH DIAGNOSTICS
877 `?name' for inaccessible file;
878 `?' for
879 errors in commands,
880 possibly followed by a verbose description
881 (see the description for the
882 .I h
883 and
884 .I H
885 commands above).
886 .PP
887 To protect against throwing away valuable work,
888 a
889 .I q
890 or
891 .I e
892 command is considered to be in error, unless a
893 .I w
894 has occurred since the last buffer change.
895 A second
896 .I q
897 or
898 .I e
899 will be obeyed regardless.
900 .SH NOTES
901 A
902 .I !\&
903 command cannot be subject to a
904 .I g
905 command.
906 .PP
907 The LC_COLLATE variable has currently no effect.
908 Ranges in bracket expressions are ordered
909 as byte values in single-byte locales
910 and as wide character values in multibyte locales.
911 .PP
912 For portable programs, restrict textual data
913 to the US-ASCII character set and
914 set the LC_CTYPE and LC_COLLATE variables to `C' or `POSIX'.