简体   繁体   English

emacs,搜索,复制一些文本,然后返回搜索点?

[英]emacs, do a search, copy some text, and then return to the point of search originally?

I am doing a search backwards in the text in emacs, then I move the point around and do a modification or copy, but then can I return to the point of the search before or do I still have to search for text around that spot? 我正在emacs的文本中向后搜索,然后我移动点并进行修改或复制,但是之后我可以返回搜索点还是仍然需要搜索该点周围的文本?

Best, 最好,

Try 尝试

M-x pop-to-mark-command

And you can also get that functionality by Cu SPC or Cu C-@ (ie using a prefix argument with the set-mark-command ). 您还可以通过Cu SPCCu C- @获得该功能(即使用带有set-mark-command前缀参数 )。

For more information on the mark ring, read about the mark ring . 有关标记环的更多信息,请阅读标记环 There is also a global mark ring , which is basically a list of marks across buffers, which you can navigate via Cx C-SPC . 还有一个全局标记环 ,它基本上是缓冲区中的标记列表,您可以通过Cx C-SPC进行导航。

I've tweaked some elisp, point-stack to allow for quick forward/backward through buffers. 我已经调整了一些elisp,点堆栈以允许快速前进/后退缓冲区。 I've written more on my blog , but the basic idea is f5 to push a location, f6 to jump back, f7 for forward. 在我的博客上写了更多 ,但基本的想法是f5推送一个位置, f6跳回来, f7推进。

Here's and animated gif showing it. 这是和动画gif显示它。 替代文字

Ctrl + R foo Enter Notice that “Mark saved where search started” message? Ctrl + R foo 输入 请注意“标记保存在搜索开始的位置”消息?

... edit ... ......编辑......

Ctrl + U Ctrl + Space Go back to the saved mark Ctrl + U Ctrl + Space 返回保存的标记

If you used the mark during the “edit” part, press Ctrl + U Ctrl + Space again that many times. 如果您在“编辑”部分使用了标记,请再次按Ctrl + U Ctrl + Space多次。 The successive marks are stored on a ring (for simple uses, what you see is a mark stack): each time the mark is set, it's pushed onto the stack, and Ctrl + U Ctrl + Space goes to the mark popped from the stack. 连续标记存储在一个环上(为了简单的用途,你看到的是一个标记堆栈):每次设置标记时,它都被推到堆栈上, Ctrl + U Ctrl + Space转到从堆栈弹出的标记。

You can also use Ctrl + U 42 Ctrl + Space or Ctrl + 4 Ctrl + 2 Ctrl + Space to go back to the 42nd previous mark. 您也可以使用Ctrl + U 42 Ctrl + SpaceCtrl + 4 Ctrl + 2 Ctrl + Space返回到第42个上一个标记。

If you put (setq set-mark-command-repeat-pop t) in your .emacs , you can repeat just Ctrl + Space after Ctrl + U Ctrl + Space to go back to successive previous marks. 如果你把(setq set-mark-command-repeat-pop t)在你.emacs ,可以按Ctrl + U Ctrl + 空格 后重复刚才Ctrl + 空格 返回到先前的连续标志。

Before search use Ctrl-space to save your mark. 在搜索之前,使用Ctrl-space保存标记。 Then do a seach and copy some text. 然后进行搜索并复制一些文本。 Then, use Ctrl-u-Ctrl-space to pop back to your saved mark. 然后,使用Ctrl-u-Ctrl-space弹出回保存的标记。

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

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