DEV Community

Kay Gosho
Kay Gosho

Posted on

Trace marks in Emacs like Vim's Ctrl-o

In Vim, we can trace marks by hitting C-o repeatedly, which is edit history of current Vim session. In Emacs, we can go back to the latest mark by hitting C-x C-x, but I wanted to go back further marks.

I carefully read Emacs manual and found the solution.

https://www.gnu.org/software/emacs/manual/html_node/emacs/Mark-Ring.html

We can trace marks by hitting C-u C-SPC repeatedly in Emacs.

How it works

Emacs has memory for marks called Mark-Ring which store up to sixteen positions of marks. Unlike Vim's C-o, Emacs' C-u C-SPC does not jump to other buffers. This means Emacs do not jump to other files. I prefer this behavior, because when we use Emacs we would open a lot of files in it. Remembering "doing everything with Emacs".

Furthermore

With one line configure of Emacs, we can go back to marks continuously like C-u C-SPC C-SPC C-SPC.

(setq set-mark-command-repeat-pop t)
Enter fullscreen mode Exit fullscreen mode

And if you are using Helm, you would favorite helm-ring.

helm

https://github.com/emacs-helm/helm/blob/master/helm-ring.el

It enables to find marked lines with Helm interface.

Refs

Top comments (0)