Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set marks in Emacs à la Vim?

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 then 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?

like image 748
MDCore Avatar asked Sep 22 '10 15:09

MDCore


People also ask

How do you set a mark in Emacs?

To set the mark, type C- SPC ( set-mark-command ). This makes the mark active; as you move point, you will see the region highlighting grow and shrink. The mouse commands for specifying the mark also make it active.


1 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.
like image 143
Jérôme Radix Avatar answered Sep 30 '22 08:09

Jérôme Radix