Searching for some string known to appear in the text is a commonly used method of moving long distances in a file. Replacing occurrences of one pattern with another is a useful way to make many simple changes to text. Hemlock provides powerful commands for doing both of these operations. [annotate]
This variable determines the kind of search done by searching and replacing commands. [annotate] |
Incremental Search searches for an occurrence of a string after the current point. It is known as an incremental search because it reads key-events form the keyboard one at a time and immediately searches for the pattern of corresponding characters as you type. This is useful because it is possible to initially type in a very short pattern and then add more characters if it turns out that this pattern has too many spurious matches. [annotate] This command dispatches on the following key-events as sub-commands: [annotate]
Any key-event not corresponding to a graphic character, except those just described, causes the search to exit. Hemlock then uses the key-event in it normal command interpretation. [annotate] For example, typing C-a will exit the search and go to the beginning of the current line. When either of these commands successfully exits, they push the starting position (before the search) on the mark stack. If the current region was active when the search started, this foregoes pushing a mark. [annotate] |
These commands do a normal dumb string search, prompting for the search string in a normal dumb fashion. One reason for using a non-incremental search is that it may be faster since it is possible to specify a long search string from the very start. Since Hemlock uses the Boyer--Moore search algorithm, the speed of the search increases with the size of the search string. When either of these commands successfully exits, they push the starting position (before the search) on the mark stack. This is inhibited when the current region is active. [annotate] |
This command prompts in the echo area for a target string and a replacement string. It then searches for an occurrence of the target after the point. When it finds a match, it prompts for a key-event indicating what action to take. The following are valid responses: [annotate]
Any other key-event causes the command to exit, returning the key-event to the input stream; thus, Hemlock will interpret it normally for a command binding. [annotate] When the current region is active, this command uses it instead of the region from point to the end of the buffer. This is especially useful when you expect to use the ! option. [annotate] If the replacement string is all lowercase, then a heuristic is used that attempts to make the case of the replacement the same as that of the particular occurrence of the target pattern. If "foo" is being replaced with "bar" then "Foo" is replaced with "Bar" and "FOO" with "BAR". [annotate] This command may be undone with Undo, but its undoing may not be undone. On a successful exit from this command, the starting position (before the search) is pushed on the mark stack. [annotate] |
If this variable is true then the case preserving heuristic in Query Replace is enabled, otherwise all replacements are done with the replacement string exactly as specified. [annotate] |
This command is the same as Query Replace except it operates without ever querying the user before making replacements. After prompting for a target and replacement string, it replaces all occurrences of the target string following the point. If a prefix argument is specified, then only that many occurrences are replaced. When the current region is active, this command uses it instead of the region from point to the end of the buffer. [annotate] |
This command prompts for a search string and displays in a pop-up window all the lines containing the string that are after the point. If a prefix argument is specified, then this displays that many lines before and after each matching line. When the current region is active, this command uses it instead of the region from point to the end of the buffer. [annotate] |
Delete Matching Lines prompts for a search string and deletes all lines containing the string that are after the point. Similarly, Delete Non-Matching Lines deletes all lines following the point that do not contain the specified string. When the current region is active, these commands uses it instead of the region from point to the end of the buffer. [annotate] |