7

Assuming familiarity with regex, is there ever any reason to use the normal incremental search (C-s) over regex (C-M-s)?

  • No reason at all. – abo-abo Jul 2 '15 at 12:32
  • 6
    I usually start with C-s, and if I need regexs I press M-r to switch it to regexp mode. – Adobe Jul 2 '15 at 13:17
7

Yes: if you want to search for a literal string, but that string contains special regex characters, it'll require extra escaping on your part.

Example text to search: "some*text"

  • C-s some*text matches
  • C-M-s some*text does not match
  • C-M-s some\*text matches
4

@Dan provided a good answer to the question. I will add this:

As @Adobe indicated in a comment, you can use M-r anytime during Isearch (literal search or regexp search) to toggle between regexp search and literal search. Easy-peasy.

This means that it can make sense to start with whichever search mode you expect to use first, or most, and just toggle to the other as needed.

What's more, literal Isearch is not so "heavy maintenance" as regexp Isearch: what you type is directly and immediately what you get. So generally, yes, I would say that it makes sense much of the time to start with C-s, not C-M-s.

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.