Skip to content

Introduction to Ido Mode

by mickey on October 10th, 2010

There are many ways of improving your productivity when you use Emacs, and Ido (or “Interactively DO things”) is one of those packages that you enable and then never, ever turn off again. It’s simply that useful. By super-charging Emacs’s completion engine and improving the speed at which you open files and buffers, you will significantly cut down on the time spent doing these menial tasks. Think about how often you switch buffers, open files or navigate directories in Emacs.


When Ido is enabled it replaces the existing key-, and command bindings with its own, “Ido-powered”, versions. Most ido commands are named “ido-xxxxx”; so find-file becomes ido-find-file, and so on.

The “Ido-powered” completion engine matches anywhere in a name, instead of just the beginning. That means if you were to search for the buffer “*Customize Group: Foobar*” without Ido you’d have to contort your fingers and type the *, then TAB (and hope it completes) and if not, type in some more; then rinse and repeat.

With Ido you’d type a few characters until you find the match, or until you narrow down your list of matches to a manageable subset, and then press RET. Even better, with fuzzy matching you can find things even more efficiently. So the above buffer name could be found by typing “cgf” — c for Customize, g for Group and f for Foobar. Magic.

There are some who refuse to use Ido because it “gets in the way”; I think a lot of those worries stem from not knowing that it is possible to disable Ido’s completion mode when it makes sense to do so.

Enable Ido Everywhere

Add this to your .emacs file:

That’ll enable basic Ido support for files and buffers and the very useful “flex matching” as well.

My Customizations

There’s more to Ido than just enabling it. I’ve compiled a list of interesting settings you can change and I have thrown in some of my preferences for good measure.

Find File At Point

Find File At Point, also known generally as “ffap”, is an intelligent (well, when I say that, I mean it uses simple heuristics to infer the context at point) system for opening files, and URLs.

Some people hate it, and personally I tolerate it. It gets in the way sometimes and when it does it’s really annoying, but mostly it helps me so it gets to stay. It works in surprisingly many contexts like inferring the filepath of a library in an elisp (require 'foobar) form.

This will make Ido guess the context, which is what I use.

You can disable URL ffap support by toggling ido-use-url-at-point.

Eliminating Obstacles

If you create a ton of throw-away buffers like I do, this setting will force Ido to always create a new buffer (in C-x b) if the name does not exist. I create throw-away buffers all the time and the last thing I need is Ido asking my permission to create one. Other choices are prompt and never.

You can customize the order in which files are sorted when Ido displays them in the minibuffer. There are certain file extensions I use more than others, so I tell Ido to emphasize those.

Ignorance is Bliss

Ido is capable of ignoring (that is, by omission) buffers, directories, files and extensions using regexp.

Variable Name Description
ido-ignore-buffers Takes a list of buffers to ignore in C-x b
ido-ignore-directories Takes a list of directories to ignore in C-x d and C-x C-f
ido-ignore-files Takes a list of files to ignore in C-x C-f

I would recommend using M-x customize-variable RET variable-name-here to customize them unless you are comfortabe editing Emacs lisp directly. I don’t ignore anything in Ido beyond the defaults, as I prefer to use the more general completion-ignored-extensions as it works with and without Ido.

To make Ido use completion-ignored-extensions you need to enable it:

Now you can customize that variable as well: M-x customize-variable RET completion-ignored-extensions. Go ahead and add all the useless object files, backup, autosave and other computing flotsam you don’t want Ido to show.

NOTE:Ido will still complete the ignored elements if Ido would otherwise not show any other matches. So if you type out the name of an ignored file Ido will still let you open it just fine.

Ido Cheatsheet

Here’s a quick cheatsheet of all the interesting Ido commands.

The “Available In” column indicates where the keybinding is available. “All” means that is is a feature inherent to ido-completing-read and as such is available in all the completion engines. “Files”, “Dirs” and “Buffers” means it is only available in one of those.

General-purpose Commands

Keybinding Description Available In
C-b Reverts to the old switch-buffer completion engine Buffers
C-f Reverts to the old find-file completion engine Files
C-d Opens a dired buffer in the current directory Dirs / Files
C-a Toggles showing ignored files (see ido-ignore-files) Files / Buffers
C-c Toggles if searching of buffer and file names should ignore case. (see ido-case-fold) Dirs / Files / Buffers
TAB Attempt to complete the input like the normal completing read functionality Dirs / Files / Buffers
C-p Toggles prefix matching; when it’s on the input will only match the beginning of a filename instead of any part of it. Files
C-s / C-r Moves to the next and previous match, respectively All
C-t Toggles matching by Emacs regular expression. All
Backspace Deletes characters as usual or goes up one directory if it makes sense to do so. All (but functionality varies)
C-SPC / C-@ Restricts the completion list to anything that matches your current input. (Thanks to Joakim Hårsman for pointing it out) All
// Like most *nix shells two forward slashes in a path means “ignore the preceding path, and go back to the top-most directory”. Works the same in Ido but it’s more interactive: it will go to the root / (or the root of the current drive in Windows) Files
~/ Jumps to the home directory. On Windows this would be typically be %USERPROFILE% or %HOME%, if it is defined.

Files / Dirs
M-d Searches for the input in all sub-directories to the directory you’re in. Files
C-k Kills the currently focused buffer or deletes the file depending on the mode. Files / Buffers
M-m Creates a new sub-directory to the directory you’re in Files

OK, so you probably won’t get in the habit of using all the commands; that’s fine, but some are more important to remember than others, like: Backspace; C-s and C-r; // and ~/; and C-d.

If Ido is getting in your way, remember the fallback commands: C-f for files; C-b for buffers.

Work Directory Commands

Work directories are recently used directories that Ido caches so the files and directories in them can be quickly recalled. Work directory commands only function in find-file routines, but that goes without saying.

You change the cached directory list by manipulating the variable ido-work-directory-list. If you’re tired of Ido caching slow, transient or generally unwanted directories you can add regular expressions to the list in ido-work-directory-list-ignore-regexps to keep Ido from caching them.

Similarly, when you go to the next or previous work directory you can force Ido to disregard directories that do not match your current input. To change this behavior, set ido-work-directory-match-only.

Keybinding Description
M-n / M-p Cycles through the next or previous work directories
M-k Kills (removes) the active work directory from the list.
M-s M-s forces ido to search the list of work directories for the current input.

Using M-s is an excellent way to quickly scan recently used directories for files. You do not have to explicitly type M-s as Ido will automagically start searching after a few seconds of idle time.

You can change the work directory merge delay by modifying the ido-auto-merge-delay-time variable.

12 Comments
  1. Joakim Hårsman permalink

    Another useful command in ido-mode is C-SPC which restricts the list of options to the current set.

    I use this if I’m looking for an org-mode file but I can’t remember the exact name:

    C-x C-f .org C-SPC

  2. mickey permalink

    Joakim,

    That’s very nifty. I didn’t know you could do that! I’ve updated the article to reflect this.

    -Mickey.

  3. Ryan Fox permalink

    imenu gives a list of all functions in a file, and lets you jump to them.

    idomenu (http://emacswiki.org/emacs/idomenu.el) gives you ido functionality for imenu. This is incredibly useful!

  4. (setq ido-everywhere t)
    could you tell me how this option change ido behavior ?
    i couldn’t find any clues so far.

  5. I didn’t know about “ido-file-extensions-order”. Thanks – great post.

  6. Hi,

    I am actually looking for a manual for IDO Mode, if one exists at all. I searched the info directory but could not find any mention of the IDO mode. Also a quick search on the web doesn’t show any sign of the presence of a manual . Any pointers to where I could look for a complete description of IDO?

    Thank you,
    Varun Vats

  7. elwoode permalink

    I found “Anything” newer version called “Helm” easier to use and it does a lot of the same.

  8. Jarvis permalink

    In my version of ido bundled with emacs 24.3.1 pressing “M-d” after running “ffap” prompts for “Wide find directory:”. You choose a parent directory, and some part of a string, then press RET and ido completes on the names of the parent’s subdirectories themselves.

    Pressing “M-f” instead prompts for “Wide find file:”. This functions the same way except matches on files within the subdirectories.

  9. In addition to ‘//’ jumping to the root of your drive, on windows, you can switch the current drive by typing ‘:/’

  10. Ooops, my post got mangled.

    In addition to ‘//’ jumping to the root of your drive, on windows, you can switch the current drive by typing ‘[drive-letter]:/’

Trackbacks & Pingbacks

  1. Disabling Prompts in Emacs | Mastering Emacs
  2. Assorted Emacs links from the archives « Notes from the Library

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS