Emacs: Open File Fast

By Xah Lee. Date: . Last updated: .

Here's a command that lets you open file fast by a fuzzy completion on file names in your bookmark.

First, you need to add files you use frequently to emacs bookmark. [see Emacs: Bookmark]

Put the following in your emacs init file.

(defun xah-open-file-fast ()
  "Prompt to open a file from bookmark `bookmark-bmenu-list'.
This command is similar to `bookmark-jump', but use `ido-mode' interface, and ignore cursor position in bookmark.

URL `http://ergoemacs.org/emacs/emacs_hotkey_open_file_fast.html'
Version 2019-02-26"
  (require 'bookmark)
  (let (($this-bookmark
         (ido-completing-read "Open bookmark:" (mapcar (lambda ($x) (car $x)) bookmark-alist))))
    (find-file (bookmark-get-filename $this-bookmark))
    ;; (bookmark-jump $this-bookmark)

Alt+x xah-open-file-fast, then it will prompt with real-time name completion as you type.

Give this command a easy key, such as F8. [see Emacs: How to Define Keys]

For best efficiency, add a unique digit or 2 letter sequence in front of each bookmark file name you use frequently, so that opening a file is just 3 keystrokes, for example, emacs blog can be eb emacs blog, so you can just type F8 e b Enter to open it.

Why ignore bookmarked cursor position?

So, now xah-open-file-fast ignores the position in bookmark.

Note, you should have save-place-mode on. It saves last cursor position.

;; remember cursor position
(if (version< emacs-version "25.0")
      (require 'saveplace)
      (setq-default save-place t))
  (save-place-mode 1))

Put $5 at https://www.patreon.com/xahlee , or goto paypal.com and pay to Xah@XahLee.org . Message me on XahLee discord, say so, ask me questions.
Or Buy Xah Emacs Tutorial

Xah Emacs Commands




edit brackets

copy paste