Книга: Learning GNU Emacs, 3rd Edition

3.1.3 Word Search

3.1.3 Word Search

If you're searching for a phrase and you know it's in the file but you can't find it with incremental search, try word search. (You probably can't find your phrase with incremental search because the phrase has a line break in it.) Word search is a nonincremental search that ignores line breaks, spaces, and punctuation. It also requires that your search string match entire words in the file.

To do a word search, type C-s Enter C-w (for word-search-forward). The prompt Word search appears in the minibuffer. (Don't be put off by the prompts that appear along the way: you'll see an I-search prompt after typing C-s and a Search prompt after pressing Enter. Ignore these.) Type the search string and press Enter. Emacs searches for the given string. To do a word search backwards, type C-r Enter C-w instead. For example, assume that you have the following text, with the cursor at the beginning:

He said, "All good elephants are wise, aren't they?"
She answered, "Some are smarter than others, but we
think this is socially conditioned."

The command C-s Enter C-w they she Enter positions the cursor after the word She. This command looks complicated, but it's really nothing more than a word search (C-s Enter C-w) for the word they, followed by the word she. It ignores the punctuation (?") and the newline between they and she.

Assume that you're looking for the word the. You don't want to bother with thence, there, theater, thesis, blithe, or any other word that happens to contain the letters the. In this situation, neither an incremental search nor a simple search is very useful—you need a word search. If you're writing a paper, word search is often exactly what you need. It is the only one of the three basic search commands that allows you to find what you want even if the phrase is split between two lines.

Now that you've seen the three most commonly used searches, you might want to experiment and see which you find most useful.

Оглавление книги

Оглавление статьи/книги

Генерация: 0.081. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз