# How to open multiple files in emacs?

**URL:** https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658
**Category:** General
**Created:** [May 5, 2024, 10:40am UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658 "2024-05-05T10:40:11Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![GoldAyan](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@GoldAyan](https://forum.systemcrafters.net/u/GoldAyan)
#### Post date: [May 5, 2024, 10:40am UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658/1 "2024-05-05T10:40:11Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![Kolev](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/kolev/32/1045_2.png) [@Kolev](https://forum.systemcrafters.net/u/Kolev)
#### Post date: [May 5, 2024, 11:04pm UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658/2 "2024-05-05T23:04:40Z")

</div>

- C-x C-f `file name` RET
- Repeat

---

<div class="post-metadata">

### Author: ![mirkoh](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@mirkoh](https://forum.systemcrafters.net/u/mirkoh)
#### Post date: [May 6, 2024, 9:18pm UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658/3 "2024-05-06T21:18:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ramin\_hal9001](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/ramin_hal9001/32/76_2.png) [@ramin\_hal9001](https://forum.systemcrafters.net/u/ramin_hal9001)
#### Post date: [May 7, 2024, 1:09am UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658/4 "2024-05-07T01:09:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![frank](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@frank](https://forum.systemcrafters.net/u/frank)
#### Post date: [May 11, 2024, 2:52am UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658/5 "2024-05-11T02:52:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![GoldAyan](https://avatars.discourse-cdn.com/v4/letter/g/9d8465/32.png) [@GoldAyan](https://forum.systemcrafters.net/u/GoldAyan)
#### Post date: [May 21, 2024, 1:10pm UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658/6 "2024-05-21T13:10:35Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mirkoh](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@mirkoh](https://forum.systemcrafters.net/u/mirkoh)
#### Post date: [June 5, 2024, 9:52pm UTC](https://forum.systemcrafters.net/t/how-to-open-multiple-files-in-emacs/658/7 "2024-06-05T21:52:49Z")

</div>

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