2

I just installed a new version of Emacs (24.3.1 through Fedora). For some reason, when I use C-s to search for a single space character, it jumps my cursor to the end of contiguous spaces rather than the beginning. For example, if I'm at the start of this line:

type thread_id        = ...

and do C-s SPC, all the spaces in the buffer are highlighted. But when I advance up to the spaces before the =, my cursor is immediately positioned on the = rather than after the first space (ie two positions after the end of thread_id).

How can I get my cursor to be at the first single character rather than the end of the range?

4

The Emacs Manual (section Special Isearch) says this:

By default, incremental search performs lax space matching: each space, or sequence of spaces, matches any sequence of one or more spaces in the text. Hence, "foo bar" matches "foo bar", "foo bar", "foo bar", and so on (but not "foobar"). More precisely, Emacs matches each sequence of space characters in the search string to a regular expression specified by the variable search-whitespace-regexp. For example, to make spaces match sequences of newlines as well as spaces, set it to "[[:space:]\n]+".

To toggle lax space matching, type M-s <SPC> (isearch-toggle-lax-whitespace). To disable this feature entirely, change search-whitespace-regexp to nil; then each space in the search string matches exactly one space.

So, set search-whitespace-regexp to nil (or set isearch-lax-whitespace to nil -- it seems to have the same effect).

  • Yep, that seems to solve it. Odd that I've never run into this before if it's been a default... – Tikhon Jelvis Dec 6 '14 at 0:42
  • 1
    It was not the default behavior in older versions of Emacs. – Drew Dec 6 '14 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.