.\" @(#)e3 6.1 (Berkeley) 5/22/86
The current line \- ``Dot'' or ``.''
Suppose your buffer still contains the six lines as above,
has printed the three lines for you.
to come to the aid of their party.
which is the third line of the buffer.
(most recent) line that you have done anything with.
command without line numbers, and
it will continue to print line 3.
maintains a record of the last line
that you did anything to (in this case, line 3, which you
just printed) so that it can be used instead of an explicit
This most recent line is referred to by the
\&\*. (pronounced ``dot'').
Dot is a line number in the same way that
exactly ``the current line'', or loosely,
``the line you most recently did something to.''
can use it in several ways \- one possibility
This will print all the lines from (including) the current
In our example these are lines 3 through 6.
Some commands change the value of dot, while others do not.
command sets dot to the number of the last line printed;
Dot is most useful when used in combinations like this one:
\&\*.+1 (or equivalently, \*.+1p)
This means ``print the next line'' and is a handy way to step
which means ``print the line
This enables you to go backwards if you wish.
Another useful one is something like
which prints the previous three lines.
Don't forget that all of these change the value of dot.
You can find out what dot is at any time by typing
will respond by printing the value of dot.
Let's summarize some things about the
can be preceded by 0, 1, or 2 line numbers.
If there is no line number given, it prints the ``current line'',
the line that dot refers to.
If there is one line number given
(with or without the letter
it prints that line (and dot is set there); and if there
are two line numbers, it prints all the lines in that range
(and sets dot to the last line printed.)
If two line numbers are specified
the first can't be bigger than the second (see Exercise 2.)
Typing a single return will cause printing of the next line \-
Deleting lines: the ``d'' command
Suppose you want to get rid of the three extra lines in the buffer.
deletes lines instead of printing them,
its action is similar to that of
The lines to be deleted are specified for
\fIstarting line, ending line\fP d
deletes lines 4 through the end.
There are now three lines left, as you can check by using
is set to the next line after the last line deleted,
unless the last line deleted is the last line in the buffer.
In that case, dot is set to
until you are sure that you
know what they do, and until you understand how dot,
If you are adventurous, try using line numbers with
the line number that you specify (rather than after dot); that
the line number you specify (not necessarily
at the end of the buffer); and that
will write out exactly the lines
you specify, not necessarily the whole buffer.
These variations are sometimes handy.
For instance you can insert a file at the beginning of a buffer
and you can enter lines at the beginning of the buffer
Modifying text: the Substitute command ``s''
We are now ready to try one of the most important
of all commands \- the substitute command
that is used to change individual
words or letters within a line or group of lines.
It is what you use, for example, for correcting spelling
mistakes and typing errors.
Suppose that by a typing error, line 1 says
to fix this up as follows:
This says: ``in line 1, substitute for the characters
the result automatically) say
which is what you wanted.
Notice that dot must have been set to the line
where the substitution took place, since the
Dot is always set this way with the
The general way to use the substitute command is
\fIstarting\(hyline, ending\(hyline\fP s/\fIchange this\fP/\fIto this\fP/
Whatever string of characters is between the first pair of
slashes is replaced by whatever is between the second pair,
Only the first occurrence on each line is changed, however.
occurrence, see Exercise 5.
The rules for line numbers are the same as those for
except that dot is set to the last line changed.
(But there is a trap for the unwary: if no substitution
and correct the first spelling mistake
(This is useful for people who are consistent
If no line numbers are given, the
``make the substitution on line dot'', so it changes things only
This leads to the very common sequence
s/something/something else/p
which makes some correction on the
current line, and then prints it, to make sure it
no other multi-command lines are legal.)
which means ``change the first
This is useful for deleting extra words in a line or removing extra
(two adjacent slashes) means ``no characters'', not a blank.
(See below for another meaning of