Mac – Emacs: How to make regexp search the default for C-s

emacsregexsearch

How can I change Emacs so that the regexp search (instead of normal search) is the default?

I would like to be able to type C-s [0-9], for example, and it takes me to the next number. Then, press C-s again, and it takes me to the next number.

I tried this:

(global-set-key "\C-s" 'search-forward-regexp)

But the repeated pressing of C-s does not work. It does find the first occurrence, but to find the second you have to re-enter the regexp [0-9] after pressing C-s.

Best Answer

You're close - use isearch-forward-regexp - note the 'i'.

Found via 'C-h k C-M-s' which is bound to interactive regexp search forward.

Related Question