Next: Symbol Search, Previous: Nonincremental Search, Up: Searching and Replacement [Contents][Index]
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.
If incremental search is active, toggle word search mode
(isearch-toggle-word
); otherwise, begin an incremental forward
word search (isearch-forward-word
).
Search for words, using a forward nonincremental word search.
Search backward for words, using a nonincremental word search.
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.
You can also search for definitions of a word by querying dictionary
servers via the DICT protocol defined by RFC 2229. Emacs
includes a client for this protocol. Type M-x dictionary-search RET to connect to a DICT server and ask it to provide the
available definitions of a word. This command prompts for the word to
look up, using the word at point as the default, then asks the DICT
server to provide the definitions of that word in one or more
dictionaries. By default, the command first tries to connect to the
DICT server installed on the local host, and if that fails, it
tries dict.org after asking for confirmation; customize the variable
dictionary-server
to specify, as a string, the URL of a single
server to use (use ‘localhost’ if you want to query only the local
server). Normally, dictionary-search
tells the server to look up
the word in all the dictionaries available to the server, but if you
invoke the command with a prefix argument, it will prompt for a single
dictionary to use. The list of dictionaries available to a server can
be displayed by pressing the ‘Select dictionary’ button shown in
the *Dictionary* buffer, described below.
The first time you use dictionary-search
, it creates a new
*Dictionary* buffer and turns on a special mode in it. The
buffer shows buttons for selecting a dictionary, searching a definition
of another word, etc. Subsequent dictionary-search
commands
reuse this buffer. To create another such buffer (e.g., to look up
other words, perhaps in another dictionary), type M-x dictionary RET.
If you turn on dictionary-tooltip-mode
in a buffer, Emacs will
look up the definitions of the word at mouse pointer and show those
definitions in a tool tip. This is handy when you are reading text with
many words about whose meaning you are unsure.
For other options of dictionary-search, see the dictionary
customization group (see Customizing Specific Items).
Next: Symbol Search, Previous: Nonincremental Search, Up: Searching and Replacement [Contents][Index]