I write most of my code in Emacs, and my preferred setup is to have the window split horizontally with two buffers side-by-side:

I find it frustrating when something automatically creates new splits and alters my layout instead of reusing the existing ones. This has been happening especially frequently since I got a high resolution screen, the Dell U3011. Emacs will keep splitting until the window is partitioned into a 2×2 grid whenever I run a command that outputs to its own buffer:

Personally, I find this behavior distracting and a waste of screen estate. To fix it, I added the following lines to my .emacs file:

(setq split-height-threshold 1200)
(setq split-width-threshold 2000)

Those values are somewhat arbitrary, but as a rule of thumb the higher the values the less likely Emacs is to create new splits. For full documentation, see the Emacs manual.

5 responses


Do you want to comment?

Comments RSS and TrackBack Identifier URI ?

Thank you, finally the correct answer!
Everyone else attempting to answer this question does so by suggesting things like:

(setq special-display-buffer-names
‘(“*whatever*” “*Help*”))

Or using -nw to start emacs etc etc.

This was the answer I was looking for, I assumed there would be an option like this considering that emacs does not mess with my layout on my laptop (which has a lot lower resolution).

April 16, 2013 10:42 am

Thanks for the awesome answer!

September 21, 2014 10:37 am

This is the best explanation of this out there1

April 14, 2015 1:55 pm

Thank you so much for this! I like the same layout you do and running a compile script was opening new windows instead of using the other (which I much prefer). This worked, and I don’t remember being so happy about a text editor!

December 20, 2016 10:25 pm

Setting those values was not preventing XEmacs from splitting the window whenever I would launch it from the command line with multiple files. This however, did work:

http://askubuntu.com/questions/4820/keeping-emacs-from-splitting-the-window-when-openning-multiple-files

I know it’s not the same scenario as what you’re doing, but googling returns this page above the one that solved my issue, so I thought I would comment with the link to save someone else the extra clicks.

Incidentally, the suggestion on the page above plus some extras you also need to prevent window splits upon startup:

“`
;;Don’t show me an errors/warnings buffer in a split view..
(setq display-warning-minimum-level ‘error)
(setq inhibit-startup-screen t)

;;Prevent xemacs from splitting the view when multiple files are opened:
(add-hook ’emacs-startup-hook
(lambda () (delete-other-windows)) t)
“`

February 27, 2017 11:05 am

Comment now!
















Trackbacks