I do a lot of my writing on my couch with my MacBook on my lap. That provides a less than optimal typing environment so I frequently mistype a command and end up magically transported to another place and time. Sometimes it’s just to another place in my current file but often it’s to another file altogether.
Apparently, I not the only one who suffers from this. Chris Maiorana, who writes for a living and uses Emacs to do so, has the same problem. He asks, wouldn’t be nice to be able to have a “back key” that would take you back to where you were before you fat fingered some command and were transported into the nether regions.
Maiorana notes that Emacs pretty much has this out of this box with push-mark that stores your location before many location moving commands. It stores your current location in the “mark ring” from which you can pop the location to return to the place where the mark was pushed.
But, asks Maiorana, what if you want to go forward too? It’s not to hard to imagine situations where you want to go back and forward between locations during your editing. It turns out that you can do that too with the help of the backard-forward package. Maiorana has a few more details in his post so take a look if you’re interested.
If you don’t want to add another package, you can simply use Ctrl+u Ctrl+Space to pop the last saved location and go to it.
I use Ctrl+u Ctrl+Space all the time but do forget to use it when I inadvertently find myself in an unexpected place. Whether you choose to install the backward-forward package or simply rely of popping the mark, it’s good to be aware of how simple it is to recover.