Emacs: icomplete mode, fido mode

By Xah Lee. Date: . Last updated: .

This page is for emacs 28 (year 2022) [see Emacs Version History]

icomplete-mode enhances emacs's name completion when in minibuffer prompts.

icomplete does completion for any command that prompts for a list of choices. Here's some of the commands that icomplete has effect:

icomplete-mode vs fido-mode

icomplete-mode has several variations. They all turn on icomplete-mode, but they differ in how they display choices, and string matching method.

icomplete-mode
The most basic. Press Tab to complete, type some more and press Tab to complete more, untill there's only one choice left, then press Enter to finish and exit. You must type the char that matches the beginning of the command/file name you want. Or, you can type a * to stand for any char.
fido-mode
activates icomplete-mode, but use flex match. That is, you can type any char that are contained in the command/file name you want. No need to press Tab. Press Enter will select the first matched choice and exit.
emacs icomplete mode 2022-04-08
emacs icomplete mode 2022-04-08
emacs fido mode 2022-04-08
emacs fido mode 2022-04-08

icomplete-vertical-mode vs fido-vertical-mode

These simply display choices vertically.

icomplete-vertical-mode
activates icomplete-mode, and changes settings to show result vertically.
fido-vertical-mode
activates fido-mode, and changes settings to show result vertically.
emacs icomplete vertical mode 2022-04-08
emacs icomplete vertical mode 2022-04-08
emacs fido vertical mode 2022-04-08
emacs fido vertical mode 2022-04-08

I recommend just turn on fido-vertical-mode

warning: copy/rename file in dired overwrites

Warning: with fido mode on, when copy or move a file in dired , be sure to press Ctrl+d to select current dir. Otherwise, if you press Enter, it selects current file choice and prompt to override file.

fido vertically keys

Ctrl+d
do not use any suggestion, but use the current typed. This is important, when you want to create a new file, dir, or dired for copy file, rename file. (corresponding command is badly named icomplete-fido-delete-char)
Enter
Select current choice
Alt+j
icomplete-fido-exit “Attempt to exit minibuffer immediately with current input.”
Alt+t
icomplete-force-complete “Complete the icomplete minibuffer.”
Ctrl+j
icomplete-force-complete-and-exit “Complete the minibuffer with the longest possible match and exit. Use the first of the matches if there are any displayed, and use the default otherwise.”
next choice
Prev choice
next choice
Prev choice
Ctrl+s
next choice
Ctrl+r
Prev choice
Ctrl+.
next choice
Ctrl+,
Prev choice
Ctrl+n
next choice
Ctrl+p
Prev choice
Alt+<
icomplete-vertical-goto-first
Alt+>
icomplete-vertical-goto-last

Icomplete Mode Setup

Put this in your Emacs Init File:

(if (version< emacs-version "28.1")
    (progn
      (progn
        ;; make buffer switch command do suggestions, also for find-file command
        (require 'ido)
        (ido-mode 1)
        ;; show choices vertically
        (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)
        )
      (progn
        ;; minibuffer enhanced completion icomplete
        (require 'icomplete)
        (icomplete-mode 1)
        ;; show choices vertically
        (setq icomplete-separator "\n")
        (setq icomplete-hide-common-prefix nil)
        (setq icomplete-in-buffer t)
        (define-key icomplete-minibuffer-map (kbd "<right>") 'icomplete-forward-completions)
        (define-key icomplete-minibuffer-map (kbd "<left>") 'icomplete-backward-completions)))
  (fido-vertical-mode 1))

history of icomplete mode

icomplete is originally written by Ken Manheimer, first released in 1993. (Ken Manheimer's home page: http://myriadicity.net/ • [2014-06-11 https://twitter.com/myriadicity ] )

Emacs Completion


Emacs Init

Init Basics

Keys

Font

Text Editing

Completion

File

Restore Things

Backup/AutoSave

Line

Appearance

Misc

Advanced Init Tips

packages