How to open multiple files in emacs?

Currently my flow is opening dired and mark the file i need to open and press F (F is from dired-x). How you guys do it ?

1 Like
  • C-x C-f file name RET
  • Repeat
2 Likes

I’m using the same approach as Kolev, just open files one by one.
With evil I have project-find-file bound to space f f.
Using dired I just press enter to open the file, or mark them with m and then open them.

There is probably a better way to do it.

There is a function in the dired-x.el library you can use that will visit every marked file: dired-do-find-marked-files. Bind this to a key like C-c f m. If you precede this command with C-u it will buffer the files but not display them.

So before I run this command to open all marked files, I often like to mark files that match a regex pattern using the built-in Dired dired-mark-files-regexp, which is bound to %m by default. Use it like this, for example:

%m [.]el$ <RET>

marks all files ending with “.el”.

You can also mark all files by searching the file content with Grep using dired-mark-files-containing-regexp. This command is bound to %g by default. So for example mark all Python source files with a “main” function:

%g if *__name__ *== *__main_ *: <RET>

…or mark all shell script files that might not end in .sh:

%g [#][!] */bin/\(ba\|\)sh <RET>

So I will run one of the above commands then type C-c f m and Emacs opens all the selected files at once.

2 Likes

use harpoon, assign each file a number in cache file, then press number to open your file

1 Like

I found a another way using embark which works perfectly for me.

This is what i do now a days ?

  • C-x C-f and use regex like *.elisp (to list all elisp in particular directory) [I use consult package]
  • C-. for embark to show actions
  • Select A for embark-act-all
  • Then press (Enter) to open all the files.
1 Like

Thanks, I’ve been experimenting with this package, very useful. I remapped the go to functions to be letters in the home row.

1 Like