Searching
The editor has very powerful search options which allow searching with any of
the following modifiers singly or combined. Search up, search marked block
only, ignore case, whole word only, loop through all loaded files or interpret
as regular expression. For search and replace a dialog allows the following;
replace, skip, replace all, quit, undo last replace, and redo last skipped.
The initial search is done by opening the
search dialog from the menu or with Ctrl S (Ctrl R for search and
replace). A search can also be initiated from the command line by
prefixing the search string with a `/' or any other punctuation not
used for other purposes. A search and replace from the command
line is of the form ``c/str/rep/[-cblrw]''. The square brackets
denote the optional search options if any and are not themselves
to be entered. Subsequently, the same
string may be searched for using Ctrl f. The editor keys used for
searching are as follows:
Un-mapped Search Control Keys
Ctrl f find next occurrence of search string
Ctrl F change dir and find search string
Ctrl R opens the search and replace dialog
Ctrl S opens the search dialog
Alt * find next word like current word
Alt # find prev word like current word
- Ctrl f finds the next occurrence of the search string. The first occurrence
must be found either by going to the command line with ESC and entering the
desired search string after a `/' as in ``/string'' or else using the
search dialog from the menu bar.
- Ctrl F. Changes the current search direction and locates the next search
string. Thus if the current direction is down then a Ctrl F finds
previous location of the search string having set the direction to up. If it
is now desired to continue searching in the up direction use Ctrl f.
- Alt * and Alt # finds the next or previous word matching the word currently
under the cursor respectively. This is equivalent to doing a search for the
current word with the /w whole word flag turned on so only whole words matching
the current word are found. The current search string is not updated however.
The search options are specified using the buttons in the search
dialog or with the optional command line switches. For example:
``\-w'' searches up from current cursor position and looks
only for ``string'' that is not part of a larger word.
The optional search suffixes are:
- | search up (down is default)
|
b | search marked block only
|
c | ignore case
|
l | loop through all files
|
r | interpret as regular expression
|
w | match whole words only
|
Of these the most complex and most powerful is the interpret as
regular expression option. Regular
expressions allow search strings to be built that will match
complex criteria. A simple example is ``[0-9]+
\.[0-9]+'' which
will match any fixed point number. For regular expressions certain
characters have special meaning:
∧ | start of line or not the following characters in a set
|
$ | end of line
|
. | any character
|
\ | next character is literal. Used to override special meaning of next
character.
|
* | match previous character or group zero or more times
|
+ | match previous character or group one or more times
|
[]
start of a set.
[] | end of a set.
|
- | range delimiter
|
( | start of a sub-expression
|
) | end of a sub-expression
|
The following are some simple examples:
+ match any word containing only letters
match a,e,i and 0 through 9
match anything but a,e,i and 0 through 9
a(ab)*b matches ab aabb aababb aabababb etc.
If a ``grep'' (A UNIX utility program which searches files for a
regular expression) utility is run from the command line the grep
search string automatically becomes the editor search string. If
your grep does not have the name grep set up a batch file or rename
it to activate this feature.