Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's textmate's 'Go to File' fuzzy search algorithm?

Textmate's 'go to file' fuzzy search is really awesome.

Wincent's Command-T plugin for vim does something similar and it rocks too.

Can someone explain how these work? Is there a general term for the method they use?

Edit: I little more detail about what those tools do

The tools let you narrow a list of options (in this case file paths) as you type.

For example if I had the following files:

/app/models/people.rb
/app/models/address.rb
/app/person.rb
/person.rb

to get to narrow the list to /app/models/people.rb I could type any of the following:

amp
peo
mp
modelsp

it's very flexible and I find my self missing this 'list narrowing' when the app I'm using doesn't have it. I'd like to learn more about it so that I may implement my own plugins if I ever felt the need. Wish I could explain it better, but that's why I'm here :)

To see it in action take a look at wincent's demo of command-t

like image 449
Dane O'Connor Avatar asked Sep 11 '10 05:09

Dane O'Connor


1 Answers

It appears to be doing a wildcard search between every letter.

amp -> *a*m*p*
peo -> *p*e*o*
mp  -> *m*p*
modelsp -> ...

If it matches only one item in the list of options, then it would return that as the intended option.

like image 79
monksy Avatar answered Sep 22 '22 19:09

monksy