Next: , Previous: , Up: Search   [Contents][Index]


12.3 Word Search

Word search looks for a sequence of words without regard to how the words are separated. More precisely, you type a string of many words, using single spaces to separate them, and the string is found even if there are multiple spaces, newlines or other punctuation between the words.

Word search is useful in editing documents formatted by text formatters. If you edit while looking at the printed, formatted version, you can’t tell where the line breaks are in the source file. Word search, allows you to search without having to know the line breaks.

C-s RET C-w words RET

Search for words, ignoring differences in punctuation.

C-r RET C-w words RET

Search backward for words, ignoring differences in punctuation.

Word search is a special case of non-incremental search. It is invoked with C-s RET C-w followed by the search string, which must always be terminated with another RET. Being non-incremental, this search does not start until the argument is terminated. It works by constructing a regular expression and searching for that. See Regexp Search.

You can do a backward word search with C-r RET C-w.

Forward and backward word searches are implemented by the commands word-search-forward and word-search-backward. You can bind these commands to keys. The reason that incremental search is programmed to invoke them as well is that C-s RET C-w is the traditional Emacs sequence of keys for word search.