heirloom-ed

view ed.1 @ 3:ac52712b2b5e

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