GNU Emacs
Emacs
Dashboard

A word search finds a sequence of words without regard to the type of punctuation between them. For instance, if you enter a search string that consists of two words separated by a single space, the search matches any sequence of those two words separated by one or more spaces, newlines, or other punctuation characters. This is particularly useful for searching text documents, because you don’t have to worry whether the words you are looking for are separated by newlines or spaces. Note that major modes for programming languages or other specialized modes can modify the definition of a word to suit their syntactic needs.

M-s w

If incremental search is active, toggle word search mode ( isearch-toggle-word); otherwise, begin an incremental forward word search ( isearch-forward-word).

M-s w RET words RET

Search for words, using a forward nonincremental word search.

M-s w C-r RET words RET

Search backward for words, using a nonincremental word search.

M-s M-w

Search the Web for the text in region.

To begin a forward incremental word search, type M-s w. If incremental search is not already active, this runs the command isearch-forward-word. If incremental search is already active (whether a forward or backward search), M-s w runs the command isearch-toggle-word, which switches to a word search while keeping the direction of the search and the current search string unchanged. You can toggle word search back off by typing M-s w again.

To begin a nonincremental word search, type M-s w RET for a forward search, or M-s w C-r RET for a backward search. These run the commands word-search-forward and word-search-backward respectively.

Incremental and nonincremental word searches differ slightly in the 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 (see Incremental Search), which always matches whole words. While you are typing the search string, ‘ Pending’ appears in the search prompt until you use a search repeating key like C-s.

The word search commands don’t perform character folding, and toggling lax whitespace matching (see lax space
matching
) has no effect on them.

To search the Web for the text in region, type M-s M-w. This command performs an Internet search for the words in region using the search engine whose URL is specified by the variable eww-search-prefix (see EWW in The Emacs Web Wowser Manual). If the region is not active, or doesn’t contain any words, this command prompts the user for a URL or keywords to search.