0

Emacs-27.1 ships with a new tab-bar-mode minor mode. This puts a tab bar at the top of each Emacs frame. Each tab in the tab bar can display multiple windows.

Is there any way to invoke Emacs from the command line and have it open multiple files in separate tabs?

For instance, I want to run a command like the following:

$ emacs --some-flag file1.txt file2.txt file3.txt

Emacs should open file1.txt, file2.txt, and file3.txt in separate tabs (instead of separate buffers). Is there some way to get this to work?


Vim has a -p flag that allows it to open files into separate tabs instead of just separate buffers.

2

Having just read on the Emacs Stack Exchange Make display-buffer open buffer in new tab and applying it to your situation, I suggest you put in your .emacs file:

(setq display-buffer-base-action '(display-buffer-in-tab))

save it and then call from the command line without any additional flag:

$ emacs --some-flag file1.txt file2.txt file3.txt
| improve this answer | |
  • Oh, that's a smart idea. However, I don't actually want to use Emacs with display-buffer-base-action turned on all the time. Is there some way to set it to only be active while processing the files from the command line? – illabout Nov 12 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.