Using emacs -nw file1 file2
I can open multiple files at once. However, emacs will open them in horizontal splits. Is there a way to set default split behavior to vertical? I have looked at:
ToggleWindowSplit
If I could have emacs call that automatically every time I open multiple files that would do what I am looking for.
I also looked at this SO post.
Their suggestion of adding (setq split-height-threshold nil)
and (setq split-width-threshold 0)
in ~/.emacs
did not work for me. I have tried them separately and together.
You can split a window horizontally or vertically by clicking C-Mouse-2 in the mode line or the scroll bar.
Much better to use the multiple buffer feature of emacs. If you are editing the first file and want to start editing the second file, simply use the hot key C-x C-f or the menu selection File->Open File to start the second file. The second file is loaded into its own buffer.
You can have several buffers open at once, but can edit only one at a time. Several buffers can be visible at the same time when you're splitting your window.
Use the C-x b command or the Buffers menu. Or if you haven't opened the file, yet, use the C-x C-f command to open the new file in a new buffer. To unsplit the window, use the command C-x 1 or right-click on either title bar.
In your init file, add the toggle-window-split function code. Then, add the following line of code to your init file:
(add-hook 'emacs-startup-hook 'toggle-window-split)
This will call the toggle-window-split function automatically every time you startup emacs. If you startup emacs with 2 files on the command line, they will be displayed in vertical splits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With