A SPC
char normally matches all whitespace defined by option
search-whitespace-regexp
. You can customize this option, so you get the matching you want by default. C-h v search-whitespace-regexp
tells us, in addition to more info about the option:
If the value is nil
, or [if]
isearch-lax-whitespace
is nil
for ordinary incremental search, or
isearch-regexp-lax-whitespace
is nil
for regexp incremental search, then each space you type matches literally, against one space.
Use key M-s SPC
during Isearch to toggle this behavior. C-h k M-s SPC
says:
isearch-toggle-lax-whitespace
is an interactive compiled Lisp function
in isearch.el
.
?
(isearch-toggle-lax-whitespace)
Toggle lax-whitespace searching on or off.
In ordinary search, toggles the value of the variable
isearch-lax-whitespace
. In regexp search, toggles the
value of the variable isearch-regexp-lax-whitespace
.
You can of course set the default values of those individual variables (they're not user options, however), to define the default behavior you prefer. But a mode etc. can change their values, overriding the values you set. (And a mode can change the value of search-whitespace-regexp
, though modes are generally not supposed to override user options.)
At least you can toggle the behavior at any time.
If you are seeing this only for Emacs version 24.3.1, do you also see the problem if you start that Emacs version using emacs -Q
(no init file)? If not then bisect your init file to find the culprit.
Not-so-well-known tip:
When regexp isearching, you can use C-q SPC
to search for a single space char at a time. No need to fiddle with any lax/strict whitespace matching.