22

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 **.

6 Answers 6

35

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)

2
  • Thanks for help! It looks more likely without external plugin, emacs is not very handy to do that like vim.
    – Orup
    Dec 3, 2010 at 13:18
  • Is it work under windows environment? I got this error message: k:/DataHubs/Dropbox/Dropbox/development/: find . "(" -iname ".ds" ")" -exec ls -ld {} ";" आ ऐ ऊअआऐ ॊ ऊऎ: ".ds" find exited abnormally with code 2 at Sun Aug 21 11:51:06
    – ceth
    Aug 21, 2011 at 7:52
5

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")
1
  • 1
    Probably not. But you can use "locate" instead, or any modern replacement.
    – monotux
    Oct 26, 2020 at 8:44
5

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.

2

FindFileInProject may also be worth looking at.

2

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

0

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).

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.