Search And Replace Forward [ HP EDIT Reference Manual ] MPE/iX 5.0 Documentation
HP EDIT Reference Manual
Search And Replace Forward
Purpose
Searches forward and replaces text.
Default Syntax
}
Description
This command searches forward in the file [REV BEG]or in a block of
text[REV END] and replaces one or more occurrences of the current search
pattern with the current replacement pattern.
Command Process
HP EDIT first searches for text that matches the search pattern. If it
finds matching text, the following occurs:
* The cursor moves to the first character of the matched text
* The entire matched text is highlighted (if Highlight Match
parameter of the Set Options screen is enabled)
* A prompt appears on the message line
After HP EDIT finds an occurrence of the search pattern in the file, it
does not automatically replace the matching text with the replacement
pattern text. Before HP EDIT proceeds, you must first respond to the
prompt as explained in the next section. If none of the text matches the
search pattern, or if you did not specify a search pattern before
executing this command, HP EDIT indicates that no occurrences of the
search pattern were replaced.
Requirements
In order for this command to perform its function, you must define a
search pattern using either the Define Search Pattern command, Define
Search Pattern From Text command, or Define Search Pattern From Macro
command. You should also define a replacement pattern using one of the
define replace pattern commands.
Options
When HP EDIT finds text that matches the search pattern, HP EDIT does not
replace text until you respond to the prompt. You have several response
choices ranging from no replacement to all further occurrences. When the
prompt appears, you can use the following keys to perform the described
functions:
Return Replaces this occurrence and continues searching.
Space Skips this occurrence and continues searching.
r Replaces this occurrence and stops searching.
+ Replaces this occurrence and all subsequent
occurrences.
Any other key Skips this occurrence and aborts all further
searching.
Procedure
To search forward and replace text:
1. Predefine the search and replace patterns using the Define Search
Pattern and Define Replace Pattern commands.
2. Ensure that the cursor is positioned anywhere before the [REV
BEG]first character to be searched and replaced or within the
selected block of text you wish to search[REV END]. To search the
entire file, move the cursor to the top of the file.
3. Press the } key, or press the Search/Replace function key,
followed by the Replace Forward function key. HP EDIT moves the
cursor to the first character of the first occurrence of the
highlighted search pattern and displays the following prompt on
the message line:
Press Return (replace), space (skip), + (all), r (replace & stop), other (stop)
4. Respond appropriately to the prompt as explained in Options.
Examples
To replace subroutine with program in the following sentence:
This subroutine consists of 30 lines.
1. Execute the Define Search Pattern (f) command.
2. Type subroutine beside the prompt and press Return.
3. Execute the Define Replace Pattern (=) command.
4. Type program beside the prompt and press Return.
5. Ensure that the cursor is positioned anywhere before the letter s
in subroutine.
6. Press the } key. HP EDIT moves the cursor to the first character
of the word subroutine as shown:
This subroutine consists of 30 lines.
7. Press the r key to replace this occurrence and stop searching. HP
EDIT displays 1 occurrence was replaced on the message line and
replaces the word subroutine with the word program as shown:
This program consists of 30 lines.
Related Commands
Define Replace Pattern
Define Replace Pattern From Text
Define Search Pattern
Define Search Pattern From Text
Global Search And Replace Backward
Global Search And Replace Forward
Insert Replace Pattern
Insert Search Pattern
Search And Replace Backward
Search Backward
Search Forward
MPE/iX 5.0 Documentation