When searching using:
C-s SPC SPC
Also matches single spaces. I want to match exactly two space.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
M-s SPC during Isearch to toggle matching whitespace literally. When matching literally, each
SPC char you type is matched individually. (This used to be the default Emacs behavior, BTW.)
To configure this as the default behavior customize option
M-x customize-option search-whitespace-regexp.)
See the GNU Emacs manual, node
Using regexp incremental search solves the problem, if you escape the space characters:
You can also use search and replace without the backslashes, if that's what you're after:
M-% SPC SPC
Using regexp search helps, but you can also make sure of literal spaces for the search using C-q SPC to quote a space into the search.
To riff off of @Rovanion's answer then, using
C-M-s C-q SPC C-q SPC
That will search for two consecutive spaces. Interestingly,
isearch-forward-regexp requires discrete matches. Searching
aa will only match once and not again at the second character.