Deleted Added
sdiff udiff text old ( 49 ) new ( 1057 )
full compact
1.TH ED 1 "21 May 1993"
2.SH NAME
3ed, red \- text editor
4.SH SYNOPSIS
5ed [-] [-sx] [-p \fIstring\fR] [\fIfile\fR]
6.LP
7red [-] [-sx] [-p \fIstring\fR] [\fIfile\fR]
8.SH DESCRIPTION

--- 120 unchanged lines hidden (view full) ---

129.IR sh (1).
130To read a file whose name begins with a bang, prefix the
131name with a backslash (\\).
132The default filename is set to
133.I file
134only if it is not prefixed with a bang.
135
136.SS LINE ADDRESSING
137An address represents the number of a line in the buffer.
138.B ed
139maintains a
140.I current address
141which is
142typically supplied to commands as the default address when none is specified.
143When a file is first read, the current address is set to the last line
144of the file. In general, the current address is set to the last line
145affected by a command.

--- 14 unchanged lines hidden (view full) ---

160address
161.I 0
162(zero).
163This means "before the first line,"
164and is legal wherever it makes sense.
165
166An address range is two addresses separated either by a comma or
167semi-colon. The value of the first address in a range cannot exceed the
168value of the the second. If only one address is given in a range, then
169the second address is set to the given address. If an
170.IR n- tuple
171of addresses is given where
172.I n > 2,
173then the corresponding range is determined by the last two addresses in
174the
175.IR n- tuple.
176If only one address is expected, then the last address is used.
177
178Each address in a comma-delimited range is interpreted relative to the
179current address. In a semi-colon-delimited range, the first address is
180used to set the current address, and the second address is interpreted
181relative to the first.
182
183
184The following address symbols are recognized.
185
186.TP 8
187\&.
188The current line (address) in the buffer.
189
190.TP 8
191$
192The last line in the buffer.
193
194.TP 8
195n

--- 311 unchanged lines hidden (view full) ---

507Any lines in the buffer are deleted before
508the new file is read.
509The current address is set to the last line read.
510
511.TP 8
512.RI e \ !command
513Edits the standard output of
514.IR `!command' ,
515(see
516.RI ! command
517below).
518The default filename is unchanged.
519Any lines in the buffer are deleted before the output of
520.I command
521is read.
522The current address is set to the last line read.
523
524.TP 8
525.RI E \ file

--- 101 unchanged lines hidden (view full) ---

627(i.e., a single quote followed by
628.I lc
629) in subsequent commands. The mark is not cleared until the line is
630deleted or otherwise modified.
631
632.TP 8
633(.,.)l
634Prints the addressed lines unambiguously.
635If a single line fills for than one screen (as might be the case
636when viewing a binary file, for instance), a `--More--'
637prompt is printed on the last line.
638.B ed
639waits until the RETURN key is pressed
640before displaying the next screen.
641The current address is set to the last line
642printed.
643
644.TP 8
645(.,.)m(.)
646Moves lines in the buffer. The addressed lines are moved to after the
647right-hand destination address, which may be the address
648.IR 0

--- 44 unchanged lines hidden (view full) ---

693The current address is set to the last line read.
694
695.TP 8
696.RI ($)r \ !command
697Reads
698to after the addressed line
699the standard output of
700.IR `!command' ,
701(see the
702.RI ! command
703below).
704The default filename is unchanged.
705The current address is set to the last line read.
706
707.HP
708.RI (.,.)s /re/replacement/
709.PD 0
710.HP
711.RI (.,.)s /re/replacement/\fRg\fR
712.HP
713.RI (.,.)s /re/replacement/n
714.br
715Replaces text in the addressed lines
716matching a regular expression
717.I re
718with
719.IR replacement .
720By default, only the first match in each line is replaced.
721If the
722.I `g'
723(global) suffix is given, then every match to be replaced.
724The
725.I `n'
726suffix, where
727.I n
728is a postive number, causes only the
729.IR n th
730match to be replaced.
731It is an error if no substitutions are performed on any of the addressed
732lines.
733The current address is set the last line affected.
734
735.I re
736and
737.I replacement
738may be delimited by any character other than space and newline
739(see the
740.I `s'
741command below).
742If one or two of the last delimiters is omitted, then the last line
743affected is printed as though the print suffix
744.I `p'
745were specified.
746
747
748An unescaped `&' in
749.I replacement

--- 14 unchanged lines hidden (view full) ---

764.I replacement
765if they are escaped with a backslash (\\).
766
767.TP 8
768(.,.)s
769Repeats the last substitution.
770This form of the
771.I `s'
772command accepts a count suffix
773.IR `n' ,
774or any combination of the characters
775.IR `r' ,
776.IR `g' ,
777and
778.IR `p' .
779If a count suffix
780.I `n'
781is given, then only the
782.IR n th
783match is replaced.
784The
785.I `r'
786suffix causes
787the regular expression of the last search to be used instead of the
788that of the last substitution.
789The
790.I `g'
791suffix toggles the global suffix of the last substitution.

--- 63 unchanged lines hidden (view full) ---

855and then executes a
856.I `q'
857command.
858
859.TP 8
860.RI (1,$)w \ !command
861Writes the addressed lines to the standard input of
862.IR `!command' ,
863(see the
864.RI ! command
865below).
866The default filename and current address are unchanged.
867
868.TP 8
869.RI (1,$)W \ file
870Appends the addressed lines to the end of
871.IR file .
872This is similar to the
873.I `w'

--- 34 unchanged lines hidden (view full) ---

908However, an unescaped
909.I `%'
910is replaced by the default filename.
911When the shell returns from execution, a `!'
912is printed to the standard output.
913The current line is unchanged.
914
915.TP 8
916($)=
917Prints the line number of the addressed line.
918
919.TP 8
920(.+1)newline
921Prints the addressed line, and sets the current address to
922that line.
923

--- 76 unchanged lines hidden ---