开发者

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

开发者 https://www.devze.com 2023-01-28 11:23 出处:网络
In vim it\'s very easy to find a file without knowing which directory the file is in. Doing this \":args **/file.hpp\" i开发者_C百科f the file exists, it will get it open.

In vim it's very easy to find a file without knowing which directory the file is in. Doing this ":args **/file.hpp" i开发者_C百科f 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 **.


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)


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


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.


FindFileInProject may also be worth looking at.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号