add .Vx so tmac.andoc will call tmac.mdoc-old
[unix-history] / usr / src / bin / ed / ed.1
index 6cca59b..48c0ac1 100644 (file)
-.\"    @(#)ed.1        6.1 (Berkeley) %G%
+.\" Copyright (c) 1990 Regents of the University of California.
+.\" All rights reserved.  The Berkeley software License Agreement
+.\" specifies the terms and conditions for redistribution.
 .\"
 .\"
-.TH ED 1 ""
-.AT 3
-.if t .ds q \(aa
-.if n .ds q '
-.SH NAME
-ed \- text editor
-.SH SYNOPSIS
-.B ed
-[
-.B \-
-] [
-.B \-x
-] [ name ]
-.SH DESCRIPTION
-.I Ed
+.\"     @(#)ed.1       6.6 (Berkeley) %G%
+.\"
+.Vx
+.Dd 
+.Dt ED 1
+.Os ATT 7th
+.Sh NAME
+.Nm ed
+.Nd text editor
+.Sh SYNOPSIS
+.Nm ed
+.Op Fl
+.Op Ar file
+.Sh DESCRIPTION
+.Nm Ed
 is the standard text editor.
 is the standard text editor.
-.PP
+.Pp
 If a
 If a
-.I name
+.Ar file
 argument is given,
 argument is given,
-.I ed
+.Nm ed
 simulates an
 simulates an
-.I e
-command (see below)\| on the named file; that is to say,
+.Ic e
+command (see below) on the named file; that is to say,
 the file is read into
 the file is read into
-.I ed's
+.Nm ed 's
 buffer so that it can be edited.
 buffer so that it can be edited.
-If 
-.B \-x
-is present, an
-.I x
-command is simulated first to handle an encrypted file.
-The optional
-.B \-
-suppresses the printing
+.Tw Ds
+.Tp Fl
+Suppresses the printing
 of explanatory output
 and should be used
 when the standard input is
 an editor script.
 of explanatory output
 and should be used
 when the standard input is
 an editor script.
-.PP
-.I Ed
+.Tp
+.Pp
+.Nm Ed
 operates on a copy of any file it is editing; changes made
 in the copy have no effect on the file until a
 operates on a copy of any file it is editing; changes made
 in the copy have no effect on the file until a
-.IR w ""
-(write)\|
-command is given.
+.Ic w
+(write) command is given.
 The copy of the text being edited resides
 The copy of the text being edited resides
-in a temporary file called the 
-.IR buffer .
-.PP
+in a temporary file called the
+.Ar buffer  .
+.Pp
 Commands to
 Commands to
-.I ed
+.Nm ed
 have a simple and regular structure: zero or
 more
 have a simple and regular structure: zero or
 more
-.I addresses
+.Ar addresses
 followed by a single character
 followed by a single character
-.I command,
+.Ar command ,
 possibly
 followed by parameters to the command.
 These addresses specify one or more lines in the buffer.
 Missing addresses are supplied by default.
 possibly
 followed by parameters to the command.
 These addresses specify one or more lines in the buffer.
 Missing addresses are supplied by default.
-.PP
+.Pp
 In general, only one command may appear on a line.
 In general, only one command may appear on a line.
-Certain commands allow the 
+Certain commands allow the
 addition of text to the buffer.
 While
 addition of text to the buffer.
 While
-.I ed
+.Nm ed
 is accepting text, it is said
 to be in
 is accepting text, it is said
 to be in
-.I  "input mode."
+.Ar input mode .
 In this mode, no commands are recognized;
 all input is merely collected.
 In this mode, no commands are recognized;
 all input is merely collected.
-Input mode is left by typing a period `\fB.\fR' alone at the
+Input mode is left by typing a period
+.Sq Ic \&.
+alone at the
 beginning of a line.
 beginning of a line.
-.PP
-.I Ed
+.Pp
+.Nm Ed
 supports a limited form of
 supports a limited form of
-.I "regular expression"
+.Ar regular expression
 notation.
 A regular expression specifies
 a set of strings of characters.
 A member of this set of strings is said to be
 notation.
 A regular expression specifies
 a set of strings of characters.
 A member of this set of strings is said to be
-.I matched
+.Ar matched
 by the regular expression.
 In the following specification for regular expressions
 the word `character' means any character but newline.
 by the regular expression.
 In the following specification for regular expressions
 the word `character' means any character but newline.
-.IP 1.
+.Tw Ds
+.Tp 1.
 Any character except a special character
 matches itself.
 Special characters are
 the regular expression delimiter plus
 Any character except a special character
 matches itself.
 Special characters are
 the regular expression delimiter plus
-.RB \e\|[\| .
-and sometimes ^\|*\|$.
-.IP 2.
+.Sq Cm \e\[.
+and sometimes
+.Sq Cm ^*$ .
+.Tp 2.
 A
 A
-..
+.Sq Cm \&.
 matches any character.
 matches any character.
-.IP 3.
-A \e followed by any character except a digit or (\|) matches that character.
-.IP 4.
+.Tp 3.
+A
+.Sq Li \e
+followed by any character except a digit or
+.Li (\)
+matches that character.
+.Tp 4.
 A nonempty string
 A nonempty string
-.I s
-bracketed
-.RI [ \|s\| ]
-(or
-.RI [^ s\| ])
+.Op Ar s
+or
+.Oo
+.Cx \&(
+.Op Cm \&^ Ar s
+.Cx \&)
+.Cx
+.Oo
 matches any character in (or not in)
 matches any character in (or not in)
-.I s.
-In 
-.I s,
-\e has no special meaning, and ] may only appear as
+.Ar s .
+In
+.Ar s ,
+.Sq Li \e
+has no special meaning, and
+may only appear as
 the first letter.
 the first letter.
-A substring 
-.I a\-b,
+A substring
+.Ar a\-b ,
 with
 with
-.I a
+.Ar a
 and
 and
-.I b
+.Ar b
 in ascending ASCII order, stands for the inclusive
 range of ASCII characters.
 in ascending ASCII order, stands for the inclusive
 range of ASCII characters.
-.IP 5.
-A regular expression of form 1-4 followed by * matches a sequence of
+.Tp 5.
+A regular expression of form 1\-4 followed by * matches a sequence of
 0 or more matches of the regular expression.
 0 or more matches of the regular expression.
-.IP 6.
+.Tp 6.
 A regular expression,
 A regular expression,
-.I x,
-of form 1-8, bracketed
-.RI \e( \|x\| \e)
+.Ar x ,
+of form 1\-8, bracketed
+.Cx Li \e(
+.Ar x
+.Li \e)
+.Cx
 matches what
 matches what
-.I x
+.Ar x
 matches.
 matches.
-.IP 7.
-A \e followed by a digit 
-.I n
+.Tp 7.
+A \e followed by a digit
+.Ar n
 matches a copy of the string that the
 bracketed regular expression beginning with the
 matches a copy of the string that the
 bracketed regular expression beginning with the
-.IR n th
-\e( matched.
-.IP 8.
-A regular expression of form 1-8,
-.I x,
-followed by a regular expression of form 1-7,
-.I y
+.Cx Ar n
+.Cx \'th
+.Cx
+.Li \e(
+matched.
+.Tp 8.
+A regular expression of form 1\-8,
+.Ar x ,
+followed by a regular expression of form 1\-7,
+.Ar y
 matches a match for
 matches a match for
-.I x
+.Ar x
 followed by a match for
 followed by a match for
-.I y,
+.Ar y ,
 with the
 with the
-.I x
+.Ar x
 match being as long as possible while still permitting a
 match being as long as possible while still permitting a
-.I y
+.Ar y
 match.
 match.
-.IP 9.
-A regular expression of form 1-8 preceded by ^
-(or followed by $), is constrained to matches that
+.Tp 9.
+A regular expression of form 1\-8 preceded by
+.Sq Li ^
+(or followed by
+.Sq Li $ ) ,
+is constrained to matches that
 begin at the left (or end at the right) end of a line.
 begin at the left (or end at the right) end of a line.
-.IP 10.
-A regular expression of form 1-9 picks out the
+.Tp 10.
+A regular expression of form 1\-9 picks out the
 longest among the leftmost matches in a line.
 longest among the leftmost matches in a line.
-.IP 11.
+.Tp 11.
 An empty regular expression stands for a copy of the
 last regular expression encountered.
 An empty regular expression stands for a copy of the
 last regular expression encountered.
-.PP
+.Tp
+.Pp
 Regular expressions are used in addresses to specify
 lines and in one command
 (see
 Regular expressions are used in addresses to specify
 lines and in one command
 (see
-.I s
-below)\|
+.Ar s
+below)
 to specify a portion of a line which is to be replaced.
 If it is desired to use one of
 the regular expression metacharacters as an ordinary
 to specify a portion of a line which is to be replaced.
 If it is desired to use one of
 the regular expression metacharacters as an ordinary
-character, that character may be preceded by `\e'.
+character, that character may be preceded by
+.Sq Li \e .
 This also applies to the character bounding the regular
 This also applies to the character bounding the regular
-expression (often `/')\| and to `\e' itself.
-.PP
+expression (often
+.Sq Li \&/ )
+and to
+.Sq Li \e
+itself.
+.Pp
 To understand addressing in
 To understand addressing in
-.I ed
+.Nm ed
 it is necessary to know that at any time there is a
 it is necessary to know that at any time there is a
-.I  "current line."
+.Ar current line.
 Generally speaking, the current line is
 the last line affected by a command; however,
 the exact effect on the current line
 is discussed under the description of
 the command.
 Addresses are constructed as follows.
 Generally speaking, the current line is
 the last line affected by a command; however,
 the exact effect on the current line
 is discussed under the description of
 the command.
 Addresses are constructed as follows.
-.TP
-1.
-The character `\fB.\fR' addresses the current line.
-.TP
-2.
-The character `$' addresses the last line of the buffer.
-.TP
-3.
+.Tw Ds
+.Tp 1.
+The character
+.Sq Ic \&.
+addresses the current line.
+.Tp 2.
+The character
+.Cx `
+.Ic $
+.Cx \'
+.Cx
+addresses the last line of the buffer.
+.Tp 3.
 A decimal number
 A decimal number
-.I n
+.Ar n
 addresses the
 addresses the
-.IR n -th
+.Cx Ar n
+.Cx \'th
+.Cx
 line of the buffer.
 line of the buffer.
-.TP
-4.
-`\(fm\fIx\fR' addresses the line marked with the name
-.IR x ,
+.Tp 4.
+.Cx `\(fm
+.Ar x
+.Cx \'
+.Cx
+addresses the line marked with the name
+.Ar x  ,
 which must be a lower-case letter.
 Lines are marked with the
 which must be a lower-case letter.
 Lines are marked with the
-.I k
+.Ar k
 command described below.
 command described below.
-.TP
-5.
-A regular expression enclosed in slashes `/' addresses
+.Tp 5.
+A regular expression enclosed in slashes
+.Cx `
+.Li /
+.Cx \'
+.Cx
+addresses
 the line found by searching forward from the current line
 and stopping at the first line containing a
 string that matches the regular expression.
 If necessary the search wraps around to the beginning of the
 buffer.
 the line found by searching forward from the current line
 and stopping at the first line containing a
 string that matches the regular expression.
 If necessary the search wraps around to the beginning of the
 buffer.
-.TP
-6.
-A regular expression enclosed in queries `?' addresses
+.Tp 6.
+A regular expression enclosed in queries 
+.Cx `
+.Li ?
+.Cx \'
+.Cx
+addresses
 the line found by searching backward from the current line
 and stopping at the first line containing
 a string that matches the regular expression.
 If necessary
 the search wraps around to the end of the buffer.
 the line found by searching backward from the current line
 and stopping at the first line containing
 a string that matches the regular expression.
 If necessary
 the search wraps around to the end of the buffer.
-.TP
-7.
-An address followed by a plus sign `+'
-or a minus sign `\-' followed by a decimal number specifies that address plus
-(resp. minus)\| the indicated number of lines.
+.Tp 7.
+An address followed by a plus sign
+.Cx `
+.Li +
+.Cx \'
+.Cx
+or a minus sign
+.Cx `
+.Li \-
+.Cx \'
+.Cx
+followed by a decimal number specifies that address plus
+(resp. minus) the indicated number of lines.
 The plus sign may be omitted.
 The plus sign may be omitted.
-.TP
-8.
-If an address begins with `+' or `\-'
+.Tp 8.
+If an address begins with
+.Cx `
+.Li +
+.Cx \'
+.Cx
+or
+.Cx `
+.Li \-
+.Cx \'
+.Cx
 the addition or subtraction is taken with respect to the current line;
 the addition or subtraction is taken with respect to the current line;
-e.g. `\-5' is understood to mean `\fB.\fR\-5'.
-.TP
-9.
-If an address ends with `+' or `\-',
+e.g.
+.Cx `
+.Li \-5
+.Cx \'
+.Cx
+is understood to mean
+.Cx `
+.Li .\-5
+.Cx \'
+.Cx
+.Nm .
+.Tp 9.
+If an address ends with
+.Cx `
+.Li +
+.Cx \'
+.Cx
+.Cx `
+.Li \-
+.Cx \',
+.Cx
 then 1 is added (resp. subtracted).
 As a consequence of this rule and rule 8,
 then 1 is added (resp. subtracted).
 As a consequence of this rule and rule 8,
-the address `\-' refers to the line before the current line.
+the address
+.Cx `
+.Li \-
+.Cx \'
+.Cx
+refers to the line before the current line.
 Moreover,
 trailing
 Moreover,
 trailing
-`+' and `\-' characters
-have cumulative effect, so `\-\-' refers to the current
+.Cx `
+.Li +
+.Cx \'
+.Cx
+and
+.Cx `
+.Li \-
+.Cx \'
+.Cx
+characters
+have cumulative effect, so
+.Cx `
+.Li \-\-
+.Cx \'
+.Cx
+refers to the current
 line less 2.
 line less 2.
-.TP
-10.
+.Tp 10.
 To maintain compatibility with earlier versions of the editor,
 To maintain compatibility with earlier versions of the editor,
-the character `^' in addresses is 
-equivalent to `\-'.
-.PP
+the character
+.Cx `
+.Li ^
+.Cx \'
+.Cx
+in addresses is
+equivalent to
+.Cx `
+.Li \-
+.Cx \'.
+.Cx
+.Tp
+.Pp
 Commands may require zero, one, or two addresses.
 Commands which require no addresses regard the presence
 of an address as an error.
 Commands which accept one or two addresses
 assume default addresses when insufficient are given.
 If more addresses are given than such a command requires,
 Commands may require zero, one, or two addresses.
 Commands which require no addresses regard the presence
 of an address as an error.
 Commands which accept one or two addresses
 assume default addresses when insufficient are given.
 If more addresses are given than such a command requires,
-the last one or two (depending on what is accepted)\| are used.
-.PP
+the last one or two (depending on what is accepted) are used.
+.Pp
 Addresses are separated from each other typically by a comma
 Addresses are separated from each other typically by a comma
-`\fB,\fR'.
+.Cx `
+.Li ,
+.Cx \'
+.Cx
 They may also be separated by a semicolon
 They may also be separated by a semicolon
-`\fB;\fR'.
-In this case the current line `\fB.\fR' is set to
+.Cx `
+.Li ;
+.Cx \'
+.Cx
+In this case the current line 
+.Cx `
+.Li .
+.Cx \'
+.Cx
+.Nm .
+is set to
 the previous address before the next address is interpreted.
 This feature can be used to determine the starting
 the previous address before the next address is interpreted.
 This feature can be used to determine the starting
-line for forward and backward searches (`/', `?')\|.
+line for forward and backward searches
+.Cx \&(`
+.Li /
+.Cx \'
+.Cx
+.Cx `
+.Li ?
+.Cx \').
+.Cx
 The second address of any two-address sequence
 must correspond to a line following the line corresponding to the first address.
 The second address of any two-address sequence
 must correspond to a line following the line corresponding to the first address.
-The special form `%'
-is an abbreviation for the address pair `1,$'.
-.PP
+The special form
+.Cx `
+.Li \&%
+.Cx \'
+.Cx
+is an abbreviation for the address pair
+.Cx `
+.Li 1,$
+.Cx \'.
+.Cx
+.Pp
 In the following list of
 In the following list of
-.I ed
+.Nm ed
 commands, the default addresses
 are shown in parentheses.
 The parentheses are not part of
 the address, but are used to show that the given addresses are
 the default.
 commands, the default addresses
 are shown in parentheses.
 The parentheses are not part of
 the address, but are used to show that the given addresses are
 the default.
-.PP
+.Pp
 As mentioned, it is generally illegal for more than one
 command to appear on a line.
 However, most commands may be suffixed by `p'
 As mentioned, it is generally illegal for more than one
 command to appear on a line.
 However, most commands may be suffixed by `p'
@@ -290,393 +422,608 @@ Commands may also be suffixed by `n',
 meaning the output of the command is to
 be line numbered.
 These suffixes may be combined in any order.
 meaning the output of the command is to
 be line numbered.
 These suffixes may be combined in any order.
-.TP 5
-.RB (\| .\| )\|a
-.br
-.ns
-.TP 5
-<text>
-.br
-.ns
-.TP 5
-.B .
-.br
+.Tw Ds
+.Tp Cx \&(
+.Ic .
+.Cx \&)
+.Ic a
+.Cx
+.Tp <text>
+.Tp Ic \&.
 The append command reads the given text
 and appends it after the addressed line.
 The append command reads the given text
 and appends it after the addressed line.
-`\fB.\fR' is left
+.Sq Ic \&.
+is left
 on the last line input, if there
 were any, otherwise at the addressed line.
 Address `0' is legal for this command; text is placed
 at the beginning of the buffer.
 on the last line input, if there
 were any, otherwise at the addressed line.
 Address `0' is legal for this command; text is placed
 at the beginning of the buffer.
-.TP 5
-.RB (\| .\| ,\  .\| )\|c
-.br
-.ns
-.TP 5
-<text>
-.br
-.ns
-.TP 5
-.B .
-.br
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&c
+.Cx
+.Tp <text>
+.Tp Ic \&.
 The change
 command deletes the addressed lines, then accepts input
 text which replaces these lines.
 The change
 command deletes the addressed lines, then accepts input
 text which replaces these lines.
-`\fB.\fR' is left at the last line input; if there were none,
+.Sq Ic \&.
+is left at the last line input; if there were none,
 it is left at the line preceding the deleted lines.
 it is left at the line preceding the deleted lines.
-.TP 5
-.RB (\| .\| ,\  .\| )\|d
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&d
+.Cx
 The delete command deletes the addressed lines from the buffer.
 The line originally after the last line deleted becomes the current line;
 if the lines deleted were originally at the end,
 the new last line becomes the current line.
 The delete command deletes the addressed lines from the buffer.
 The line originally after the last line deleted becomes the current line;
 if the lines deleted were originally at the end,
 the new last line becomes the current line.
-.TP 5
-e filename
+.Tp Cx Ic \&e
+.Cx \&\ \&
+.Ar filename
+.Cx
 The edit
 command causes the entire contents of the buffer to be deleted,
 and then the named file to be read in.
 The edit
 command causes the entire contents of the buffer to be deleted,
 and then the named file to be read in.
-`\fB.\fR' is set to the last line of the buffer.
+.Sq Ic \&.
+is set to the last line of the buffer.
 The number of characters read is typed.
 The number of characters read is typed.
-`filename' is remembered for possible use as a default file name
+.Ar filename
+is remembered for possible use as a default file name
 in a subsequent
 in a subsequent
-.I r
+.Ic r
 or
 or
-.I w
+.Ic w
 command.
 command.
-If `filename' is missing, the remembered name is used.
-.TP 5
-E filename
+If
+.Ar filename
+is missing, the remembered name is used.
+.Tp Cx Ic E
+.Cx \&\ \&
+.Ar filename
+.Cx
 This command is the same as
 This command is the same as
-.I e,
+.Ic e ,
 except that no diagnostic results when no
 except that no diagnostic results when no
-.I w
+.Ic w
 has been given since the last buffer alteration.
 has been given since the last buffer alteration.
-.TP 5
-f filename
+.Tp Cx Ic f
+.Cx \&\ \&
+.Ar filename
+.Cx
 The filename command prints the currently remembered file name.
 The filename command prints the currently remembered file name.
-If `filename' is given,
-the currently remembered file name is changed to `filename'.
-.TP 5
-(1,$)\|g/regular expression/command list
+If
+.Ar filename
+is given,
+the currently remembered file name is changed to
+.Ar filename .
+.Tp Cx \&(
+.Ic \&1
+.Cx \&,
+.Ic \&$
+.Cx \&)
+.Ic \&g
+.Ar/regular expression/command list
+.Cx
 In the global
 command, the first step is to mark every line which matches
 the given regular expression.
 Then for every such line, the
 In the global
 command, the first step is to mark every line which matches
 the given regular expression.
 Then for every such line, the
-given command list is executed with `\fB.\fR' initially set to that line.
+given command list is executed with
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+initially set to that line.
 A single command or the first of multiple commands
 appears on the same line with the global command.
 A single command or the first of multiple commands
 appears on the same line with the global command.
-All lines of a multi-line list except the last line must be ended with `\e'.
-.I A,
-.I i,
+All lines of a multi-line list except the last line must be ended with
+.Cx `
+.Ic \&\e
+.Cx \'.
+.Cx
+.Ic A ,
+.Ic i,
 and
 and
-.I c
+.Ic c
 commands and associated input are permitted;
 commands and associated input are permitted;
-the `\fB.\fR' terminating input mode may be omitted if it would be on the
+the
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+terminating input mode may be omitted if it would be on the
 last line of the command list.
 The commands
 last line of the command list.
 The commands
-.I g
+.Ic g
 and
 and
-.I v
+.Ic v
 are not permitted in the command list.
 are not permitted in the command list.
-.TP 5
-.RB (\| .\| )\|i
-.ns
-.TP 5
-<text>
-.br
-.ns
-.TP 5
-.B .
-.br
+.Tp Cx \&(
+.Ic .
+.Cx \&)
+.Ic i
+.Cx
+.Tp <text>
+.Tp Ic \&.
 This command inserts the given text before the addressed line.
 This command inserts the given text before the addressed line.
-`\fB.\fR' is left at the last line input, or, if there were none,
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+is left at the last line input, or, if there were none,
 at the line before the addressed line.
 This command differs from the
 at the line before the addressed line.
 This command differs from the
-.I a
+.Ic a
 command only in the placement of the
 text.
 command only in the placement of the
 text.
-.TP 5
-.RB (\| .\| ,\  . +1)\|j
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.+1
+.Cx \&)
+.Ic \&j
+.Cx
 This command joins the addressed lines into a single line;
 intermediate newlines simply disappear.
 This command joins the addressed lines into a single line;
 intermediate newlines simply disappear.
-`\fB.\fR' is left at the resulting line.
-.TP 5
-( \fB. \fR)\|k\fIx\fR
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+is left at the resulting line.
+.Tp Cx \&(
+.Ic .
+.Cx \&)
+.Ic k
+.Ar x
+.Cx
 The mark command marks the addressed line with
 name
 The mark command marks the addressed line with
 name
-.I x,
+.Ar x ,
 which must be a lower-case letter.
 which must be a lower-case letter.
-The address form `\(fm\fIx\fR' then addresses this line.
-.ne 2.5
-.TP 5
-.RB (\| .\| ,\  .\| )\|l
+The address form
+.Cx `\(fm
+.Ar x
+.Cx \'
+.Cx
+then addresses this line.
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&l
+.Cx
 The list command
 prints the addressed lines in an unambiguous way:
 non-graphic characters are
 printed in two-digit octal,
 and long lines are folded.
 The
 The list command
 prints the addressed lines in an unambiguous way:
 non-graphic characters are
 printed in two-digit octal,
 and long lines are folded.
 The
-.I l
+.Ar l
 command may be placed on the same line after any non-i/o
 command.
 command may be placed on the same line after any non-i/o
 command.
-.TP 5
-.RB (\| .\| ,\  .\| )\|m\fIa
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&m
+.Ar a
+.Cx
 The move command repositions the addressed lines after the line
 addressed by
 The move command repositions the addressed lines after the line
 addressed by
-.IR a .
+.Ar a  .
 The last of the moved lines becomes the current line.
 The last of the moved lines becomes the current line.
-.TP 5
-.RB (\| .\| ,\  .\| )\|p
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&p
+.Cx
 The print command prints the addressed lines.
 The print command prints the addressed lines.
-`\fB.\fR'
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
 is left at the last line printed.
 The
 is left at the last line printed.
 The
-.I p
+.Ic p
 command
 may
 be placed on the same line after any non-i/o command.
 command
 may
 be placed on the same line after any non-i/o command.
-.TP
-.RB (\| .\| ,\  .\| )\|P
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&P
+.Cx
 This command is a synonym for
 This command is a synonym for
-.I p.
-.TP 5
-q
+.Ic p .
+.Tp Ic q
 The quit command causes
 The quit command causes
-.I ed
+.Nm ed
 to exit.
 No automatic write
 of a file is done.
 to exit.
 No automatic write
 of a file is done.
-.TP 5
-Q
+.Tp Ic Q
 This command is the same as
 This command is the same as
-.I q,
+.Ic q ,
 except that no diagnostic results when no
 except that no diagnostic results when no
-.I w
+.Ic w
 has been given since the last buffer alteration.
 has been given since the last buffer alteration.
-.TP 5
-($)\|r filename
+.Tp Cx \&(
+.Ic $
+.Cx \&)
+.Ic r
+.Cx \&\ \&
+.Ar filename
+.Cx
 The read command
 reads in the given file after the addressed line.
 If no file name is given,
 the remembered file name, if any, is used
 (see
 The read command
 reads in the given file after the addressed line.
 If no file name is given,
 the remembered file name, if any, is used
 (see
-.I e
+.Ic e
 and
 and
-.I f
-commands)\|.
+.Ic f
+commands).
 The file name is remembered if there was no
 remembered file name already.
 Address `0' is legal for
 The file name is remembered if there was no
 remembered file name already.
 Address `0' is legal for
-.I r
+.Ic r
 and causes the
 file to be read at the beginning of the buffer.
 If the read is successful, the number of characters
 read is typed.
 and causes the
 file to be read at the beginning of the buffer.
 If the read is successful, the number of characters
 read is typed.
-`\fB.\fR' is left at the last line read in from the file.
-.TP 5
-(\| \fB.\fR\|, \fB.\fR\|)\|s/regular expression/replacement/       or,
-.br
-.ns
-.TP 5
-(\| \fB.\fR\|, \fB.\fR\|)\|s/regular expression/replacement/g
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+is left at the last line read in from the file.
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&s
+.Ar/regular expression/replacement/
+.Cx \&\tor
+.Cx
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&s
+.Ar/regular expression/replacement/
+.Ic \&g
+.Cx
 The substitute command searches each addressed
 line for an occurrence of the specified regular expression.
 On each line in which a match is found,
 all matched strings are replaced by the replacement specified,
 The substitute command searches each addressed
 line for an occurrence of the specified regular expression.
 On each line in which a match is found,
 all matched strings are replaced by the replacement specified,
-if the global replacement indicator `g' appears after the command.
+if the global replacement indicator
+.Ic \&g
+appears after the command.
 If the global indicator does not appear, only the first occurrence
 of the matched string is replaced.
 It is an error for the substitution to fail on all addressed lines.
 Any punctuation character
 If the global indicator does not appear, only the first occurrence
 of the matched string is replaced.
 It is an error for the substitution to fail on all addressed lines.
 Any punctuation character
-may be used instead of `/' to delimit the regular expression
+may be used instead of
+.Cx `
+.Ic \&/
+.Cx \'
+.Cx
+to delimit the regular expression
 and the replacement.
 and the replacement.
-`\fB.\fR' is left at the last line substituted.
-.IP
-An ampersand `&' appearing in the replacement
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+is left at the last line substituted.
+An ampersand
+.Cx `
+.Ic \&&
+.Cx \'
+.Cx
+appearing in the replacement
 is replaced by the string matching the regular expression.
 is replaced by the string matching the regular expression.
-The special meaning of `&' in this context may be
-suppressed by preceding it by `\e'.
+The special meaning of
+.Cx `
+.Ic \&&
+.Cx \'
+.Cx
+in this context may be
+suppressed by preceding it by
+.Cx `
+.Ic \&\e
+.Cx \'.
+.Cx
 The characters
 The characters
-.I `\|\en'
+.Cx `
+.Ic \&\e
+.Ar n
+.Cx \'
+.Cx
 where
 where
-.I n
+.Ar n
 is a digit,
 are replaced by the text matched by the
 is a digit,
 are replaced by the text matched by the
-.IR n -th
+.Cx Ar n
+.Cx \'th
+.Cx
 regular subexpression
 regular subexpression
-enclosed between `\e(' and `\e)'.
+enclosed between
+.Cx `
+.Ic \&\e\&(
+.Cx \'.
+.Cx
+and
+.Cx `
+.Ic \&\e\&)
+.Cx \'.
+.Cx
 When
 nested, parenthesized subexpressions
 are present,
 When
 nested, parenthesized subexpressions
 are present,
-.I n
-is determined by counting occurrences of `\e(' starting from the left.
-.IP
+.Ar n
+is determined by counting occurrences of
+.Cx `
+.Ic \&\e\&(
+.Cx \'.
+.Cx
+starting from the left.
 Lines may be split by substituting new-line characters into them.
 The new-line in the
 replacement string
 Lines may be split by substituting new-line characters into them.
 The new-line in the
 replacement string
-must be escaped by preceding it by `\e'.
-.IP
+must be escaped by preceding it by
+.Cx `
+.Ic \&\e
+.Cx \'.
+.Cx
 One or two trailing delimiters may be omitted,
 One or two trailing delimiters may be omitted,
-implying the `p' suffix.
-The special form `s' followed by
-.I no
+implying the
+.Ic p
+suffix.
+The special form
+.Ic s
+followed by
+.Ar no
 delimiters
 repeats the most recent substitute command
 on the addressed lines.
 delimiters
 repeats the most recent substitute command
 on the addressed lines.
-The `s' may be followed by the letters
-.B r
+The
+.Ic s
+may be followed by the letters
+.Ic r
 (use the most recent regular expression for the
 left hand side, instead of the most recent
 left hand side of a substitute command),
 (use the most recent regular expression for the
 left hand side, instead of the most recent
 left hand side of a substitute command),
-.B p
+.Ic p
 (complement the setting of the
 (complement the setting of the
-.I p
+.Ic p
 suffix from the previous substitution), or
 suffix from the previous substitution), or
-.B g
+.Ic g
 (complement the setting of the
 (complement the setting of the
-.I g
+.Ic g
 suffix).
 These letters may be combined in any order.
 suffix).
 These letters may be combined in any order.
-.TP 5
-.RB (\| .\| ,\  .\| )\|t\|\fIa
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&t
+.Ar a
+.Cx
 This command acts just like the
 This command acts just like the
-.I m
+.Ic m
 command, except that a copy of the addressed lines is placed
 after address
 command, except that a copy of the addressed lines is placed
 after address
-.I a
+.Ad a
 (which may be 0).
 (which may be 0).
-`\fB.\fR' is left on the last line of the copy.
-.TP 5
-.RB (\| .\| ,\  .\| )\|u
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+is left on the last line of the copy.
+.Tp Cx \&(
+.Ic \&.
+.Cx \&,
+.Ic \&.
+.Cx \&)
+.Ic \&u
+.Cx
 The undo command restores the buffer to it's state
 before the most recent buffer modifying command.
 The current line is also restored.
 Buffer modifying commands are
 The undo command restores the buffer to it's state
 before the most recent buffer modifying command.
 The current line is also restored.
 Buffer modifying commands are
-.I a, c, d, g, i, k, m, r, s, t,
+.Ic a , c , d , g , i , k , m , r , s , t ,
 and
 and
-.I v.
+.Ic v .
 For purposes of undo,
 For purposes of undo,
-.I g
+.Ic g
 and
 and
-.I v
+.Ic v
 are considered to be a single buffer modifying command.
 Undo is its own inverse.
 are considered to be a single buffer modifying command.
 Undo is its own inverse.
-.IP
 When
 When
-.I ed
+.Nm ed
 runs out of memory
 (at about 8000 lines on any 16 bit mini-computer
 such as the PDP-11)
 This full undo is not possible, and
 runs out of memory
 (at about 8000 lines on any 16 bit mini-computer
 such as the PDP-11)
 This full undo is not possible, and
-.I u
+.Ic u
 can only undo the effect of the most recent
 substitute on the current line.
 This restricted undo also applies to editor scripts
 when
 can only undo the effect of the most recent
 substitute on the current line.
 This restricted undo also applies to editor scripts
 when
-.I ed
+.Nm ed
 is invoked with the
 is invoked with the
-.B -
+.Fl
 option.
 option.
-.TP 5
-(1, $)\|v/regular expression/command list
+.Tp Cx \&(
+.Ic \&1
+.Cx \&,
+.Ic \&$
+.Cx \&)
+.Ic \&v
+.Ar/regular expression/command list
+.Cx
 This command is the same as the global command
 This command is the same as the global command
-.I g
+.Ic g
 except that the command list is executed
 except that the command list is executed
-.I g
-with `\fB.\fR' initially set to every line
-.I except
+.Ic g
+with
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+initially set to every line
+.Em except
 those
 matching the regular expression.
 those
 matching the regular expression.
-.TP 5
-(1, $)\|w filename
-.br
+(1, $)\w filename
+.Tp Cx \&(
+.Ic \&1
+.Cx \&,
+.Ic \&$
+.Cx \&)
+.Ic \&w
+.Cx \&\ \&
+.Ar filename
+.Cx
 The write command writes the addressed lines onto
 the given file.
 If the file does not exist,
 it is created.
 The write command writes the addressed lines onto
 the given file.
 If the file does not exist,
 it is created.
-The file name is remembered if there was no 
+The file name is remembered if there was no
 remembered file name already.
 If no file name is given,
 the remembered file name, if any, is used
 (see
 remembered file name already.
 If no file name is given,
 the remembered file name, if any, is used
 (see
-.I e
+.Ic e
 and
 and
-.I f
-commands)\|.
-`\fB.\fR' is unchanged.
+.Ic f
+commands).
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+is unchanged.
 If the command is successful, the number of characters written is
 printed.
 If the command is successful, the number of characters written is
 printed.
-.TP
-(1, $)\|W filename
+.Tp Cx \&(
+.Ic \&1
+.Cx \&,
+.Ic \&$
+.Cx \&)
+.Ic \&W
+.Cx \&\ \&
+.Ar filename
+.Cx
 This command is the same as
 This command is the same as
-.I w,
+.Ic w ,
 except that the addressed lines are appended to the file.
 except that the addressed lines are appended to the file.
-.TP 5
-(1, $)\|wq filename
+.Tp Cx \&(
+.Ic \&1
+.Cx \&,
+.Ic \&$
+.Cx \&)
+.Ic \&wq
+.Cx \&\ \&
+.Ar filename
+.Cx
 This command is the same as
 This command is the same as
-.I w
+.Ic w
 except that afterwards a
 except that afterwards a
-.I q
+.Ic q
 command is done,
 exiting the editor
 after the file is written.
 command is done,
 exiting the editor
 after the file is written.
-.TP 5
-x
-A key string is demanded from the standard input.
-Later
-.I r, e
-and
-.I w
-commands will encrypt and decrypt the text 
-with this key by the algorithm of 
-.IR crypt (1).
-An explicitly empty key turns off encryption.
-.RB (\| .\| +1)\|z     or,
-.br
-.ns
-.TP 5
-.RB (\| .\| +1)\|z\fIn
+.Ic \&1
+.Ic \&+1
+.Cx \&)
+.Ic \&z
+.Cx \&\ \ \&or,
+.Cx
+.Tp Cx \&(
+.Ic \&1
+.Ic \&+1
+.Cx \&)
+.Ic \&z
+.Ar n
+.Cx
 This command scrolls through the buffer starting at the addressed line.
 22 (or
 This command scrolls through the buffer starting at the addressed line.
 22 (or
-.I n,
+.Ar n ,
 if given)
 lines are printed.
 The last line printed becomes the current line.
 The value
 if given)
 lines are printed.
 The last line printed becomes the current line.
 The value
-.I n
+.Ar n
 is sticky, in that it becomes the default for
 future
 is sticky, in that it becomes the default for
 future
-.I z
+.Ic z
 commands.
 commands.
-.TP 5
-($)\|=
+.Tp Cx \&(
+.Ic \&$
+.Cx \&)
+.Ic \&=
+.Cx
 The line number of the addressed line is typed.
 The line number of the addressed line is typed.
-`\fB.\fR' is unchanged by this command.
-.TP 5
-!<shell command>
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
+is unchanged by this command.
+.Tp Cx Ic \&!
+.Cx <shell\ command>
+.Cx
 The remainder of the line after the `!' is sent
 to
 The remainder of the line after the `!' is sent
 to
-.IR sh (1)
+.Xr sh  1
 to be interpreted as a command.
 to be interpreted as a command.
-.RB ` . '
+.Cx `
+.Ic \&.
+.Cx \'
+.Cx
 is unchanged.
 is unchanged.
-.TP 5
-.RB (\| . +1,\| . +1)\|<newline>
+.Tp Cx \&(
+.Ic \&.+1
+.Cx \&,
+.Ic \&.+1
+.Cx \&)
+.Cx <newline>
+.Cx
 An address alone on a line causes the addressed line to be printed.
 An address alone on a line causes the addressed line to be printed.
-A blank line alone is equivalent to `.+1p'; it is useful
+A blank line alone is equivalent to
+.Ic .+1
+it is useful
 for stepping through text.
 If two addresses are present with no
 intervening semicolon,
 for stepping through text.
 If two addresses are present with no
 intervening semicolon,
-.I ed
+.Nm ed
 prints the range of lines.
 If they are separated by a semicolon,
 the second line is printed.
 prints the range of lines.
 If they are separated by a semicolon,
 the second line is printed.
-.PP
-If an interrupt signal (ASCII DEL)\| is sent,
-.I ed
-prints `?interrupted'
+.Tp
+.Pp
+If an interrupt signal (ASCII DEL) is sent,
+.Nm ed
+prints
+.Sq Li ?interrupted
 and returns to its command level.
 and returns to its command level.
-.PP
+.Pp
 Some size limitations:
 512 characters per line,
 256 characters per global command list,
 Some size limitations:
 512 characters per line,
 256 characters per global command list,
@@ -685,57 +1032,58 @@ and, on mini computers,
 128K characters in the temporary file.
 The limit on the number of lines depends on the amount of core:
 each line takes 2 words.
 128K characters in the temporary file.
 The limit on the number of lines depends on the amount of core:
 each line takes 2 words.
-.PP
+.Pp
 When reading a file,
 When reading a file,
-.I ed
+.Nm ed
 discards ASCII NUL characters
 and all characters after the last newline.
 It refuses to read files containing non-ASCII characters.
 discards ASCII NUL characters
 and all characters after the last newline.
 It refuses to read files containing non-ASCII characters.
-.SH FILES
-/tmp/e*
+.Sh FILES
+.Dw edhup
+.Di L
+.Dp Pa /tmp/e*
+.Dp Pa edhup
+work is saved here if terminal hangs up
+.Dp
+.Sh SEE ALSO
+.Xr ex 1 ,
+.Xr sed 1 ,
+.Xr crypt 1
 .br
 .br
-edhup: work is saved here if terminal hangs up
-.SH "SEE ALSO"
 B. W. Kernighan,
 B. W. Kernighan,
-.I
-A Tutorial Introduction to the ED Text Editor
+.Em A Tutorial Introduction to the ED Text Editor
 .br
 B. W. Kernighan,
 .br
 B. W. Kernighan,
-.I Advanced editing on UNIX
-.br
-ex(1), sed(1), crypt(1)
-.SH DIAGNOSTICS
-`?name' for inaccessible file;
-`?self-explanatory message'
+.Em Ar Advanced editing on UNIX
+.Sh HISTORY
+The
+.Nm ed
+command appeared in Version 6 AT&T UNIX.
+.Sh DIAGNOSTICS
+.Sq Li name
+for inaccessible file;
+.Sq Li ?self-explanatory message
 for other errors.
 for other errors.
-.PP
+.Pp
 To protect against throwing away valuable work,
 a
 To protect against throwing away valuable work,
 a
-.I q
+.Ic q
 or
 or
-.I e
+.Ic e
 command is considered to be in error, unless a
 command is considered to be in error, unless a
-.I w
+.Ic w
 has occurred since the last buffer change.
 A second
 has occurred since the last buffer change.
 A second
-.I q
+.Ic q
 or
 or
-.I e
+.Ic e
 will be obeyed regardless.
 will be obeyed regardless.
-.SH BUGS
-The 
-.I l
-command mishandles DEL.
-.br
+.Sh BUGS
 The
 The
-.I undo
-command causes marks to be lost on affected lines.
+.Ic l
+command mishandles
+.Li DEL .
 .br
 The
 .br
 The
-.I x
-command,
-.B -x
-option,
-and
-special treatment of hangups
-only work on UNIX.
+.Ic undo
+command causes marks to be lost on affected lines.