help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to search a whole word in emacs?


From: Drew Adams
Subject: RE: How to search a whole word in emacs?
Date: Fri, 26 Oct 2007 15:05:08 -0700

>     I need to search  a whole word in a big file. For example, I need to
>     search "Machine" but I don't need to know anything like
>     "machine_state", "running_machine_state" etc. The search shall be case
>     sensitive.
>
>     I've tried C-s ret C-w Machine but it returns every word with
>     "Machine" in it. I just need the exact word.

Assuming that "ret" means hit the Enter key (usually written RET), that
should work fine (assuming you also follow it by another RET). It should not
find "Machine" in the middle of other words; it should find it only as a
whole word. It is a non-incremental search, however, which is usually less
convenient than incremental search.

> You want either M-C-s \ b M a c h i n e \ b

That's incremental and works fine, but can be a bit hard to remember.

> or perhaps M-x word-search-forward RET Machine RET

Aother way to do incremental word search (also a bit hard to remember):

 C-s M-e C-w  M a c h i n e  C-s

Starting with Emacs 22, this is documented in the Emacs manual (node Word
Search).

Another way, if you use Isearch+
(http://www.emacswiki.org/cgi-bin/wiki/IsearchPlus):

 C-s M-w  M a c h i n e

This (`isearch-toggle-word') is from Juri Linkov, BTW. I thought it was
going to be added to Emacs a year ago, but it looks like it never was. Too
bad. An advantage is that `M-w' is a toggle between word and non-word
search - use it at any time.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]