Editing text – HP NonStop G-Series User Manual

Page 159

Advertising
background image

Add the word “new” just before the word “text” in the first line in the file: First, move the cursor to
the t in “text.” Then, enter input mode by typing:

I

Next, enter the word “new,” plus a space character:

new <Space>

Now exit input mode by pressing:

<Esc>

The cursor should now be on the space between the words “new” and “text.”
The i command starts inserting text before the character that the cursor is on. To insert text after
the character the cursor is on, use the a command. You need the a command to add text to the
end of a line.
The o command creates a new line below the line with the cursor and allows you to insert text at
the start of that new line. To add a sentence to the end of this file, first move the cursor to the next
line by typing:

j

The cursor should be on the i in “vi”. Then, enter input mode by typing:

o

Enter the new sentence, which can include Return characters, and press Esc to return to command
mode when you are finished. If you make a mistake, you can press the Backspace key to correct
it.

New text can be easily entered<Return>
while in input mode.<Esc>

Your screen should now look like the following:

You can use this new text file
to experiment with vi.
New text can be easily entered
while in input mode.
~
~
~
~
~
~
~
"my.file" 4 lines, 102 characters

There is also an O command, which creates a new line above the current line and starts inserting
text at the start of the new line. This is useful for adding new text to the top of the file, but it can
be used anywhere.
There are two other commands that start input mode: I and A. The I command starts inserting text
before the first character of the current line. The A command starts inserting text after the last
character of the current line.

Editing Text

The vi editor provides commands for both deleting and changing blocks of text. For example, to
remove the word “easily,” move the cursor to the first character of the word and type:

dw

This is a combination of the delete command d and the motion command w. In fact, many vi
commands can be combined with motion commands to specify the duration of the action. The
general form for combining action and motion commands is:

[number] command motion

The command entry represents an action command, motion represents a motion command, and
number

optionally represents the number of times to perform the command. You also can use this

Getting Started

159

Advertising
This manual is related to the following products: