@c This is part of the Emacs manual.
-@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2013 Free Software
+@c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2014 Free Software
@c Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node Search
the cursor moves to just after the first @samp{FOO}.
@cindex faces for highlighting search matches
+@cindex isearch face
At each step, Emacs highlights the @dfn{current match}---the buffer
text that matches the search string---using the @code{isearch} face
(@pxref{Faces}). The current search string is also displayed in the
@samp{foo bar}, @samp{foo bar}, and so on (but not @samp{foobar}).
More precisely, Emacs matches each sequence of space characters in the
search string to a regular expression specified by the variable
-@code{search-whitespace-regexp}. For example, set it to
-@samp{"[[:space:]\n]+"} to make spaces match sequences of newlines as
-well as spaces. To toggle lax space matching, type @kbd{M-s SPC}
+@code{search-whitespace-regexp}. For example, to make spaces match
+sequences of newlines as well as spaces, set it to
+@samp{"[[:space:]\n]+"}.
+
+ To toggle lax space matching, type @kbd{M-s @key{SPC}}
(@code{isearch-toggle-lax-whitespace}). To disable this feature
entirely, change @code{search-whitespace-regexp} to @code{nil}; then
-each space in the search string matches exactly one space
+each space in the search string matches exactly one space.
If the search string you entered contains only lower-case letters,
the search is case-insensitive; as long as an upper-case letter exists
delete the upper-case character from the search string, it ceases to
have this effect. @xref{Search Case}.
+@cindex invisible text, searching for
+@kindex M-s i @r{(Incremental search)}
+@findex isearch-toggle-invisible
+ To toggle whether or not invisible text is searched, type
+@kbd{M-s i} (@code{isearch-toggle-invisible}). @xref{Outline Search}.
+
To search for a newline character, type @kbd{C-j}.
- To search for other control characters, such as @key{control-S},
-quote it by typing @kbd{C-q} first (@pxref{Inserting Text}). To
-search for non-@acronym{ASCII} characters, you can either use
-@kbd{C-q} and enter its octal code, or use an input method
-(@pxref{Input Methods}). If an input method is enabled in the current
-buffer when you start the search, you can use it in the search string
-also. While typing the search string, you can toggle the input method
-with the command @kbd{C-\} (@code{isearch-toggle-input-method}). You
-can also turn on a non-default input method with @kbd{C-^}
+ To search for non-@acronym{ASCII} characters, use one of the
+following methods:
+
+@itemize @bullet
+@item
+Type @kbd{C-q}, followed by a non-graphic character or a sequence of
+octal digits. This adds a character to the search string, similar to
+inserting into a buffer using @kbd{C-q} (@pxref{Inserting Text}). For
+example, @kbd{C-q C-s} during incremental search adds the
+@samp{control-S} character to the search string.
+
+@item
+Type @kbd{C-x 8 @key{RET}}, followed by a Unicode name or code-point.
+This adds the specified character into the search string, similar to
+the usual @code{insert-char} command (@pxref{Inserting Text}).
+
+@item
+Use an input method (@pxref{Input Methods}). If an input method is
+enabled in the current buffer when you start the search, you can use
+it in the search string also. While typing the search string, you can
+toggle the input method with @kbd{C-\}
+(@code{isearch-toggle-input-method}). You can also turn on a
+non-default input method with @kbd{C-^}
(@code{isearch-toggle-specified-input-method}), which prompts for the
name of the input method. When an input method is active during
incremental search, the search prompt includes the input method
where @var{im} is the mnemonic of the active input method. Any input
method you enable during incremental search remains enabled in the
current buffer afterwards.
+@end itemize
@kindex M-% @r{(Incremental search)}
Typing @kbd{M-%} in incremental search invokes @code{query-replace}
or @code{query-replace-regexp} (depending on search mode) with the
-current search string used as the string to replace. @xref{Query
-Replace}.
+current search string used as the string to replace. A negative
+prefix argument means to replace backward. @xref{Query Replace}.
@kindex M-TAB @r{(Incremental search)}
Typing @kbd{M-@key{TAB}} in incremental search invokes
@findex isearch-yank-line
Similarly, @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest
of the current line to the search string. If point is already at the
-end of a line, it appends the next line.
+end of a line, it appends the next line. With a prefix argument
+@var{n}, it appends the next @var{n} lines.
If the search is currently case-insensitive, both @kbd{C-w} and
@kbd{M-s C-e} convert the text they copy to lower case, so that the
@code{word-search-backward} respectively.
Incremental and nonincremental word searches differ slightly in the
-way they find a match. In a nonincremental word search, the last word
-in the search string must exactly match a whole word. In an
-incremental word search, the matching is more lax: the last word in
-the search string can match part of a word, so that the matching
-proceeds incrementally as you type. This additional laxity does not
-apply to the lazy highlight, which always matches whole words.
+way they find a match. In a nonincremental word search, each word in
+the search string must exactly match a whole word. In an incremental
+word search, the matching is more lax: while you are typing the search
+string, its first and last words need not match whole words. This is
+so that the matching can proceed incrementally as you type. This
+additional laxity does not apply to the lazy highlight, which always
+matches whole words.
@node Symbol Search
@section Symbol Search
They also have separate search rings, which you can access with
@kbd{M-p} and @kbd{M-n}.
- Just as in ordinary incremental search, any @key{SPC} typed in
-incremental regexp search matches any sequence of one or more
-whitespace characters. The variable @code{search-whitespace-regexp}
-specifies the regexp for the lax space matching, and @kbd{M-s SPC}
-(@code{isearch-toggle-lax-whitespace}) toggles the feature.
-@xref{Special Isearch}.
+ Unlike ordinary incremental search, incremental regexp search
+do not use lax space matching by default. To toggle this feature
+use @kbd{M-s @key{SPC}} (@code{isearch-toggle-lax-whitespace}).
+Then any @key{SPC} typed in incremental regexp search will match
+any sequence of one or more whitespace characters. The variable
+@code{search-whitespace-regexp} specifies the regexp for the lax
+space matching. @xref{Special Isearch}.
In some cases, adding characters to the regexp in an incremental
regexp search can make the cursor move back and start again. For
well as to string search. The effect ceases if you delete the
upper-case letter from the search string.
- Typing @kbd{M-c} within an incremental search toggles the case
-sensitivity of that search. The effect does not extend beyond the
-current incremental search to the next one, but it does override the
-effect of adding or removing an upper-case letter in the current
-search.
-
@vindex case-fold-search
If you set the variable @code{case-fold-search} to @code{nil}, then
all letters must match exactly, including case. This is a per-buffer
performed by the replace commands (@pxref{Replace}) and the minibuffer
history matching commands (@pxref{Minibuffer History}).
+@c isearch-toggle-case-fold
+ Typing @kbd{M-c} within an incremental search toggles the case
+sensitivity of that search. The effect does not extend beyond the
+current incremental search to the next one, but it does override the
+effect of adding or removing an upper-case letter in the current
+search.
+
Several related variables control case-sensitivity of searching and
matching for specific commands or activities. For instance,
@code{tags-case-fold-search} controls case sensitivity for
(@pxref{Unconditional Replace}). In particular, it preserves case
provided @code{case-replace} is non-@code{nil}, as it normally is
(@pxref{Replacement and Case}). A numeric argument means to consider
-only occurrences that are bounded by word-delimiter characters.
+only occurrences that are bounded by word-delimiter characters. A
+negative prefix argument replaces backward.
@kindex C-M-%
@findex query-replace-regexp
like @code{query-replace}.
@cindex faces for highlighting query replace
+@cindex query-replace face
+@cindex lazy-highlight face
These commands highlight the current match using the face
@code{query-replace}. They highlight other matches using
@code{lazy-highlight} just like incremental search (@pxref{Incremental
@item Y @r{(Upper-case)}
to replace all remaining occurrences in all remaining buffers in
-multi-buffer replacements (like the Dired `Q' command which performs
+multi-buffer replacements (like the Dired @key{Q} command that performs
query replace on selected files). It answers this question and all
subsequent questions in the series with "yes", without further
user interaction.
used the minibuffer to read its arguments. @xref{Repetition, C-x ESC
ESC}.
+@cindex invisible text, and query-replace
+ The option @code{search-invisible} determines how @code{query-replace}
+treats invisible text. @xref{Outline Search}.
+
@xref{Operating on Files}, for the Dired @kbd{Q} command which
performs query replace on selected files. See also @ref{Transforming
File Names}, for Dired commands to rename, copy, or link files by
This command is just like @code{multi-isearch-buffers}, except it
performs an incremental regexp search.
+@item M-x multi-isearch-files
+Prompt for one or more file names, ending with @key{RET}; then,
+begin a multi-file incremental search in those files. (If the
+search fails in one file, the next @kbd{C-s} tries searching the
+next specified file, and so forth.) With a prefix argument, prompt
+for a regexp and begin a multi-file incremental search in files
+matching that regexp.
+
+@item M-x multi-isearch-files-regexp
+This command is just like @code{multi-isearch-files}, except it
+performs an incremental regexp search.
+
+In some modes that set the buffer-local variable
+@code{multi-isearch-next-buffer-function} (e.g., in Change Log mode)
+a multi-file incremental search is activated automatically.
+
@cindex Occur mode
@cindex mode, Occur
@item M-x occur