DEV Community

Kay Gosho
Kay Gosho

Posted on

2 1

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay