Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opening more than one file split vertically through emacs -nw

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.

like image 664
yarian Avatar asked Jul 13 '11 17:07

yarian


People also ask

How do I split the screen vertically in Emacs?

You can split a window horizontally or vertically by clicking C-Mouse-2 in the mode line or the scroll bar.

How do I open two Emacs files?

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.

Can you only have one buffer open in Emacs at a time?

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.

How do I get rid of split screen in Emacs?

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.


1 Answers

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.

like image 67
zev Avatar answered Sep 23 '22 01:09

zev