Emacs: Playing Hansel and Gretel with Marks, Registers and Bookmarks

Arialdo Martini — 20/03/2024 — emacs lisp

A cool trick not everybody knows with Visual Studio and JetBrains’ IDEs is that it is possible to navigate back to previous positions with Ctrl -.

A similar trick also works with Bash:

cd -

and with Git:

git checkout -

Neat, right?
Of course, there are way more powerful tools built around this idea (such as z, autojump and zoxide). And — did you doubt? — similar powerful features in Emacs too. Let’s explore them.

Leaving a trail of breadcrumbs

So you want to leave a track while you move around buffers and you want to retrace your steps, right?
As far as I know, Emacs offers 3 tools:

Tool Main characteristics When it is the best fit
mark ring - buffer local and global
- unnamed
- both manual and automated
- volatile
- It’s related to the region
- Quick, impromptu navigation
registers - global
- short-named
- manual
- not persistent by default
- Within a working session
- Can store more than positions
bookmarks - named
- manual
- persisted
- The longterm cornerstones for organizing your work environment
- Can store more than positions

In this series, we will explorer them all!

Table of Contents

References