Emacs: Bookmark

By Xah Lee. Date: . Last updated: .

Emacs's Bookmarks is similar to browser's bookmark. It lets you easily open frequently needed files.

emacs bookmark 2021-07-19
Emacs Bookmark.

Add a Item to Bookmark

bookmark-setCtrl+x r m
Add current buffer to bookmark. It will prompt you for a name. Bookmark can be a file or a directory.

List Bookmark Items

list-bookmarksCtrl+x r l
Open the bookmark list.

Open a Item in Bookmark

bookmark-jumpCtrl+x r b
Open a file in bookmark. Emacs will prompt for a name. You can type a asterisk * for wildcard. For example, “*today” will match “todo today”.

Remove/Rename a Bookmark Item

When in the bookmark file:

Save Bookmark File

Alt+x bookmark-save to save the bookmark file. (Press s while in bookmark file)

Bookmarks are automatically saved when emacs quit. (Emacs 24.4 (released 2014-10))

You can control bookmark auto save behavior by bookmark-save-flag.

;; everytime bookmark is changed, automatically save it
(setq bookmark-save-flag 1)

Set Emacs to Open Bookmark File on Start

To have emacs open bookmark file on startup, add this to the end of your elisp init file:

(setq inhibit-splash-screen t)
(require 'bookmark)
(list-bookmarks)
(switch-to-buffer "*Bookmark List*")

Bookmark File Location

In emacs 24.x, bookmark file is at ~/.emacs.d/bookmarks.

In emacs 23.x, bookmark file is at ~/.emacs.bmk.

The default bookmark file path is stored in the variable bookmark-default-file. Alt+x describe-variable to see its value.

Spent a few hours here?

Emacs Tutorial

Emacs Init

Emacs Keys

Elisp Basics

Elisp Examples

Elisp Advanced

Elisp Write Major Mode


Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc