简体   繁体   中英

Edit the previous search string in emacs query-replace?

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?

是的,试试Mp ,就像这个序列

M-% M-p [return] M-p [DEL] C [return]

I can also use Cr. It shows me all the entries in minibuffer and I can select from that. I have Cr binded to Mx anything-minibuffer-history. After Mx query-replace, hit Ch b and search for major-mode in the Help buffer. That will give full list of command. Here is my bindings.

C-g     abort-recursive-edit
TAB     self-insert-command
C-j     exit-minibuffer
RET     exit-minibuffer
C-r     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
M-n     next-history-element
M-p     previous-history-element
M-r     previous-matching-history-element
M-s     next-matching-history-element

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM