username_4567
username_4567

Reputation: 4903

Emacs : Open buffer in vertical split by default

I am very very new to emacs. I want something like this. Every time I open a new buffer, it should split current winodow vertically. How should I change .emacs file. Please provide some pointers.

Upvotes: 27

Views: 25595

Answers (4)

ideasman42
ideasman42

Reputation: 47968

From this post on reddit you can set this explicitly for ediff.

(custom-set-variables
 '(ediff-window-setup-function 'ediff-setup-windows-plain)
 '(ediff-diff-options "-w")
 '(ediff-split-window-function 'split-window-horizontally))

This has the advantage that it doesn't impact other splits.

Upvotes: 0

Mario Giovinazzo
Mario Giovinazzo

Reputation: 451

Add This to .emacs to split windows vertically as default opening a new buffer in other windows

(setq
   split-width-threshold 0
   split-height-threshold nil)

Upvotes: 5

Stuart Hickinbottom
Stuart Hickinbottom

Reputation: 1360

I don't remember the exact route I followed to get this, but I have the following configuration to suggest to Emacs that it should split the frame vertically rather than horizontally when Emacs has the choice (eg when bringing up help).

This seems to work fine on my widescreen monitors.

(setq split-height-threshold nil)
(setq split-width-threshold 160)

Upvotes: 20

Robin Green
Robin Green

Reputation: 33033

You know that you can do this manually with C-x 3 right? So we can use this fact to learn how to add the command to do this to .emacs.

We just need to find out what the function is. So let's do C-h k C-x 3 to find the help for C-x 3. That shows:

C-x 3 runs the command split-window-right, which is an interactive compiled Lisp function in `window.el'.

So, open .emacs (C-x C-f ~/.emacs), go to the end of the file and add:

(split-window-right)

Then save the file, restart emacs and it should work. I just tested it.

Upvotes: 23

Related Questions