Orup
Orup

Reputation: 579

How to find a file in Emacs without known exact directory?

In vim it's very easy to find a file without knowing which directory the file is in. Doing this ":args **/file.hpp" if the file exists, it will get it open.

Is there any substitution in Emacs to do so? The find-file seems work for wildcards, but it doesn't do the tricky like vim does with **.

Upvotes: 22

Views: 17813

Answers (6)

Drew
Drew

Reputation: 30699

In Icicles you can find files by matching not just the relative file name but any parts of the path. You can use substring, regexp, and fuzzy matching. You can AND together multiple search patterns (progressive completion). See multi-command icicle-locate-file. And you can even search against file contents, as well as or instead of file name.

http://www.emacswiki.org/emacs/Icicles_-_File-Name_Input

Upvotes: 2

Joseph Gay
Joseph Gay

Reputation: 800

A good tip if you use ido-find-file:
From a known root directory, you can use ido-wide-find-file-or-pop-dir, which by default is bound to M-f.

Upvotes: 5

monotux
monotux

Reputation: 3716

A more blunt but still handy tool: M-x locate

Using OS X? This makes emacs use spotlight instead of the standard locate:

(setq locate-command "mdfind")

Upvotes: 5

phils
phils

Reputation: 73274

FindFileInProject may also be worth looking at.

Upvotes: 2

Trey Jackson
Trey Jackson

Reputation: 74440

I like

M-x ifind /some/path/to/start/file.hpp

or just

M-x ifind file.hpp

using the ifind package found here. Note: it does open up a *ifind* buffer which displays the results, which you can either select with the mouse, or navigate using C-x ` (aka M-x next-error).

Upvotes: 0

barti_ddu
barti_ddu

Reputation: 10299

M-x find-name-dired looks like what You want (You will be prompted for root directory to start search with and a file mask)

Upvotes: 35

Related Questions