Emacs's Bookmarks is similar to browser's bookmark. It lets you easily open frequently needed files.
Add a Bookmark
Open a file you want to bookmark. Then, Alt+x
bookmark-set 【Ctrl+x r m】. It'll add current file to bookmark file. It will prompt you for a name.
Bookmark can be a file or a directory.
list-bookmark 【Ctrl+x r l】 → Open bookmark file.
When in bookmark file, press Enter ↵ to open the item under cursor.
Open a Bookmark
To open a bookmarked item, Alt+x
bookmark-jump 【Ctrl+x r b】, then type a name.
You can type a asterisk
* for wildcard. For example, “*today” will match “todo today”.
Remove / Rename Bookmark
When in the bookmark file:
- Type d to mark the current item for remove.
- Type x to remove all D marked ones.
- Type r to rename current item's title.
- Type s to save the change.
Save Bookmark File
bookmark-save to save the bookmark file. (Press 【s】 while in bookmark file)
Bookmarks are automatically saved when emacs quit. (since ~2014) 〔►see Emacs 24.4 New Features (released 2014-10) (2014-10)〕
You can control bookmark auto save behavior by bookmark-save-flag.
(setq bookmark-save-flag 1) ; everytime bookmark is changed, automatically save it (setq bookmark-save-flag t) ; save bookmark when emacs quits (setq bookmark-save-flag nil) ; never auto save.
How to Remember Bookmark Commands or Shortcuts?
Bookmark commands are under the menu 〖Edit ▸ Bookmarks〗.
When you are in bookmark file, Alt+x
describe-mode 【Ctrl+h m】 to see its commands and shortcuts.
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) (bookmark-bmenu-list) (switch-to-buffer "*Bookmark List*")
Bookmark File Location
In emacs 24.x, bookmark file is at
In emacs 23.x, bookmark file is at
The default bookmark file path is stored in the variable bookmark-default-file. Alt+x
describe-variable 【Ctrl+h v】 to see its value.
Open File topics
- Emacs: File Manager, dired
- Emacs: Bookmark Tutorial
- Emacs: Open Recently Opened File
- Emacs: Open File Fast
- Emacs: Open Last Closed File
- Emacs: Open File Path Under Cursor