The Essentials of Emacs Bookmarks

What they are

Bookmarks are like registers in that they record positions you can jump to. Unlike registers, they have long names, and persist from one Emacs session to the next.

Their primary use is twofold

  • Allow you to keep a list of commonly used files
  • Allows you to record the exact place you want to "remember" in that file.
  • You can bookmark almost anything, including PDFs, Folders, places in the Emacs manual and even remote locations using TRAMP.

So, the bookmark feature allows you to bookmark a file and its place in the document.

Keys

The prefix key is usually C-x r the same prefix key for registers.

C-x r m - Create a bookmark
C-x r l - Go to my bookmark list
C-x r b - Jump to any bookmark

This is cumbersome. I have adopted the shortcuts of the bookmark+ package.

  ;; Create a bookmark
    (global-set-key (kbd "C-x x m") 'bookmark-set)
  ;; Go to my bookmark list
    (global-set-key (kbd "C-x x e") 'bookmark-bmenu-list)
  ;; Jump to any bookmark (used rarely)
    (global-set-key (kbd "C-x x j") 'bookmark-jump)

Rename - r
Delete - dx

Special customization

Sort by last created bookmark top of list

  (setq bookmark-sort-flag nil)   ; sort by last created
  (setq bookmark-save-flag 1)   ; save bookmarks automatically

Return to Home