Function: search-forward

search-forward is an interactive function defined in search.c.

Signature

(search-forward STRING &optional BOUND NOERROR COUNT)

Documentation

Search forward from point for STRING.

Set point to the end of the occurrence found, and return point. An optional second argument bounds the search; it is a buffer position.
  The match found must not end after that position. A value of nil
  means search to the end of the accessible portion of the buffer.
Optional third argument, if t, means if fail just return nil (no error).
  If not nil and not t, move to limit of search and return nil.
Optional fourth argument COUNT, if a positive number, means to search
  for COUNT successive occurrences. If COUNT is negative, search
  backward, instead of forward, for -COUNT occurrences. A value of
  nil means the same as 1.
With COUNT positive, the match found is the COUNTth one (or first,
  if COUNT is 1 or nil) in the buffer located entirely after the
  origin of the search; correspondingly with COUNT negative.

Search case-sensitivity is determined by the value of the variable case-fold-search, which see.

See also the functions match-beginning, match-end and replace-match.

Other relevant functions are documented in the buffer group.

View in manual

Probably introduced at or before Emacs version 18.

Key Bindings

Shortdoc

;; buffer
(search-forward "some-string" nil t)
    e.g. => 245

Source Code

// Defined in /usr/src/emacs/src/search.c
{
  return search_command (string, bound, noerror, count, 1, 0, 0);
}