Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

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

like image 929
Orup Avatar asked Dec 02 '10 23:12

Orup


People also ask

How do I find files in Emacs?

To find a file in Emacs, you use the C-x C-f ( find-file ) command.

How do I change the default directory in Emacs?

You can type the 'cd' emacs command. ( M-x cd ) to change the default folder as a one off.

What is the command to open a file from within Emacs?

Use Ctrl-x f to open a file from within Emacs. Create a new file in the same way as opening a file by specifying the new filename. The new file will not be saved unless specified. Save a file that is currently open by entering the Ctrl-x Ctrl-s command.


3 Answers

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)

like image 101
barti_ddu Avatar answered Oct 21 '22 01:10

barti_ddu


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")
like image 23
monotux Avatar answered Oct 21 '22 02:10

monotux


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.

like image 44
Joseph Gay Avatar answered Oct 21 '22 00:10

Joseph Gay