When using C-x C-f (ido-find-file) to open files use I can use M-s to enable fuzzy matching.

If I type C-x C-f then M-s and then enter the the fuzzy search string, things work as they should.

However if I type C-x C-f then enter the fuzzy string and then type M-s I get something like this in the minibuffer:

my-fuzzy-search[correct-completion]{some-totally-unrelated-file | correct-completion | ... }

Some unrelated file is always first in the list of results, and if I press enter here ido will open it. Is there a way to configure ido so that the correct match will be first in the list in this case?

  • FWIW, Ido does not really use what is usually called fuzzy matching. It uses what it calls flex matching (which is what Icicles calls scatter matching), which is kind of a poor man's fuzzy matching. (Nothing wrong with it - just saying...)
    – Drew
    Oct 30, 2014 at 1:06

1 Answer 1


Ido doesn't have very smart fuzzy matching by default. Essentially, if you put in


Ido will try to match


against its candidates. This isn't really how we think about matching, since we would expect a file literally called horse-feathers.txt to score higher than hogs-raging-senial.png.

Check out the flx-ido package. From the readme:

The sorting algorithm is a balance between word beginnings (abbreviation) and contiguous matches (substring).

The longer the substring match, the higher it scores. This maps well to how we think about matching.

In general, it's better form queries with only lowercase characters so the sorting algorithm can do something smart.

For example, if you have these files:


If the search term was pre-mode, you might expect "prelude-mode.el" to rank higher. However because the substring match "re-mode" is so long, "clojure-mode.el" actually scores higher.

Here, using premode would give the expected order. Notice that the "-" actually prevents the algorithm from helping you.

uppercase letters

Flx always folds lowercase letters to match uppercase. However, you can use uppercase letters for force flx to only match uppercase.

This is similar to Emacs' case-folding. The difference is mixing in uppercase letters does not disable folding.

completing file names

Matches within the basepath score higher.

  • This works better, but I can still get situations where the completion I want is in [] brackets in the beginning, but further down in the {} list. If I write the beginning of a filename with wrong case, this file will end up further down the list, compared to a file with the same letters further apart but with the right case. However the first file will be shown within the square brackets.
    – snowape
    Oct 30, 2014 at 5:22
  • Again, In general, it's better form queries with only lowercase characters so the sorting algorithm can do something smart. Why use Shift when you don't have to? Oct 30, 2014 at 17:01
  • When I write with all lowercase, and the match I want has some uppercase characters, then the situation in my first comment happens.
    – snowape
    Oct 30, 2014 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.