3
votes

I'm new to Emacs, so recently I faced the problem of "how to quickly find and open a file in emacs?" (something like Go-to in sublime/atom, Cmd-P). As a solution I'm using projectile package, but its behaviour is slightly different in the following scenario. If I want to narrow down my search providing only parts of the path, it wont be able to find the file I'm looking for. Eg.

Given the following file on my project:

my-project/lib/something/bananas

on emacs, I run M-x projectile-find-file or C-c p f, how could I find the above file providing only lib and bananas?

If i type bananas(only) I can find the file, what I'm looking for is a way of narrow the search as I might have multiple files named bananas

I tried something like lib/*/bananas but didn't work.

Basically the behaviour that I'm trying to achieve is equivalent to this:

atom example (link to example as unfortunately I don't have reputation(points) enough to upload a photo here)

3
What you are describing is generally called "fuzzy finding" or "flex matching". There are plenty of packages out there that provide this feature, but emacs won't do this out of the box.Randy Morris

3 Answers

4
votes

For me it works with

M-x projectile-find-file or C-c p f

Just separate search tags with space, in your example:

lib bananas
0
votes

One of the packages that you can use for this is helm-projectile.

0
votes

I use ido-ubiquitious for this (along with (setq ido-enable-flex-matching t)). It makes pretty much any completion use ido, and thus gives you fuzzy matching. You can use M-SPC to incrementally narrow your search, e.g. C-c p f l i b M-SPC b a n a n a s M-SPC. The matching is still fuzzy, so it doesn't matter if you narrow by "bananas" or "lib" first.