Next: Quick Vi Tutorial
Up: Quick Ed Tutorial
Previous: editing a existing file
You have seen how to display the contents of the current line, by
the use of the command. We also know there are line number modifiers
for the commands. To print the contents of the second line.
2p
There are some special modifiers that refer to positions that can
change, in the lifetime of the edit session. The {} is the last line
of the text. To print the last line.
$p
The current line number uses the special modifier symbol . To
display the current line using a modifier.
.p
This may appear to be unnecessary, although it is very useful in the context of
line number ranges.
To display the contents of the text from line 1 to line 2 the range needs
to be supplied to ed.
1,2p
The first number refers to the starting line, and the second refers to the
finishing line. The current line will subsequently be the second number of the command
range.
If you want to display the contents of the file from the start to
the current line.
1,.p
To display the contents from the current line to the end of the
file.
.,$p
All that is left is to display the contents of the entire file which
is left to you.
How can you delete the first 2 lines of the file.
1,2d
The command key deletes the text line by line. If you wanted
to delete the entire contents you would issue.
1,$d
If you have made to many changes and do not want to save the contents
of the file, then the best option is to quit the editor without
writing the file beforehand.
Most users do not use ed as the main editor of choice. The more modern
editors offer a full edit screen and more flexible command sets. Ed
offers a good introduction to vi and helps explain where its
command set originates.
Next: Quick Vi Tutorial
Up: Quick Ed Tutorial
Previous: editing a existing file
Converted on:
Mon Apr 1 08:59:56 EST 1996
|