Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: replace regexp with per-match prompt

Tags:

regex

emacs

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).

like image 465
wap26 Avatar asked May 23 '12 08:05

wap26


1 Answers

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

like image 67
tripleee Avatar answered Sep 25 '22 03:09

tripleee