The search command

One of the central features of any editor is its search facility. Searching should be fast and versatile. Therefore much effort has been put into providing stedi with a set of very fast search routines which utilize the rather modern Boyer and Moore search algorithm (see R. S. Boyer and J. S. Moore, A fast string searching algorithm, Comm. ACM, 20, 10 (Oct.-1977), 762-772). As a consequence, searching for a string of 6 characters is done at a rate of more than 400 Kbytes per second on a Motorola 68000 at 8 Mhz or a 80286 at 10 Mhz. This allows for moving through even very large files at an extremely fast pace.

Both the search command and the search and replace are issued from the command line. A slash (/) is the starting character for either of these commands.

The basic syntax for a search command is:

    /string/
where `string' is the string of characters desired to be searched for. The cursor will be positioned at the first character of the first occurrence of `string' that is encountered. If no (further) occurrences are found, this will be announced in the message line. The trailing slash is optional. Experience shows that it is often forgotten and as searching isn't destructive (it doesn't alter the text) there is no reason to be very strict about syntax for this command. Note that the search operation doesn't look inside closed folds.

The search command can also take various optional parameters. If no options are specified, a default setting is taken. The full syntax of the search command is:

    /string/options
where `options' is a string of characters specifying the options desired. If a character in this string corresponds to one of the option characters listed below, a flag for that option is set. If two options contradict each other, the last one given over-rides the first. The possible options are:

N or n

The search is case Non-sensitive. This means that the case of the characters in the search string is not considered. This holds also for the characters used in the national character sets, such as characters with accents, if both the upper case and the lower case versions of such a character are present in the standard character fonts for your computer.

S or s
The search will be case Sensitive. N and S are mutually exclusive: only the last one given counts. These options can be used to override the default set with the Alt-N or Alt-S commands.

R or r

The search will only be done in the Range between the mark and the cursor. This enables the user to search (and replace) strings in a part of the file only. A match can only occur if the string searched for is fully included in this range between the mark and the cursor.

B or b

The search will only be done in the Block of rows and columns between the mark and the cursor. With this option, searches (and replacements) can be performed in specified columns. A match can only occur if the string to be found is fully included inside the block defined by the mark and the cursor.

W or w

The string to be searched for is interpreted as a word. This means that a match can only occur if the string is encountered where it is both immediately preceded by and followed by a character that does not belong to words. Characters belonging to words are a-z, A-Z, 0-9, _ and the special alphabetic characters that may be present in the local default font that are used for the national character sets.

0

The search will be circularly forward. This means that the search will be started in the forward direction. If no match is encountered between the position where the cursor started and the end of the file, the search is continued starting at the beginning of the file. When the original position of the cursor is encountered, a message `No match found.' is given. The original position of the cursor never counts as a match in searching (it does in search and replace though !).

> or $\gg$

The search will be forward. If no match is found between the original position of the cursor and the end of the file the message `No match found.' will be given.

< or $\ll$

The search will be backward. If no match is found between the original position of the cursor and the beginning of the file the message `No match found.' will be given.

. (a period)

If the search is is executed from a learn buffer a macro or by means of the I command (p. [*]) and the search is unsuccessful no further execution will be attempted.

$[$col1,col2$]$

The search takes place only inside the specified range of columns (inclusive). If either number is omitted (the comma is relevant) it is set at its minimal or maximal value respectively.

Another useful search command, which is executed from the keyboard, is the `matching brackets' search. If the cursor is placed on any type of parenthesis or bracket and Alt-= is pressed, the matching bracket will be found and the cursor moved there. This holds for normal parentheses ( ( or ) ), and both square ( [ or ] ) and curly ( { or } ) brackets. If no match is found an error message is printed out on the message bar. This command can be extremely useful for finding unmatched sets of parentheses in a program.