A couple of days ago I wrote a note to myself post to help me remember the
align-regexp functionality. Today’s post is another note to myself. A recent post by Xah Lee reminded me of some Emacs functionality that I am always forgetting. Every time I see the
set-mark-command function described I think, “Boy, that’s really useful, I need to remember it.” Then I promptly forget about it again.
set-mark-command (bound to 【Ctrl+Space】) sets the mark at the point’s position. The normal way of invoking it to remember locations is to type 【Ctrl+Space Ctrl+Space】. The first 【Ctrl+Space】 sets the mark and the second deactivates it so that no region is highlighted. Emacs also pushes the mark onto the buffer’s mark ring and onto the global mark ring.
This is useful because we can use the marks recorded on the mark rings to return to a remembered location. If we want to return to a previous mark in the same buffer, we type 【Ctrl+u Ctrl+Space】 We can move back several locations by repeating the 【Ctrl+u Ctrl+Space】.
If we want to return to a mark which may be in another buffer we can type 【Ctrl+x Ctrl+Space】. This can also be repeated to move back several marks.
This may seem confusing but it boils down to just three key sequences
- 【Ctrl+Space Ctrl+Space】 to push the current position onto the mark rings.
- 【Ctrl+u Ctrl+Space】 to return to a previous position in the same buffer.
- 【Ctrl+x Ctrl+Space】 to return to the previous position, which may or may not be in the same buffer.