Changing multiple lines, Inserting text—the i (insert) subcommand, Using line numbers – HP NonStop G-Series User Manual

Page 178

Advertising
background image

The only way to stop
appending new material is to
use the proper keys to create a
a period.

The period on a line by itself stops ed from adding text to the buffer. The 1,$p subcommand
displays the entire contents of the buffer, showing that the change was made.

Changing Multiple Lines

To change more than one line of text, give the starting and ending line numbers of the group of
lines to be replaced with the c subcommand. You can replace the group of lines with one or more
new lines.
In the following example, the 2,3c subcommand deletes lines 2 and 3 from the buffer, and then
you can enter new text:

2,3c
adding text is to type a
.
1,$p
The only way to stop
adding text is to type a
line that contains only a
period.

The period on a line by itself stops ed from adding text to the buffer. The 1,$p subcommand
displays the entire contents of the buffer, showing that the change was made.

Inserting Text—The i (Insert) Subcommand

Use the i (insert) subcommand to insert one or more new lines into the buffer. To locate the place
in the buffer for the lines to be inserted, you can use either a line number or a context search. The
i

subcommand inserts new lines before the specified line. (Compare the i subcommand with the

a

subcommand, explained in

“osh Flags” (page 86)

, which inserts new lines after the specified

line.) To insert text, do the following:
1.

Enter a subcommand of one of the following types:

ni

where n is the number of the line the new lines will be inserted above.

/string/i

where string is a group of characters contained in the line the new lines will be inserted
above.

2.

Enter the new lines.

3.

Enter a period at the start of a new line.

Using Line Numbers

If you know the number of the line where you want to insert new lines, you can use an insert
subcommand of the form ni (where n is a line number). The new lines you type go into the buffer
before line number n. To end the i subcommand, type a period (.) on a line by itself.
In the following example, the 1,$p subcommand prints the contents of the buffer. Then the 4i
subcommand inserts new lines before line number 4.

1,$p
The only way to stop
adding text is to type a
line that contains only
a period.
4i --repeat, only--
.
1,$p
The only way to stop
adding text is to type a

178

The ed Editor

Advertising
This manual is related to the following products: