Owner's manual

nd
To delete lines numbered n through m from the buffer, enter:
n,md
Deleting the Current Line
If you want to delete the current line, simply enter d. In the following example, the 1,$p
subcommand displays the entire contents of the buffer, and the $ subcommand makes the last line
of the buffer the current line:
1,$p
Remember, the only way to quit
adding is to type a
line that contains only
a period. Then press Enter.
$
a period. Then press Enter.
d
The d subcommand then deletes the current line (in this case, the last line in the buffer).
Deleting a Specific Line
If you know the line number of the line you want to delete, use a subcommand of the form nd to
make the deletion. In the following example, the 2d subcommand deletes line 2 from the buffer:
2d
1,$p
Remember, the only way to quit
line that contains only
The 1,$p subcommand displays the contents of the buffer, showing that the line was deleted.
Deleting Multiple Lines
To delete a group of lines from the buffer, use a subcommand of the form n,md, where n is the
starting line number and m is the ending line number of the group to be deleted.
In the following example, the 1,2d subcommand deletes lines 1 and 2:
1,2d
1,$p
?
The 1,$p subcommand displays the ? message, indicating that the buffer is empty.
If you are following these examples on your system, you should restore the contents of the buffer
before you move on to the next subsection. The following example shows you how to restore the
contents of the buffer:
e afile
?
e afile
78
This command sequence reads a copy of the original file afile into the buffer.
Moving Text—The m (Move) Subcommand
Use the m (move) subcommand to move a group of lines from one place to another in the buffer.
After a move, the last line moved becomes the current line.
To move text, enter a subcommand of the form x,ymz where:
is the first line of the group to be moved.x
is the last line of the group to be moved.y
is the line the moved lines are to follow.z
176 The ed Editor