1

I've recently switched from using Eclipse to emacs. I'm trying to find a way to emulate eclipse's Ctrl-Shft-r functionality which lets you type in a file name and it begins showing all files in the current workspace that begin with the string you are typing.

C-x C-f seems to handle just tab-completion in the current directory, whereas Eclipse's functionality looked through all sub-directories to find matching files.

I'm looking for something (maybe there's a plugin that does this) that allows you to type the name of folder to look in, and then a partial file and returns back the results in a buffer. Possibly that uses auto-complete to list off matching files with their full paths.

Sleaker
  • 53
  • 8

2 Answers2

3

First of all, steer clear of vanilla find-file function (that's the interactive function that is run when you hit C-x C-f). It is very limited, it forces you to hit TAB all the time, and the first thing most people do when switching to emacs is replace find-file with something more powefull.

There're a number of alternatives. ido-mode is one, helm is another. The former is light-weight, fast and comes built-in with emacs. The latter is immensely powerful and strives to be fast, too.

Second of all, there're two ways a recursive file search can usually be done:

  1. directory search - that's when you just search a directory, no surprises here;
  2. project search - that's when you setup a project your're working on, thus making emacs aware of which files are of interest to you right now.

For directory search, ido-find-file and helm-find-file are both viable options. Ido does its search automatically when you pause typing; helm uses (C-u) M-g s to activate grep. See this SO question for more info.

For project search, you need a library to manage your projects. Projectile is great for that. Set it up and use C-c p f or C-c p F to list files in current or all of your projects, respectively. Oh, and projectile uses ido by default, but there is helm support, too.

Community
  • 1
  • 1
shakurov
  • 2,358
  • 24
  • 27
  • Thanks for the reply, I didn't think of replacing commands so I'll look that up. I also realized since I'm using eclim it provides `eclim-file-locate` which I can use similar to eclipse's `ctrl-shift-r`. The methods you've listed off work beyond just eclim support though so they'll help me in other areas. – Sleaker Apr 20 '15 at 19:05
  • 2
    FWIW: I would *not* say "*steer clear of vanilla `find-file`*". And I doubt that "*the first thing* ***most people*** *do when switching to emacs is to replace `find-file`*" - far from it. Otherwise, the answer is OK. FWIW: You can get the same kind of "powerful", immediately-show-candidates behavior using [Icicles](http://www.emacswiki.org/emacs/Icicles). (And you can also get complete-on-demand behavior, using `TAB`, which is ***not*** useless in the context of Emacs.) In Emacs there are many, many ways to skin a cat. And the default, out-of-the-box (vanilla) behavior of Emacs is not bad. – Drew Apr 21 '15 at 15:58
1

You're looking for projectile which indexes your project's files. I used it for a while but have recently switched to using helm-recentf

(global-set-key "\C-x\ \C-r" 'helm-recentf)

I have recent files set to a large number. Pretty much anything I've ever opened is a few keystrokes away. This even doubles up as a handy way to switch buffers.

(require 'recentf)
(setq recentf-auto-cleanup 'never)
(recentf-mode 1)
(setq recentf-max-saved-items 200)
rorsach
  • 64
  • 5