Change previous search string in emacs query-replace?

When using query-replace (with or without regexp) in emacs, the previous query replacement pair is remembered and offered by default the next time query-replace is called. But I would like to be able to edit this default replacement with something like this without entering a whole new option.

Like this:

in the section of a long document I execute a replacement request

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

further in the same document that I want to do

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

The M-% team alone gives

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

Is there any magic key combination that allows me to change this final “B” to “C” without redialing?

+4
source share
2 answers

Yes, try Mp , something like this sequence

 M-% Mp [return] Mp [DEL] C [return] 
+6
source

I can also use Cr. He shows me all the entries in the minibuffer, and I can choose from this. I have a Cr related to Mx nothing-minibuffer-history. After replacing the Mx request, press Ch b and find the main mode in the help buffer. This will give a complete list of commands. Here are my bindings.

  Cg abort-recursive-edit
 TAB self-insert-command
 Cj exit-minibuffer
 Ret exit minibuffer
 Cr anything-minibuffer-history
 ESC Prefix Command
 C-tab file-cache-minibuffer-complete
 down next-history-element
 next next-history-element
 prior previous-history-element
 up previous-history-element
 Mn next-history-element
 Mp previous-history-element
 Mr previous-matching-history-element
 Ms next-matching-history-element
+1
source

All Articles