Finding your position in the buffer, Changing your position in the buffer – HP NonStop G-Series User Manual

Page 171

Advertising
background image

Finding Your Position in the Buffer

When you first load a file into the buffer, the last line of the file is the current line. As you work
with the file, you usually change the current line many times. You can display the current line or
its line number at any time.
To display the current line, enter p:

p
a period.

The p subcommand displays the current line (“a period.”). Because the current line has not been
changed since you read afile into the buffer, the current line is the last line of the buffer.
Enter .= to display the line number of the current line, as shown:

.=
4

Because afile has four lines, and the current line is the last line in the buffer, the .= subcommand
displays 4.
You also can use the $ (the symbol that stands for the last line in the buffer) with the = subcommand
to determine the number of the last line in the buffer:

$=
4

The $= subcommand is an easy way to find out how many lines are in the buffer. Note that the $
symbol in the ed program has no relationship to the $ shell prompt.

Changing Your Position in the Buffer

You can change your position in the buffer (change your current line) in one of two ways:

Specify a line number (an absolute position)

Move forward or backward relative to your current line

To move the current line to a specific line, enter the line number; ed displays the new current line.
In the following example, the first line of afile becomes the current line:

1
The only way to stop

Pressing Return advances one line through the buffer and displays the new current line, as the
following example shows:

appending is to type a

<Return>

line that contains only

<Return>

a period.

<Return>

?

Note that when you try to move beyond the last line of the buffer, ed returns ?, an error message.
You cannot move beyond the end of the buffer.
To set the current line to the last line of the buffer, enter $.
To move the current line backward through the buffer one line at a time, enter hyphens (-) one
after the other, as the following example shows:

-
line that contains only
-
appending is to type a

Displaying and Changing the Current Line

171

Advertising
This manual is related to the following products: