Command Line Searches |
Top Previous Next |
The EXPL editor has several search commands that let you quickly scan for strings of characters.
Basic Search Command. The basic search command is done by typing "S" on the Command Line followed by the string you want to search for followed by two Esc characters. For example:
<Esc>Sanimals<Esc><Esc>
This commands searches forward from the cursor to the first occurrence of “animals”. If you type Ctrl+G, it is re-executed, and the next occurrence of “animals” is located.
Search Direction. Searches normally go forward from the cursor, but you can set the search to go backward by clicking on the search direction item on the Status Line. You can also change it by typing Ctrl+_ (Ctrl+underscore). Typing Ctrl+_ a second time, changes back to forward searches. The search direction is indicated on the status line by an arrow. The arrow points to the right if the search is forward, and points to the left if the search is backward.
You also can force a search to be forward or backward by placing a “+” or “-“ in front of it. For example:
<Esc>-Sfrog<Esc><Esc>
This forces a backward search for the string “frog”. This feature is useful with macros when you don’t know the direction that was last set by the Ctrl+_ command.
Case Sensitivity. The editor lets you change the case sensitivity of searches. Normally, searches are case-sensitive, which means that uppercase and lowercase letters are treated as different characters. In other words, uppercase “A” does not match lowercase “a”. You can toggle case sensitivity on and off by clicking on the case-sensitivity item on the Status Line. You can also toggle it on and off by Typing Ctrl+]. If case sensitivity has been toggled off, searching for “COWBOY” also locates the string ”Cowboy”. The case sensitivity is shown on the status line. If “S#s” is shown, searches are case-sensitive; and if “S=s” is shown, they are not.
Wild Cards. Sometimes you want to search for a string, but the match doesn’t need to be exact. For example, you might want to locate a string like “the high was 78 degrees”, but the temperature can be any two-digit number. The “wildcard” character, Ctrl+W, is used to do this. When Ctrl+W is placed in a search string, it matches any character. As a result, the search string: “the high was <Ctrl-W><Ctrl-W> degrees” finds the string no matter what temperature was used.
Numeric Wild Cards. You also may want to search for a number, but you don’t care about what the exact value is. For this reason, there is a numeric wild card Ctrl+N. Ctrl+N will match any numeric digit. For example, <Ctrl+N><Ctrl+N> will match any two-digit number.
Search and Replace. A common editing operation is searching for one string and replacing it with another. This is done with the "F" (find) command. The “F” command is like a regular search except that it replaces the string with a new string. The format of the command is:
F <string1> <Esc> <string2> <Esc>
The editor searches for <string1> and, if found, replaces it with <string2>. The two strings do not need to be the same length. If the second string is empty, the editor simply deletes the first string.
Examples. Here are some sample command lines:
<Esc>SPRINT<Esc>I LINE<Esc><Esc>
This searches forward for the word “PRINT”, and inserts a space and the word “LINE” immediately after it.
<Esc>Ftheir<Esc>they’re<Esc>J<Esc><Esc>
This command line changes every occurrence of the word “their” to “they’re”.
<Esc>S\<Esc>DRI<Enter><Esc>J<Esc><Esc>
This macro can be used to delete all comments from an XPL program. It searches for an occurrence of a “\” character, deletes it and the rest of the line, then inserts a new carriage return to replace the one deleted by the “R” command.
|