6
votes

Emacs 23.3 is said to allow prompting part of the replacement string on each match, via the \? syntax.

The string should be prompted in the mini-buffer.

This feature is described here: http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Replace.html

I tried the simple replacement (query-replace-regexp "^" "\\?") with Emacs 23.3 on Windows, but I get a "Invalid use of `\' in replacement text" error.

Any idea on how I should use this feature ?

Note: I could use \,(read-from-minibuffer "? ") instead but doing so prompts for a string before highlighting the match.

I don't think it matters, but my version of Emacs is the following: GNU Emacs 23.3.1 (i386-mingw-nt6.1.7601).

1

1 Answers

9
votes

This is a feature of replace-regexp, not query-replace-regexp. (Didn't know about this feature; thanks for highlighting it!)