A symbol search is much like an ordinary search, except that the boundaries of the search must match the boundaries of a symbol. The meaning of symbol in this context depends on the major mode, and usually refers to a source code token, such as a Lisp symbol in Emacs Lisp mode. For instance, if you perform an incremental symbol search for the Lisp symbol
forward-word, it would not match
isearch-forward-word. This feature is thus mainly useful for searching source code.
If incremental search is active, toggle symbol search mode (
isearch-toggle-symbol); otherwise, begin an incremental forward symbol search (
Start a symbol incremental search forward with the symbol found near point added to the search string initially.
M-s _ RET symbol RET
Search forward for
M-s _ C-r RET symbol RET
Search backward for
To begin a forward incremental symbol search, type
M-s _ (or
M-s . if the symbol to search is near point). If incremental search is not already active,
M-s _ runs the command
M-s . runs the command
isearch-forward-symbol-at-point. With a numeric prefix argument of
M-s . will search for the
nthe next occurrence of the symbol at point; negative values of
n search backwards. If incremental search is already active,
M-s _ switches to a symbol search, preserving the direction of the search and the current search string; you can disable symbol search by typing
M-s _ again. In incremental symbol search, while you are typing the search string, only the beginning of the search string is required to match the beginning of a symbol, and ‘
Pending’ appears in the search prompt until you use a search repeating key like
To begin a nonincremental symbol search, type
M-s _ RET for a forward search, or
M-s _ C-r RET or a backward search. In nonincremental symbol searches, the beginning and end of the search string are required to match the beginning and end of a symbol, respectively.
The symbol search commands don’t perform character folding, and toggling lax whitespace matching (see lax space matching) has no effect on them.