简体   繁体   English

Emacs:跳回上一个查询替换位置

[英]Emacs: Jump back to previous query-replace location

I do this a lot: [M-%] to query-replace , then hit [y] a few times, then I'm past the area where I'm changing things so I hit [q] to be done. 我做了很多: [M-%] query-replace ,然后点击[y]几次,然后我已经过了我正在改变事物的区域,所以我点击[q]完成。

Then I'd like to get the cursor back to where I was, so here's where it gets awkward. 然后我想让光标回到原来的位置,所以这就是尴尬的地方。 I [C-_] to undo the last replace, then move the cursor on character, then undo again to redo the last replace. [C-_] undo最后一次替换,然后将光标移动到角色上,然后再次undo以重做最后一次替换。 Now the cursor's up where I've been editing, but there has to be a better way. 现在光标在我编辑的位置,但必须有更好的方法。

(I'm happy to get back to either where I started the replace, or where the last replace happened.) (我很高兴回到我开始更换的地方,或者最后一次更换的地方。)

Cu C-SPC jumps to the mark (which was automatically set as Blrfl pointed out), and then pops the previous mark off the local mark ring (so you can repeat the process to move to previous marks). Cu C-SPC跳转到标记(自动设置为Blrfl指出),然后将当前标记环上的前一个标记弹出(这样您就可以重复该过程以移动到先前的标记)。

I think this is preferable to exchange-point-and-mark , as the latter reactivates the mark, highlighting the region in transient-mark-mode, which you wouldn't want in this case. 我认为这比exchange-point-and-mark更可取,因为后者重新激活标记,突出显示瞬态标记模式中的区域,在这种情况下您不需要。 (Unless you wanted to jump back and forth between the point you started at and the location of the final replacement, in which case exchange-point-and-mark would be exactly what you wanted.) (除非你想跳来回你开始在点和最终更换的位置之间,在这种情况下, exchange-point-and-mark 是你想要什么。)

After you quit, the mark will be where you started and the point will be where you stopped. 退出后,标记将位于您开始的位置,该点将位于您停止的位置。 Cx Cx will swap the two, putting the point where you started. Cx Cx会交换这两个,把你的位置放在开始位置。

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

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