I'd like to be able to set multiple marks in Emacs like Vim does. In Vim you might press m b and that would set a mark at that line in the file. Later pressing ' b will move your cursor back to that line. You can make multiple marks with m{a-zA-Z}. Is there a way to have multiple marks like this in Emacs?
5 Answers
From Emacs documentation :
C-x r SPC r
- Record the position of point and the current buffer in register r (point-to-register).
C-x r j r
- Jump to the position and buffer saved in register r (jump-to-register).
But if you want your positions to persist automatically from one Emacs session to the next, you should use Bookmarks :
C-x r m RET
- Set the bookmark for the visited file, at point.
C-x r m bookmark RET
- Set the bookmark named bookmark at point (bookmark-set).
C-x r b bookmark RET
- Jump to the bookmark named bookmark (bookmark-jump).
C-x r l
- List all bookmarks (list-bookmarks).
M-x bookmark-save
- Save all the current bookmark values in the default bookmark file.

- 10,285
- 4
- 34
- 40
You can use what Emacs calls registers
. The documentation explains them better than I can.

- 77,191
- 7
- 105
- 161
-
Thanks. For a bonus multiplier, do you know of any way/plugin to highlight marked lines? – MDCore Sep 22 '10 at 15:30
-
No, no way that I know of. There are commands, such as `highlight-phrase` and `highlight-regexp`, which may be useful, but nothing like `highlight-register` in the standard build. – High Performance Mark Sep 22 '10 at 15:37
-
@MDCore: I've been using Emacs for donkeys years, but still learn something new every time I check this tag on SO. Thanks. – High Performance Mark Sep 22 '10 at 16:20
Try the mark ring for quick marks:
I used Vim for a decade before switching to Emacs a few years ago, and while the registers and bookmarks looked good at first, the mark ring is what I actually end up using 90% of the time. Usually I just use the C-space, C-x C-x, but cycling works, too.
Btw, realize that doing large non-arrow key movements like M-v will often add a mark to the mark ring. Just practice these key combos and you'll likely find them sufficient for most tasks.
Radix already did a good job explaining the registers and bookmarks, and those are useful for locations in files that will be referred to often or need annotation.

- 13,397
- 7
- 35
- 44
-
1To avoid transient mark being activated when jumping (C-x C-x), use prefix argument (C-u C-x C-x). – arvidj Oct 28 '15 at 13:05
Vanilla Emacs makes you specify a name for each bookmark. What you want, it sounds like, is a quick way to create bookmarks without naming them -- just hit a key. You want autonamed bookmarks, available with Bookmark+. You can even have them be automatically highlighted, if you like (the fringe or the line).

- 29,895
- 7
- 74
- 104
Have a look at this: http://www.cs.utah.edu/dept/old/texinfo/emacs18/emacs_13.html
-
Yeah I'm looking for random access to my marks. That mark ring is a stack. – MDCore Sep 22 '10 at 15:27