Searching for strings, Moving text, Copying text – HP NonStop G-Series User Manual

Page 161: Searching for strings moving text copying text

Advertising
background image

Searching for Strings

Use the / command to search for strings of characters in a file. To try the / command, first move
to the top of the my.file file. Then type / followed by the string “th” and press Return as follows:

/th<Return>

As soon as you enter /, it will be displayed on the bottom of the screen. As you type the string
“th”, it will be echoed at the bottom of the screen. You can press Backspace to fix mistakes as you
type the search string. After you press Return, the cursor is moved to the first occurrence of the
string.
The n command searches for the next occurrence of the last string you searched for. Try it now by
entering:

n

The cursor should move to the next occurrence of the string, which is the “th” in the word “with”.
You can also use N like n to search the other direction through the file.
The ? command can be used in the same way as / to specify a search string for a backward
search through the file. When you search backward, the n command moves the cursor backward
to the next occurrence of the string and the N command moves the cursor forward.

Moving Text

The first step in moving a block of text is to select the text to be moved. The d command not only
deletes a block of text but also copies it to a paste buffer. Once in the paste buffer, the text can
be moved by repositioning the cursor and then using the p command to insert the text after the
current cursor position.
To delete the first line of the file, move there and type:

dd

The line is deleted and copied into the paste buffer, and the cursor is moved to the next line in the
file. To paste the deleted line following the current line, type:

p

To paste text before the cursor rather than after it, use the P command.
If you delete a letter or word-size block, it is pasted into the new position within the current line.
For example, to move the word “can” to just before the word “with,” you could use the following
command sequence:

/can<Return>
dw
/with<Return>
P

Copying Text

You copy text in the same way you move it, except you use the yank text command y. The y
command copies the specified text into the paste buffer without deleting it from the text. It follows
the same syntax as the d command. You can use the yy command to copy an entire text line into
the paste buffer.
For example, to copy the first two lines of the file to a position immediately underneath them, enter
the following commands from the first line of the file:

2yy
j
P

Note that you must move down one line using j; otherwise, the two lines will be pasted after the
first line rather than after the second.

Using Advanced Techniques

161

Advertising
This manual is related to the following products: