简体   繁体   English

编辑emacs query-replace中的上一个搜索字符串?

[英]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. 在emacs中使用query-replace(有或没有regexp)时,会记住先前的查询替换对,并在下次调用query-replace时将其建议为默认值。 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 命令M-%本身给出

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? 是否有一些魔术键组合可以将最终的“B”更改为“C”而无需重新输入?

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

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

I can also use Cr. 我也可以用Cr。 It shows me all the entries in minibuffer and I can select from that. 它显示了迷你缓冲区中的所有条目,我可以从中进行选择。 I have Cr binded to Mx anything-minibuffer-history. 我有Cr绑定到Mx任何 - 迷你缓冲区历史。 After Mx query-replace, hit Ch b and search for major-mode in the Help buffer. 在Mx查询替换之后,按Ch b并在帮助缓冲区中搜索主模式。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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