[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

J.4 Interactive Highlighting by Matching

It is sometimes useful to highlight the strings that match a certain regular expression. For example, you might wish to see all the references to a certain variable in a program source file, or highlight certain parts in a voluminous output of some program, or make certain cliches stand out in an article.

Use the M-x hi-lock-mode command to turn on a minor mode that allows you to specify regular expressions of the text to be highlighted. Hi-lock mode works like Font Lock (see section J.2 Font Lock mode), except that it lets you specify explicitly what parts of text to highlight. You control Hi-lock mode with these commands:

C-x w h regexp RET face RET
Highlight text that matches regexp using face face (highlight-regexp). By using this command more than once, you can highlight various parts of the text in different ways.

C-x w r regexp RET
Unhighlight regexp (unhighlight-regexp). You must enter one of the regular expressions currently specified for highlighting. (You can use completion, or choose from a menu, to enter one of them conveniently.)

C-x w l regexp RET face RET
Highlight entire lines containing a match for regexp, using face face (highlight-lines-matching-regexp).

C-x w b
Insert all the current highlighting regexp/face pairs into the buffer at point, with comment delimiters to prevent them from changing your program. This key binding runs the hi-lock-write-interactive-patterns command.

These patterns will be read the next time you visit the file while Hi-lock mode is enabled, or whenever you use the M-x hi-lock-find-patterns command.

C-x w i
Re-read regexp/face pairs in the current buffer (hi-lock-write-interactive-patterns). The list of pairs is found no matter where in the buffer it may be.

This command does nothing if the major mode is a member of the list hi-lock-exclude-modes.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 2, 2002 using texi2html