Function: isearch-forward

isearch-forward is an interactive and byte-compiled function defined in isearch.el.gz.

Signature

(isearch-forward &optional REGEXP-P NO-RECURSIVE-EDIT)

Documentation

Do incremental search forward.

With a prefix argument, do an incremental regular expression search instead. As you type characters, they add to the search string and are found. The following non-printing keys are bound in isearch-mode-map.

Type DEL (isearch-delete-char) to cancel last input item from end of search string. Type RET (isearch-exit) to exit, leaving point at location found. Type LFD (C-j) to match end of line. Type C-s (isearch-repeat-forward) to search again forward, C-r (isearch-repeat-backward) to search again backward. Type M-s M-< (isearch-beginning-of-buffer) to go to the first match, M-s M-> (isearch-end-of-buffer) to go to the last match. Type C-w (isearch-yank-word-or-char) to yank next word or character in buffer
  onto the end of the search string, and search for it.
Type C-M-d (isearch-del-char) to delete character from end of search string. Type C-M-y (isearch-yank-char) to yank char from buffer onto end of search string and search for it. Type C-M-z (isearch-yank-until-char) to yank from point until the next instance of a
 specified character onto end of search string and search for it.
Type M-s C-e (isearch-yank-line) to yank rest of line onto end of search string and search for it. Type C-y (isearch-yank-kill) to yank the last string of killed text. Type M-y (isearch-yank-pop-only) to replace string just yanked into search prompt
 with string killed before it.
Type C-q (isearch-quote-char) to quote control character to search for it. Type C-x 8 RET (isearch-char-by-name) to add a character to search by Unicode name, with completion. C-g (isearch-abort) while searching or when search has failed cancels input back to what has
 been found successfully.
C-g (isearch-abort) when search is successful aborts and moves point to starting point.

If you try to exit with the search string still empty, it invokes
 nonincremental search.

Type M-s c (isearch-toggle-case-fold) to toggle search case-sensitivity. Type M-s i (isearch-toggle-invisible) to toggle search in invisible text. Type M-s r (isearch-toggle-regexp) to toggle regular-expression mode. Type M-s w (isearch-toggle-word) to toggle word mode. Type M-s _ (isearch-toggle-symbol) to toggle symbol mode. Type M-s ' (isearch-toggle-char-fold) to toggle character folding.

Type M-s SPC (isearch-toggle-lax-whitespace) to toggle whitespace matching. In incremental searches, a space or spaces normally matches any whitespace defined by the variable search-whitespace-regexp; see also the variables isearch-lax-whitespace and isearch-regexp-lax-whitespace.

Type M-s e (isearch-edit-string) to edit the search string in the minibuffer.

Also supported is a search ring of the previous 16 search strings. Type M-n (isearch-ring-advance) to search for the next item in the search ring. Type M-p (isearch-ring-retreat) to search for the previous item in the search ring. Type C-M-i (isearch-complete) to complete the search string using the search ring.

Type M-% (isearch-query-replace) to run query-replace with string to replace from last search string. Type C-M-% (isearch-query-replace-regexp) to run query-replace-regexp with the last search string. Type M-s o (isearch-occur) to run occur that shows the last search string. Type M-s h r (isearch-highlight-regexp) to run highlight-regexp that highlights the last search string. Type M-s h l (isearch-highlight-lines-matching-regexp) to run highlight-lines-matching-regexp that highlights lines
 matching the last search string.

Type C-h b (isearch-describe-bindings) to display all Isearch key bindings. Type C-h k (isearch-describe-key) to display documentation of Isearch key. Type C-h m (isearch-describe-mode) to display documentation of Isearch mode.

If an input method is turned on in the current buffer, that input method is also active while you are typing characters to search. To toggle the input method, type C-\ (isearch-toggle-input-method). It also toggles the input method in the current buffer.

To use a different input method for searching, type C-^ (isearch-toggle-specified-input-method), and specify an input method you want to use.

To activate a transient input method, type C-x \ (isearch-transient-input-method).

The above keys, bound in isearch-mode-map, are often controlled by
 options; do M-x apropos (apropos) on search-.* to find them.
Other control and meta characters terminate the search
 and are then executed normally (depending on search-exit-option).
Likewise for function keys and mouse button events.

If this function is called non-interactively with a nil NO-RECURSIVE-EDIT, it does not return to the calling function until the search is done. See the function isearch-mode(var)/isearch-mode(fun) for more information.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/isearch.el.gz
;; Entry points to isearch-mode.

(defun isearch-forward (&optional regexp-p no-recursive-edit)
  "\
Do incremental search forward.
With a prefix argument, do an incremental regular expression search instead.
\\<isearch-mode-map>
As you type characters, they add to the search string and are found.
The following non-printing keys are bound in `isearch-mode-map'.

Type \\[isearch-delete-char] to cancel last input item from end of search string.
Type \\[isearch-exit] to exit, leaving point at location found.
Type LFD (C-j) to match end of line.
Type \\[isearch-repeat-forward] to search again forward,\
 \\[isearch-repeat-backward] to search again backward.
Type \\[isearch-beginning-of-buffer] to go to the first match,\
 \\[isearch-end-of-buffer] to go to the last match.
Type \\[isearch-yank-word-or-char] to yank next word or character in buffer
  onto the end of the search string, and search for it.
Type \\[isearch-del-char] to delete character from end of search string.
Type \\[isearch-yank-char] to yank char from buffer onto end of search\
 string and search for it.
Type \\[isearch-yank-until-char] to yank from point until the next instance of a
 specified character onto end of search string and search for it.
Type \\[isearch-yank-line] to yank rest of line onto end of search string\
 and search for it.
Type \\[isearch-yank-kill] to yank the last string of killed text.
Type \\[isearch-yank-pop-only] to replace string just yanked into search prompt
 with string killed before it.
Type \\[isearch-quote-char] to quote control character to search for it.
Type \\[isearch-char-by-name] to add a character to search by Unicode name,\
 with completion.
\\[isearch-abort] while searching or when search has failed cancels input\
 back to what has
 been found successfully.
\\[isearch-abort] when search is successful aborts and moves point to\
 starting point.

If you try to exit with the search string still empty, it invokes
 nonincremental search.

Type \\[isearch-toggle-case-fold] to toggle search case-sensitivity.
Type \\[isearch-toggle-invisible] to toggle search in invisible text.
Type \\[isearch-toggle-regexp] to toggle regular-expression mode.
Type \\[isearch-toggle-word] to toggle word mode.
Type \\[isearch-toggle-symbol] to toggle symbol mode.
Type \\[isearch-toggle-char-fold] to toggle character folding.

Type \\[isearch-toggle-lax-whitespace] to toggle whitespace matching.
In incremental searches, a space or spaces normally matches any whitespace
defined by the variable `search-whitespace-regexp'; see also the variables
`isearch-lax-whitespace' and `isearch-regexp-lax-whitespace'.

Type \\[isearch-edit-string] to edit the search string in the minibuffer.

Also supported is a search ring of the previous 16 search strings.
Type \\[isearch-ring-advance] to search for the next item in the search ring.
Type \\[isearch-ring-retreat] to search for the previous item in the search\
 ring.
Type \\[isearch-complete] to complete the search string using the search ring.

Type \\[isearch-query-replace] to run `query-replace' with string to\
 replace from last search string.
Type \\[isearch-query-replace-regexp] to run `query-replace-regexp'\
 with the last search string.
Type \\[isearch-occur] to run `occur' that shows\
 the last search string.
Type \\[isearch-highlight-regexp] to run `highlight-regexp'\
 that highlights the last search string.
Type \\[isearch-highlight-lines-matching-regexp] to run\
 `highlight-lines-matching-regexp' that highlights lines
 matching the last search string.

Type \\[isearch-describe-bindings] to display all Isearch key bindings.
Type \\[isearch-describe-key] to display documentation of Isearch key.
Type \\[isearch-describe-mode] to display documentation of Isearch mode.

If an input method is turned on in the current buffer, that input
method is also active while you are typing characters to search.
To toggle the input method, type \\[isearch-toggle-input-method].  \
It also toggles the input
method in the current buffer.

To use a different input method for searching, type \
\\[isearch-toggle-specified-input-method],
and specify an input method you want to use.

To activate a transient input method, type \\[isearch-transient-input-method].

The above keys, bound in `isearch-mode-map', are often controlled by
 options; do \\[apropos] on search-.* to find them.
Other control and meta characters terminate the search
 and are then executed normally (depending on `search-exit-option').
Likewise for function keys and mouse button events.

If this function is called non-interactively with a nil NO-RECURSIVE-EDIT,
it does not return to the calling function until the search is done.
See the function `isearch-mode' for more information."

  (interactive "P\np")
  (isearch-mode t (not (null regexp-p)) nil (not no-recursive-edit)))