Emacs: Using Bookmark Feature
This page is a tutorial on emacs's bookmark feature. Emacs's Bookmarks is similar to browser's bookmark. It lets you easily open frequently needed files.
Add a File to Bookmark
Open the file you want to add. Then, call
bookmark-set 【Ctrl+x r m】 . It will prompt you for a name.
Opening Bookmark File
To open bookmark, call
bookmark-bmenu-list 【Ctrl+x r l】. This displays your bookmarks.
bookmark-jump: Opening a Bookmarked Item
To open a bookmarked item, call
bookmark-jump 【Ctrl+x r b】, then type a name.
You can use
* for wildcard. ➢ for example:
*today will match
Saving Your Bookmark
bookmark-save to save it. (Press 【s】 while in bookmark)
Sometimes in or before 〔➤see Emacs 24.4 New Features (released 2014-10) (2014-10)〕, by default, bookmarks are automatically saved when emacs quit. Before, if you don't save it, newly added bookmarks will be for the current session only, and won't show up when you restart emacs.
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.
Removing Or Renaming Bookmark Item
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.
How to Remember Bookmark Commands or Shortcuts?
Bookmark commands are right under the menu 〖Edit ▸ Bookmarks〗. If you forgot the commands or shortcuts, look at the menu. The menu is a great way to remember many emacs's commands.
Also, the bookmark commands all start with “bookmark-”. The only one you really need to remember is
bookmark-bmenu-list. Once you have the bookmark open, call
describe-mode 【Ctrl+h m】 to see its commands and shortcuts.
Starting Emacs with Bookmark
To have emacs open bookmarks 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 Raw File Location
In emacs 24.x, bookmark file is at
In emacs 23.x, it's at
The default location is controlled by the variable bookmark-default-file. Call
describe-variable 【Ctrl+h v】 to see its value.
You can set default bookmark location like this:
(setq bookmark-default-file (concat user-emacs-directory "bookmarks"))
The syntax to load a bookmark file is this:
(bookmark-load bookmark-default-file t)
Other Ways to Open File Fast
or, buy something from my keyboard store.