Reputation: 28293
What is the easiest way to open a txt file whose path has to be found using the shell find command?
For example, let say I want to open a file that I know is (uniquely) named example.txt and which I know is "somewhere I can find it using the shell find command".
What I do currently is this:
I do C-u (universal-argument) then M-! (shell command)
I then enter the find, for example:
find . -iname "example.txt"
Then the full path (which I didn't know previously) appears in the buffer, I cut it, then I hit C-x C-f, I delete what written by default and then paste what I cut before.
This seems a bit long and requires quite a few keystrokes, cut'n'pasting etc.
Is there an easiest way to do the same (without writing a new custom Emacs command)?
Upvotes: 11
Views: 2864
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
.
http://www.emacswiki.org/emacs/Icicles_-_File-Name_Input
Upvotes: 1
Reputation: 2007
I am surprised that globalff is not mentioned as one of the viable option. Sure it requires locate command but its quite fast and useful when you can't recall the exact name.
Upvotes: 0
Reputation: 800
Also have a look at LocateFilesAnywhere
I happen to use M-x anything-locate
Upvotes: 1
Reputation: 49
M-x locate
is the fastest way to find and open a file, esp. if you know the exact filename, in emacs.
Upvotes: 3
Reputation: 10533
M-x find-dired
RET
then you have a dired buffer showing your files returned by find. You can use classic dired command to open/move/rename... files and directories.
Upvotes: 0
Reputation: 56595
If your folder constitutes a "project" - something under a version control or having a root folder marker such as project.el, .dir-locals.el, etc, you can use the find-file-in-project, which in my opinion is an excellent solution to this problem.
Upvotes: 2
Reputation: 17327
M-x find-name-dired
Enter the dir (defaults to current) and filename (shell globs work too) and you'll get a virtual dired buffer with the results. Go the file you want and hit 'a
'
Upvotes: 10
Reputation: 29772
Using only built-in functionality, I would:
find-file-at-point
command: M-x ffap.I use find-file-at-point
often enough that I have it bound to a dedicated key, s-\ (super-backslash).
Upvotes: 10
Reputation: 74440
Try out ifind.el
M-x ifind /some/starting/point/example.txt
Will search for example.txt
in directories below /some/starting/point
.
Upvotes: 6