opening more than one file split vertically through emacs -nw
Asked Answered
C

2

7

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.

Colliery answered 13/7, 2011 at 17:28 Comment(0)
K
9

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.

Katinakatine answered 16/7, 2011 at 0:36 Comment(0)
L
3

By default emacs will pick a vertical or horizontal split based on the size of your terminal.

If you want emacs to put files side by side no matter how wide your terminal add this to your .emacs:

(setq split-width-threshold 0)

If you want emacs to put files one above the other no matter how short your terminal is add this to your .emacs:

(setq split-height-threshold 0)
Ligulate answered 13/7, 2011 at 17:57 Comment(2)
did you try setting only one and not the other? When I set one to 'nil' like in your post it didn't work for me either. Just set either width or height to 0.Ligulate
Yup. I tried both your suggestion of (setq split-width-threshold 0) and (setq split-height-threshold nil) separately.Colliery

© 2022 - 2024 — McMap. All rights reserved.