7

I would like to know Emacs' equivalent of Vim's :n, which opens several files according to a glob.

Say I have this directory:

-rw-rw-r-- 1 pablo pablo 31 Jun 25 00:59 /home/pablo/tmp/prueba.php
-rw-rw-r-- 1 pablo pablo 2442 May 9 1913 /home/pablo/tmp/sin_soap.php
-rw-rw-r-- 1 pablo pablo 726 Jun 25 15:20 /home/pablo/tmp/verificar.php

And I want to open all those files. In Vim, I can type

:n *php

and that will give me one buffer for every file; I don't know how to do that in Emacs (when it's already open, of course I can do 'emacs *php' in a shell).

I'm happy with a function that I can call from any buffer via M-x, but if there's a command that I can call in dired-mode (say, edit all marked files or something), that would be beyond cool.

Thanks.

ptn777
  • 238
  • 1
  • 10

2 Answers2

14

The ordinary find-file command, C-xC-f, will accept wildcards and open multiple buffers. From the documentation:

Interactively, or if wildcards is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files. You can suppress wildcard expansion by setting `find-file-wildcards' to nil.

In your example you'd just type C-xC-f*phpRET.

Sean
  • 29,130
  • 4
  • 80
  • 105
  • 1
    Dude. I had no idea. I've been wanting to be able to do that for *years*. – zwol Aug 30 '10 at 04:10
  • That's what I get for using ido-find-file instead... Also, I found this: http://stackoverflow.com/questions/1110118/in-emacs-dired-how-to-find-visit-multiple-files – ptn777 Aug 30 '10 at 06:53
  • If you use `ido-find-file`, you can do `C-x C-f ~/path/to/somewhere/*.txt`, but instead of pressing return, press `C-x C-f` to start the regular find-file with the current input – dbr Dec 13 '12 at 21:08
0

Open the directory in dired, or use find-dired to create a dired buffer using Unix find (i.e. not find-file), then mark the files you want (with m) to open and press F.

Joel J. Adamson
  • 713
  • 4
  • 10