search word under cursor in emacs

On Aug 22, 4:07 am, lichtkind wrote:
> Hello,
> I have marked a string. Now I want to search for this string in the
> whole text. I know that I can search with C-R or C-S. and type in the
> searchstring. I'm looking for a way, that the marked string is
> automatic the searchstring. This should also work for the other
> search/ search and replace types.

if u are using emacs 22, then you can do this:

“Ctrl+s Ctrl+w”. This will search the current word, but you must move your cursor to the beginning of the word first.

In emacs 23, the above is deprecated. Basically, now you start it with M-s as prefix, then press some other key. It's rather complex and very not intuitive. I have 10 years of using emacs, but i did spent some 5 or 10 min reading the release notes... but i haven't figured it out.

You can, type M-s then C-h, to get a list of shortcuts that has M-s as start. You can read their command names there.

here's the output:

Global Bindings Starting With M-s:
key binding
--- -------

M-s h Prefix Command
M-s o occur
M-s w isearch-forward-word

M-s h f hi-lock-find-patterns
M-s h l highlight-lines-matching-regexp
M-s h p highlight-phrase
M-s h r highlight-regexp
M-s h u unhighlight-regexp
M-s h w hi-lock-write-interactive-patterns

ok, i just gave another try with M-s w. Spent another 2 min on this. Dunno what the fuck it is going.

someday i'll give a hour or two on this, maybe then i'll know the answer.

∑ http://xahlee.org/


  1. thanks i was looking for a solution to this but isn't C-w supposed to kill region ... care to explain it a bit.

  2. @awhan
    sorry didn't see this till now.

    yes C-w normally kill region.
    C-s C-w is just special case i guess...

  3. Tried with emacs-24.1 (c-s + c-w) it worked as you explained above for emacs 22