23

In Emacs using ido-mode allows me to open a file from the minibuffer with C-xC-f. This method opens only one file at a time.

How do I open all the files in a directory or specify more than one file to open?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
hekevintran
  • 22,822
  • 32
  • 111
  • 180
  • 2
    I don't know if this solution applies (hence the comment) but in combination with emacsclient (see http://stackoverflow.com/questions/4458245/how-to-set-emacs-to-open-new-files-in-current-instance-on-ubuntu-mint) you can use `find` in the commandline as well. To open all Clojure files in emacs I do this: ``emacsclient `find . -type f -name "*.clj"` `` – Christophe De Troyer May 18 '15 at 11:32

2 Answers2

18

You can just provide * as the file name and press Enter; you'll be asked for a confirmation and if you press Enter a second time, all files in the directory will be opened.

Note that "opening all files in a directory" involves opening dired buffers for all of its subdirectories.

When not using ido-mode -- at the basic Emacs find-file prompt -- you can use the same * to open all files in a directory. When you do use ido-mode to find files, you can always press C-f to drop back to the usual Emacs find-file prompt. (You can use ido to speed up getting to some directory you're interested in first and drop to the basic find-file in there.) That's one way of creating a new file with ido (the other being the C-j binding); also, it gives you another way of using the above mentioned * trick.

Michał Marczyk
  • 83,634
  • 13
  • 201
  • 212
  • @~unutbu: Which version of Emacs are you using? I'm on 23.1.50.1 (using the ido.el bundled with Emacs) and I've just checked that it works even without my config, with or without ido. – Michał Marczyk Mar 10 '10 at 03:42
  • 2
    @~unutbu: Actually, there's a variable called `find-file-wildcards` which needs to be set to a non-`nil` value for wildcard expansion to work. See `/usr/share/emacs//lisp/files.el.gz` (please adjust this path for your platform; or say `C-h f find-file `, then press `` again with point on `files.el`), line 1314 (in my version), in the definition of the `find-file` function. Let me know if this helps and I'll edit the answer to take it into account. – Michał Marczyk Mar 10 '10 at 03:51
  • @Michal: Thank you for your help! I had `(require 'ffap)` in my .emacs. When I remove `(require 'ffap)`, I get the behavior you describe. – unutbu Mar 10 '10 at 14:13
  • @~unutbu: Sure thing! Glad it works for you now. :-) As far as I can tell, `ffap` should adjust its behaviour depending on the value of `find-file-wildcards` -- no guarantees, but perhaps you might want to try it out with a `(setq find-file-wildcards t)` in your `~/.emacs`. – Michał Marczyk Mar 10 '10 at 20:40
  • 3
    Emacs 23.2.1 with `ido-mode` with default setting for `find-file-wildcards` which is `t`. Entering `*.txt` after `C-x` `C-f` opens a file *called* `*.txt`. – SabreWolfy Feb 01 '12 at 11:47
3

File-name groking is nowhere near as useful as more general pattern-matching.

In Icicles file-name completion, you can open any number of files matching any number of patterns, from the same minibuffer. Pattern-matching can be substring, regexp, fuzzy, or prefix, and you can combine patterns using intersection and complementing.

Just as in Ido, in Icicles your minibuffer input dynamically filters the file-name candidates. You can choose individual candidates or choose all that currently match (using C-!).

(You can of course use file-name groking also. As with Emacs file-name input generally, hitting RET on a wildcard (grok) pattern sends it to find-file, which opens all matching files.)

Drew
  • 29,895
  • 7
  • 74
  • 104