Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit the previous search string in emacs query-replace?

Tags:

emacs

When using query-replace (with or without regexp) in emacs, the previous query-replace pair is remembered and suggested as default the next time query-replace is invoked. But I would like to be able to edit this default replacement to something similar without having to type the entire new variant.

Like this:

in a section of a long document I do a query-replace

M-% antidisestablishmentarianism-A [return] antidisestablismentarianism-B

later on in the same document I want to do

M-% antidisestablishmentarianism-A [return] antidisestablismentarianism-C

The command M-% on its own gives

Query-replace (default antidisestablishmentarianism-A -> antidisestablismentarianism-B):

Is there some magic key combination which makes it possible to change that final "B" to a "C" without retyping?

like image 257
Alice Lesser Avatar asked May 02 '13 14:05

Alice Lesser


1 Answers

Yah, try M-p, something like this sequence

M-% M-p [return] M-p [DEL] C [return]
like image 103
Trey Jackson Avatar answered Nov 02 '22 19:11

Trey Jackson