Emacs: Ido Mode

By Xah Lee. Date: . Last updated: .

ido-mode enhanced emacs switch buffer command and opening file command.

It AUTOMATICALLY show list of choices as you type (no need to press Tab first).

Alt+x ido-mode to toggle it on/off.

Alt+x ido-switch-bufferCtrl+x b】 to switch buffer.

Alt+x ido-find-fileCtrl+x Ctrl+f】 to open file.

emacs ido-mode show vertical 2016-06-27 52017
Emacs ido-switch-buffer in action.

Ido Keys

When ido-switch-buffer is called, it will prompt for a choice of buffer name.

Here's the most useful ido keys when in the prompt:

  1. 】 → Select the next choice.
  2. 】 → Select the previous choice.
  3. 】 → Go to the buffer you switched to last time. 【】 for next.
  4. Enter】 → Use the first choice.
  5. Ctrl+f】 → stop suggestion. useful for creating new file. 【Ctrl+b】 to go back to buffer selection mode.
  6. Ctrl+d】 → switch to open directory mode.
  7. Ctrl+g】 → cancel.

How to create a new file with ido-mode?

Alt+x ido-switch-buffer, then press 【Ctrl+f】 to stop suggestion. This is useful when creating new file.

When you want to open a directory, press 【Ctrl+d】.

Ido Mode Setup

You can setup ido mode to display choices vertically, and turn on flex match.

Put this in your emacs init file:

  ;; make buffer switch command do suggestions, also for find-file command
  (require 'ido)
  (ido-mode 1)

  ;; show choices vertically
  (if (version< emacs-version "25")
        (make-local-variable 'ido-separator)
        (setq ido-separator "\n"))
      (make-local-variable 'ido-decorations)
      (setf (nth 2 ido-decorations) "\n")))

  ;; show any name that has the chars you typed
  (setq ido-enable-flex-matching t)
  ;; use current pane for newly opened file
  (setq ido-default-file-method 'selected-window)
  ;; use current pane for newly switched buffer
  (setq ido-default-buffer-method 'selected-window)
  ;; stop ido from suggesting when naming new file
  (define-key (cdr ido-minor-mode-map-entry) [remap write-file] nil))
;; big minibuffer height, for ido to show choices vertically
(setq max-mini-window-height 0.5)

Stop ido Suggestion When Writing File

When you call write-fileCtrl+x Ctrl+w】 (aka “save as”), when ido is on, it'll make suggestions. This is annoying because usually you don't want the name to be a existing file.

Here's how to stop ido suggestion when Alt+x write-file, put this in emacs init:

(require 'ido)
;; stop ido suggestion when doing a save-as
(define-key (cdr ido-minor-mode-map-entry) [remap write-file] nil)

See also: Emacs: icomplete vs ido mode

History of Ido Mode

ido is written by Kim F Storm. Ido started in 1996. Kim is also author of cua-mode. (cua started in 1997) Kim's home page is http://www.cua.dk/index.html

Ido became part of emacs 22 (released in 2007).

ido is based on iswitchb-mode by Stephen Eglen. iswitchb started in 1996. Stephen's home page is http://sje30.github.io/ . Stephen's emacs page http://www.damtp.cam.ac.uk/user/sje30/emacs/

Open File topics

  1. Emacs: File Manager, dired
  2. Emacs: Bookmark Tutorial
  3. Emacs: Open Recently Opened File
  4. Emacs: Open File Fast
  5. Emacs: Open Last Closed File
  6. Emacs: Open File Path Under Cursor

Buffer topics

  1. Emacs: List Buffers
  2. Emacs: Switch Buffer
  3. Emacs: New Empty Buffer
  4. Emacs: Next/Previous User Buffer
Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

Patreon me $5. Ask me question on patreon