|
|
1.1 root 1: .\" Copyright (c) 1990 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)ed.1 6.5 (Berkeley) 7/24/90
6: .\"
7: .Dd July 24, 1990
8: .Dt ED 1
9: .Os ATT 7th
10: .if t .ds q \(aa
11: .if n .ds q '
12: .Sh NAME
13: .Nm ed
14: .Nd text editor
15: .Sh SYNOPSIS
16: .Nm ed
17: .Op Fl
18: .Op Fl x
19: .Op Ar file
20: .Sh DESCRIPTION
21: .Nm Ed
22: is the standard text editor.
23: .Pp
24: If a
25: .Ar file
26: argument is given,
27: .Nm ed
28: simulates an
29: .Ic e
30: command (see below) on the named file; that is to say,
31: the file is read into
32: .Nm ed 's
33: buffer so that it can be edited.
34: .Tw Ds
35: .Tp Fl x
36: An
37: .Ic x
38: command is simulated first to handle an encrypted file.
39: .Tp Fl
40: Suppresses the printing
41: of explanatory output
42: and should be used
43: when the standard input is
44: an editor script.
45: .Tp
46: .Pp
47: .Nm Ed
48: operates on a copy of any file it is editing; changes made
49: in the copy have no effect on the file until a
50: .Ic w
51: (write) command is given.
52: The copy of the text being edited resides
53: in a temporary file called the
54: .Ar buffer .
55: .Pp
56: Commands to
57: .Nm ed
58: have a simple and regular structure: zero or
59: more
60: .Ar addresses
61: followed by a single character
62: .Ar command ,
63: possibly
64: followed by parameters to the command.
65: These addresses specify one or more lines in the buffer.
66: Missing addresses are supplied by default.
67: .Pp
68: In general, only one command may appear on a line.
69: Certain commands allow the
70: addition of text to the buffer.
71: While
72: .Nm ed
73: is accepting text, it is said
74: to be in
75: .Ar input mode .
76: In this mode, no commands are recognized;
77: all input is merely collected.
78: Input mode is left by typing a period
79: .Sq Ic \&.
80: alone at the
81: beginning of a line.
82: .Pp
83: .Nm Ed
84: supports a limited form of
85: .Ar regular expression
86: notation.
87: A regular expression specifies
88: a set of strings of characters.
89: A member of this set of strings is said to be
90: .Ar matched
91: by the regular expression.
92: In the following specification for regular expressions
93: the word `character' means any character but newline.
94: .Tw Ds
95: .Tp 1.
96: Any character except a special character
97: matches itself.
98: Special characters are
99: the regular expression delimiter plus
100: .Sq Cm \e\[.
101: and sometimes
102: .Sq Cm ^*$ .
103: .Tp 2.
104: A
105: .Sq Cm \&.
106: matches any character.
107: .Tp 3.
108: A
109: .Sq Li \e
110: followed by any character except a digit or
111: .Li (\)
112: matches that character.
113: .Tp 4.
114: A nonempty string
115: .Op Ar s
116: or
117: .Oo
118: .Cx \&(
119: .Op Cm \&^ Ar s
120: .Cx \&)
121: .Cx
122: .Oo
123: matches any character in (or not in)
124: .Ar s .
125: In
126: .Ar s ,
127: .Sq Li \e
128: has no special meaning, and
129: may only appear as
130: the first letter.
131: A substring
132: .Ar a\-b ,
133: with
134: .Ar a
135: and
136: .Ar b
137: in ascending ASCII order, stands for the inclusive
138: range of ASCII characters.
139: .Tp 5.
140: A regular expression of form 1\-4 followed by * matches a sequence of
141: 0 or more matches of the regular expression.
142: .Tp 6.
143: A regular expression,
144: .Ar x ,
145: of form 1\-8, bracketed
146: .Cx Li \e(
147: .Ar x
148: .Li \e)
149: .Cx
150: matches what
151: .Ar x
152: matches.
153: .Tp 7.
154: A \e followed by a digit
155: .Ar n
156: matches a copy of the string that the
157: bracketed regular expression beginning with the
158: .Cx Ar n
159: .Cx \'th
160: .Cx
161: .Li \e(
162: matched.
163: .Tp 8.
164: A regular expression of form 1\-8,
165: .Ar x ,
166: followed by a regular expression of form 1\-7,
167: .Ar y
168: matches a match for
169: .Ar x
170: followed by a match for
171: .Ar y ,
172: with the
173: .Ar x
174: match being as long as possible while still permitting a
175: .Ar y
176: match.
177: .Tp 9.
178: A regular expression of form 1\-8 preceded by
179: .Sq Li ^
180: (or followed by
181: .Sq Li $ ) ,
182: is constrained to matches that
183: begin at the left (or end at the right) end of a line.
184: .Tp 10.
185: A regular expression of form 1\-9 picks out the
186: longest among the leftmost matches in a line.
187: .Tp 11.
188: An empty regular expression stands for a copy of the
189: last regular expression encountered.
190: .Tp
191: .Pp
192: Regular expressions are used in addresses to specify
193: lines and in one command
194: (see
195: .Ar s
196: below)
197: to specify a portion of a line which is to be replaced.
198: If it is desired to use one of
199: the regular expression metacharacters as an ordinary
200: character, that character may be preceded by
201: .Sq Li \e .
202: This also applies to the character bounding the regular
203: expression (often
204: .Sq Li \&/ )
205: and to
206: .Sq Li \e
207: itself.
208: .Pp
209: To understand addressing in
210: .Nm ed
211: it is necessary to know that at any time there is a
212: .Ar current line.
213: Generally speaking, the current line is
214: the last line affected by a command; however,
215: the exact effect on the current line
216: is discussed under the description of
217: the command.
218: Addresses are constructed as follows.
219: .Tw Ds
220: .Tp 1.
221: The character
222: .Sq Ic \&.
223: addresses the current line.
224: .Tp 2.
225: The character
226: .Cx `
227: .Ic $
228: .Cx \'
229: .Cx
230: addresses the last line of the buffer.
231: .Tp 3.
232: A decimal number
233: .Ar n
234: addresses the
235: .Cx Ar n
236: .Cx \'th
237: .Cx
238: line of the buffer.
239: .Tp 4.
240: .Cx `\(fm
241: .Ar x
242: .Cx \'
243: .Cx
244: addresses the line marked with the name
245: .Ar x ,
246: which must be a lower-case letter.
247: Lines are marked with the
248: .Ar k
249: command described below.
250: .Tp 5.
251: A regular expression enclosed in slashes
252: .Cx `
253: .Li /
254: .Cx \'
255: .Cx
256: addresses
257: the line found by searching forward from the current line
258: and stopping at the first line containing a
259: string that matches the regular expression.
260: If necessary the search wraps around to the beginning of the
261: buffer.
262: .Tp 6.
263: A regular expression enclosed in queries
264: .Cx `
265: .Li ?
266: .Cx \'
267: .Cx
268: addresses
269: the line found by searching backward from the current line
270: and stopping at the first line containing
271: a string that matches the regular expression.
272: If necessary
273: the search wraps around to the end of the buffer.
274: .Tp 7.
275: An address followed by a plus sign
276: .Cx `
277: .Li +
278: .Cx \'
279: .Cx
280: or a minus sign
281: .Cx `
282: .Li \-
283: .Cx \'
284: .Cx
285: followed by a decimal number specifies that address plus
286: (resp. minus) the indicated number of lines.
287: The plus sign may be omitted.
288: .Tp 8.
289: If an address begins with
290: .Cx `
291: .Li +
292: .Cx \'
293: .Cx
294: or
295: .Cx `
296: .Li \-
297: .Cx \'
298: .Cx
299: the addition or subtraction is taken with respect to the current line;
300: e.g.
301: .Cx `
302: .Li \-5
303: .Cx \'
304: .Cx
305: is understood to mean
306: .Cx `
307: .Li .\-5
308: .Cx \'
309: .Cx
310: .Nm .
311: .Tp 9.
312: If an address ends with
313: .Cx `
314: .Li +
315: .Cx \'
316: .Cx
317: .Cx `
318: .Li \-
319: .Cx \',
320: .Cx
321: then 1 is added (resp. subtracted).
322: As a consequence of this rule and rule 8,
323: the address
324: .Cx `
325: .Li \-
326: .Cx \'
327: .Cx
328: refers to the line before the current line.
329: Moreover,
330: trailing
331: .Cx `
332: .Li +
333: .Cx \'
334: .Cx
335: and
336: .Cx `
337: .Li \-
338: .Cx \'
339: .Cx
340: characters
341: have cumulative effect, so
342: .Cx `
343: .Li \-\-
344: .Cx \'
345: .Cx
346: refers to the current
347: line less 2.
348: .Tp 10.
349: To maintain compatibility with earlier versions of the editor,
350: the character
351: .Cx `
352: .Li ^
353: .Cx \'
354: .Cx
355: in addresses is
356: equivalent to
357: .Cx `
358: .Li \-
359: .Cx \'.
360: .Cx
361: .Tp
362: .Pp
363: Commands may require zero, one, or two addresses.
364: Commands which require no addresses regard the presence
365: of an address as an error.
366: Commands which accept one or two addresses
367: assume default addresses when insufficient are given.
368: If more addresses are given than such a command requires,
369: the last one or two (depending on what is accepted) are used.
370: .Pp
371: Addresses are separated from each other typically by a comma
372: .Cx `
373: .Li ,
374: .Cx \'
375: .Cx
376: They may also be separated by a semicolon
377: .Cx `
378: .Li ;
379: .Cx \'
380: .Cx
381: In this case the current line
382: .Cx `
383: .Li .
384: .Cx \'
385: .Cx
386: .Nm .
387: is set to
388: the previous address before the next address is interpreted.
389: This feature can be used to determine the starting
390: line for forward and backward searches
391: .Cx \&(`
392: .Li /
393: .Cx \'
394: .Cx
395: .Cx `
396: .Li ?
397: .Cx \').
398: .Cx
399: The second address of any two-address sequence
400: must correspond to a line following the line corresponding to the first address.
401: The special form
402: .Cx `
403: .Li \&%
404: .Cx \'
405: .Cx
406: is an abbreviation for the address pair
407: .Cx `
408: .Li 1,$
409: .Cx \'.
410: .Cx
411: .Pp
412: In the following list of
413: .Nm ed
414: commands, the default addresses
415: are shown in parentheses.
416: The parentheses are not part of
417: the address, but are used to show that the given addresses are
418: the default.
419: .Pp
420: As mentioned, it is generally illegal for more than one
421: command to appear on a line.
422: However, most commands may be suffixed by `p'
423: or by `l', in which case
424: the current line is either
425: printed or listed respectively
426: in the way discussed below.
427: Commands may also be suffixed by `n',
428: meaning the output of the command is to
429: be line numbered.
430: These suffixes may be combined in any order.
431: .Tw Ds
432: .Tp Cx \&(
433: .Ic .
434: .Cx \&)
435: .Ic a
436: .Cx
437: .Tp <text>
438: .Tp Ic \&.
439: The append command reads the given text
440: and appends it after the addressed line.
441: .Sq Ic \&.
442: is left
443: on the last line input, if there
444: were any, otherwise at the addressed line.
445: Address `0' is legal for this command; text is placed
446: at the beginning of the buffer.
447: .Tp Cx \&(
448: .Ic \&.
449: .Cx \&,
450: .Ic \&.
451: .Cx \&)
452: .Ic \&c
453: .Cx
454: .Tp <text>
455: .Tp Ic \&.
456: The change
457: command deletes the addressed lines, then accepts input
458: text which replaces these lines.
459: .Sq Ic \&.
460: is left at the last line input; if there were none,
461: it is left at the line preceding the deleted lines.
462: .Tp Cx \&(
463: .Ic \&.
464: .Cx \&,
465: .Ic \&.
466: .Cx \&)
467: .Ic \&d
468: .Cx
469: The delete command deletes the addressed lines from the buffer.
470: The line originally after the last line deleted becomes the current line;
471: if the lines deleted were originally at the end,
472: the new last line becomes the current line.
473: .Tp Cx Ic \&e
474: .Cx \&\ \&
475: .Ar filename
476: .Cx
477: The edit
478: command causes the entire contents of the buffer to be deleted,
479: and then the named file to be read in.
480: .Sq Ic \&.
481: is set to the last line of the buffer.
482: The number of characters read is typed.
483: .Ar filename
484: is remembered for possible use as a default file name
485: in a subsequent
486: .Ic r
487: or
488: .Ic w
489: command.
490: If
491: .Ar filename
492: is missing, the remembered name is used.
493: .Tp Cx Ic E
494: .Cx \&\ \&
495: .Ar filename
496: .Cx
497: This command is the same as
498: .Ic e ,
499: except that no diagnostic results when no
500: .Ic w
501: has been given since the last buffer alteration.
502: .Tp Cx Ic f
503: .Cx \&\ \&
504: .Ar filename
505: .Cx
506: The filename command prints the currently remembered file name.
507: If
508: .Ar filename
509: is given,
510: the currently remembered file name is changed to
511: .Ar filename .
512: .Tp Cx \&(
513: .Ic \&1
514: .Cx \&,
515: .Ic \&$
516: .Cx \&)
517: .Ic \&g
518: .Ar/regular expression/command list
519: .Cx
520: In the global
521: command, the first step is to mark every line which matches
522: the given regular expression.
523: Then for every such line, the
524: given command list is executed with
525: .Cx `
526: .Ic \&.
527: .Cx \'
528: .Cx
529: initially set to that line.
530: A single command or the first of multiple commands
531: appears on the same line with the global command.
532: All lines of a multi-line list except the last line must be ended with
533: .Cx `
534: .Ic \&\e
535: .Cx \'.
536: .Cx
537: .Ic A ,
538: .Ic i,
539: and
540: .Ic c
541: commands and associated input are permitted;
542: the
543: .Cx `
544: .Ic \&.
545: .Cx \'
546: .Cx
547: terminating input mode may be omitted if it would be on the
548: last line of the command list.
549: The commands
550: .Ic g
551: and
552: .Ic v
553: are not permitted in the command list.
554: .Tp Cx \&(
555: .Ic .
556: .Cx \&)
557: .Ic i
558: .Cx
559: .Tp <text>
560: .Tp Ic \&.
561: This command inserts the given text before the addressed line.
562: .Cx `
563: .Ic \&.
564: .Cx \'
565: .Cx
566: is left at the last line input, or, if there were none,
567: at the line before the addressed line.
568: This command differs from the
569: .Ic a
570: command only in the placement of the
571: text.
572: .Tp Cx \&(
573: .Ic \&.
574: .Cx \&,
575: .Ic \&.+1
576: .Cx \&)
577: .Ic \&j
578: .Cx
579: This command joins the addressed lines into a single line;
580: intermediate newlines simply disappear.
581: .Cx `
582: .Ic \&.
583: .Cx \'
584: .Cx
585: is left at the resulting line.
586: .Tp Cx \&(
587: .Ic .
588: .Cx \&)
589: .Ic k
590: .Ar x
591: .Cx
592: The mark command marks the addressed line with
593: name
594: .Ar x ,
595: which must be a lower-case letter.
596: The address form
597: .Cx `\(fm
598: .Ar x
599: .Cx \'
600: .Cx
601: then addresses this line.
602: .Tp Cx \&(
603: .Ic \&.
604: .Cx \&,
605: .Ic \&.
606: .Cx \&)
607: .Ic \&l
608: .Cx
609: The list command
610: prints the addressed lines in an unambiguous way:
611: non-graphic characters are
612: printed in two-digit octal,
613: and long lines are folded.
614: The
615: .Ar l
616: command may be placed on the same line after any non-i/o
617: command.
618: .Tp Cx \&(
619: .Ic \&.
620: .Cx \&,
621: .Ic \&.
622: .Cx \&)
623: .Ic \&m
624: .Ar a
625: .Cx
626: The move command repositions the addressed lines after the line
627: addressed by
628: .Ar a .
629: The last of the moved lines becomes the current line.
630: .Tp Cx \&(
631: .Ic \&.
632: .Cx \&,
633: .Ic \&.
634: .Cx \&)
635: .Ic \&p
636: .Cx
637: The print command prints the addressed lines.
638: .Cx `
639: .Ic \&.
640: .Cx \'
641: .Cx
642: is left at the last line printed.
643: The
644: .Ic p
645: command
646: may
647: be placed on the same line after any non-i/o command.
648: .Tp Cx \&(
649: .Ic \&.
650: .Cx \&,
651: .Ic \&.
652: .Cx \&)
653: .Ic \&P
654: .Cx
655: This command is a synonym for
656: .Ic p .
657: .Tp Ic q
658: The quit command causes
659: .Nm ed
660: to exit.
661: No automatic write
662: of a file is done.
663: .Tp Ic Q
664: This command is the same as
665: .Ic q ,
666: except that no diagnostic results when no
667: .Ic w
668: has been given since the last buffer alteration.
669: .Tp Cx \&(
670: .Ic $
671: .Cx \&)
672: .Ic r
673: .Cx \&\ \&
674: .Ar filename
675: .Cx
676: The read command
677: reads in the given file after the addressed line.
678: If no file name is given,
679: the remembered file name, if any, is used
680: (see
681: .Ic e
682: and
683: .Ic f
684: commands).
685: The file name is remembered if there was no
686: remembered file name already.
687: Address `0' is legal for
688: .Ic r
689: and causes the
690: file to be read at the beginning of the buffer.
691: If the read is successful, the number of characters
692: read is typed.
693: .Cx `
694: .Ic \&.
695: .Cx \'
696: .Cx
697: is left at the last line read in from the file.
698: .Tp Cx \&(
699: .Ic \&.
700: .Cx \&,
701: .Ic \&.
702: .Cx \&)
703: .Ic \&s
704: .Ar/regular expression/replacement/
705: .Cx \&\tor
706: .Cx
707: .Tp Cx \&(
708: .Ic \&.
709: .Cx \&,
710: .Ic \&.
711: .Cx \&)
712: .Ic \&s
713: .Ar/regular expression/replacement/
714: .Ic \&g
715: .Cx
716: The substitute command searches each addressed
717: line for an occurrence of the specified regular expression.
718: On each line in which a match is found,
719: all matched strings are replaced by the replacement specified,
720: if the global replacement indicator
721: .Ic \&g
722: appears after the command.
723: If the global indicator does not appear, only the first occurrence
724: of the matched string is replaced.
725: It is an error for the substitution to fail on all addressed lines.
726: Any punctuation character
727: may be used instead of
728: .Cx `
729: .Ic \&/
730: .Cx \'
731: .Cx
732: to delimit the regular expression
733: and the replacement.
734: .Cx `
735: .Ic \&.
736: .Cx \'
737: .Cx
738: is left at the last line substituted.
739: An ampersand
740: .Cx `
741: .Ic \&&
742: .Cx \'
743: .Cx
744: appearing in the replacement
745: is replaced by the string matching the regular expression.
746: The special meaning of
747: .Cx `
748: .Ic \&&
749: .Cx \'
750: .Cx
751: in this context may be
752: suppressed by preceding it by
753: .Cx `
754: .Ic \&\e
755: .Cx \'.
756: .Cx
757: The characters
758: .Cx `
759: .Ic \&\e
760: .Ar n
761: .Cx \'
762: .Cx
763: where
764: .Ar n
765: is a digit,
766: are replaced by the text matched by the
767: .Cx Ar n
768: .Cx \'th
769: .Cx
770: regular subexpression
771: enclosed between
772: .Cx `
773: .Ic \&\e\&(
774: .Cx \'.
775: .Cx
776: and
777: .Cx `
778: .Ic \&\e\&)
779: .Cx \'.
780: .Cx
781: When
782: nested, parenthesized subexpressions
783: are present,
784: .Ar n
785: is determined by counting occurrences of
786: .Cx `
787: .Ic \&\e\&(
788: .Cx \'.
789: .Cx
790: starting from the left.
791: Lines may be split by substituting new-line characters into them.
792: The new-line in the
793: replacement string
794: must be escaped by preceding it by
795: .Cx `
796: .Ic \&\e
797: .Cx \'.
798: .Cx
799: One or two trailing delimiters may be omitted,
800: implying the
801: .Ic p
802: suffix.
803: The special form
804: .Ic s
805: followed by
806: .Ar no
807: delimiters
808: repeats the most recent substitute command
809: on the addressed lines.
810: The
811: .Ic s
812: may be followed by the letters
813: .Ic r
814: (use the most recent regular expression for the
815: left hand side, instead of the most recent
816: left hand side of a substitute command),
817: .Ic p
818: (complement the setting of the
819: .Ic p
820: suffix from the previous substitution), or
821: .Ic g
822: (complement the setting of the
823: .Ic g
824: suffix).
825: These letters may be combined in any order.
826: .Tp Cx \&(
827: .Ic \&.
828: .Cx \&,
829: .Ic \&.
830: .Cx \&)
831: .Ic \&t
832: .Ar a
833: .Cx
834: This command acts just like the
835: .Ic m
836: command, except that a copy of the addressed lines is placed
837: after address
838: .Ad a
839: (which may be 0).
840: .Cx `
841: .Ic \&.
842: .Cx \'
843: .Cx
844: is left on the last line of the copy.
845: .Tp Cx \&(
846: .Ic \&.
847: .Cx \&,
848: .Ic \&.
849: .Cx \&)
850: .Ic \&u
851: .Cx
852: The undo command restores the buffer to it's state
853: before the most recent buffer modifying command.
854: The current line is also restored.
855: Buffer modifying commands are
856: .Ic a , c , d , g , i , k , m , r , s , t ,
857: and
858: .Ic v .
859: For purposes of undo,
860: .Ic g
861: and
862: .Ic v
863: are considered to be a single buffer modifying command.
864: Undo is its own inverse.
865: When
866: .Nm ed
867: runs out of memory
868: (at about 8000 lines on any 16 bit mini-computer
869: such as the PDP-11)
870: This full undo is not possible, and
871: .Ic u
872: can only undo the effect of the most recent
873: substitute on the current line.
874: This restricted undo also applies to editor scripts
875: when
876: .Nm ed
877: is invoked with the
878: .Fl
879: option.
880: .Tp Cx \&(
881: .Ic \&1
882: .Cx \&,
883: .Ic \&$
884: .Cx \&)
885: .Ic \&v
886: .Ar/regular expression/command list
887: .Cx
888: This command is the same as the global command
889: .Ic g
890: except that the command list is executed
891: .Ic g
892: with
893: .Cx `
894: .Ic \&.
895: .Cx \'
896: .Cx
897: initially set to every line
898: .Em except
899: those
900: matching the regular expression.
901: (1, $)\w filename
902: .Tp Cx \&(
903: .Ic \&1
904: .Cx \&,
905: .Ic \&$
906: .Cx \&)
907: .Ic \&w
908: .Cx \&\ \&
909: .Ar filename
910: .Cx
911: The write command writes the addressed lines onto
912: the given file.
913: If the file does not exist,
914: it is created.
915: The file name is remembered if there was no
916: remembered file name already.
917: If no file name is given,
918: the remembered file name, if any, is used
919: (see
920: .Ic e
921: and
922: .Ic f
923: commands).
924: .Cx `
925: .Ic \&.
926: .Cx \'
927: .Cx
928: is unchanged.
929: If the command is successful, the number of characters written is
930: printed.
931: .Tp Cx \&(
932: .Ic \&1
933: .Cx \&,
934: .Ic \&$
935: .Cx \&)
936: .Ic \&W
937: .Cx \&\ \&
938: .Ar filename
939: .Cx
940: This command is the same as
941: .Ic w ,
942: except that the addressed lines are appended to the file.
943: .Tp Cx \&(
944: .Ic \&1
945: .Cx \&,
946: .Ic \&$
947: .Cx \&)
948: .Ic \&wq
949: .Cx \&\ \&
950: .Ar filename
951: .Cx
952: This command is the same as
953: .Ic w
954: except that afterwards a
955: .Ic q
956: command is done,
957: exiting the editor
958: after the file is written.
959: .Tp x
960: A key string is demanded from the standard input.
961: Later
962: .Ic r , e
963: and
964: .Ic w
965: commands will encrypt and decrypt the text
966: with this key by the algorithm of
967: .Xr crypt 1 .
968: An explicitly empty key turns off encryption.
969: .Ic \&1
970: .Ic \&+1
971: .Cx \&)
972: .Ic \&z
973: .Cx \&\ \ \&or,
974: .Cx
975: .Tp Cx \&(
976: .Ic \&1
977: .Ic \&+1
978: .Cx \&)
979: .Ic \&z
980: .Ar n
981: .Cx
982: This command scrolls through the buffer starting at the addressed line.
983: 22 (or
984: .Ar n ,
985: if given)
986: lines are printed.
987: The last line printed becomes the current line.
988: The value
989: .Ar n
990: is sticky, in that it becomes the default for
991: future
992: .Ic z
993: commands.
994: .Tp Cx \&(
995: .Ic \&$
996: .Cx \&)
997: .Ic \&=
998: .Cx
999: The line number of the addressed line is typed.
1000: .Cx `
1001: .Ic \&.
1002: .Cx \'
1003: .Cx
1004: is unchanged by this command.
1005: .Tp Cx Ic \&!
1006: .Cx <shell\ command>
1007: .Cx
1008: The remainder of the line after the `!' is sent
1009: to
1010: .Xr sh 1
1011: to be interpreted as a command.
1012: .Cx `
1013: .Ic \&.
1014: .Cx \'
1015: .Cx
1016: is unchanged.
1017: .Tp Cx \&(
1018: .Ic \&.+1
1019: .Cx \&,
1020: .Ic \&.+1
1021: .Cx \&)
1022: .Cx <newline>
1023: .Cx
1024: An address alone on a line causes the addressed line to be printed.
1025: A blank line alone is equivalent to
1026: .Ic .+1
1027: it is useful
1028: for stepping through text.
1029: If two addresses are present with no
1030: intervening semicolon,
1031: .Nm ed
1032: prints the range of lines.
1033: If they are separated by a semicolon,
1034: the second line is printed.
1035: .Tp
1036: .Pp
1037: If an interrupt signal (ASCII DEL) is sent,
1038: .Nm ed
1039: prints
1040: .Sq Li ?interrupted
1041: and returns to its command level.
1042: .Pp
1043: Some size limitations:
1044: 512 characters per line,
1045: 256 characters per global command list,
1046: 64 characters per file name,
1047: and, on mini computers,
1048: 128K characters in the temporary file.
1049: The limit on the number of lines depends on the amount of core:
1050: each line takes 2 words.
1051: .Pp
1052: When reading a file,
1053: .Nm ed
1054: discards ASCII NUL characters
1055: and all characters after the last newline.
1056: It refuses to read files containing non-ASCII characters.
1057: .Sh FILES
1058: .Dw edhup
1059: .Di L
1060: .Dp Pa /tmp/e*
1061: .Dp Pa edhup
1062: work is saved here if terminal hangs up
1063: .Dp
1064: .Sh SEE ALSO
1065: .Xr ex 1 ,
1066: .Xr sed 1 ,
1067: .Xr crypt 1
1068: .br
1069: B. W. Kernighan,
1070: .Em A Tutorial Introduction to the ED Text Editor
1071: .br
1072: B. W. Kernighan,
1073: .Em Ar Advanced editing on UNIX
1074: .Sh HISTORY
1075: The
1076: .Nm ed
1077: command appeared in Version 6 AT&T UNIX.
1078: .Sh DIAGNOSTICS
1079: .Sq Li name
1080: for inaccessible file;
1081: .Sq Li ?self-explanatory message
1082: for other errors.
1083: .Pp
1084: To protect against throwing away valuable work,
1085: a
1086: .Ic q
1087: or
1088: .Ic e
1089: command is considered to be in error, unless a
1090: .Ic w
1091: has occurred since the last buffer change.
1092: A second
1093: .Ic q
1094: or
1095: .Ic e
1096: will be obeyed regardless.
1097: .Sh BUGS
1098: The
1099: .Ic l
1100: command mishandles
1101: .Li DEL .
1102: .br
1103: The
1104: .Ic undo
1105: command causes marks to be lost on affected lines.
1106: .br
1107: The
1108: .Ic x
1109: command,
1110: .Fl x
1111: option,
1112: and
1113: special treatment of hangups
1114: only work on UNIX.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.