false
false

Reputation: 10102

Making query-replace-regexp more responsive

C-h h!

It happens quite often to me that I try to C-M-% a text. Thus I use query-replace-regexp interactively. So I enter the search regex and Emacs asks meekly for the replacement text, when in fact my search regex does not match any text!

Ideally, I would like to be signaled as soon as possible that my regex does not match.

Is there a way out of this?

Upvotes: 1

Views: 48

Answers (1)

legoscia
legoscia

Reputation: 41548

One way to do this is to start with C-M-s, for isearch-forward-regexp, and interactively enter the regexp. That way, you'll see that it reaches the first match, and any further matches will be highlighted. Then, still in isearch mode, type C-M-%. The regexp from the isearch will automatically become the search regexp for the replacement command.

Upvotes: 3

Related Questions