When I do M-x compile, emacs will split my window to launch compilation and show its logs in a new window. As I understand, it has some algorithm to decide how to split the window.

So, when I have just one window with code opened on my big monitor, for some reason, instead of more-convenient horizontal split (showing compile-log side-by-side on the right and code on left), it splits window vertically. How could that be tweaked? Thank you.


C-h v split-width-threshold RET should give you some useful info about that. There's also split-height-threshold, of course.


The function that splits the window is split-window-sensibly, which can be tweaked by split-width-threshold and split-height-threshold, as Stefan suggested.

Alternatively, you can tell Emacs to use a different function to split the window by setting split-window-preferred-function (the default is split-window-sensibly). For more details see C-h v split-window-sensibly RET.

  • 2
    This helped me out too, but It seems like the thresholds should be in the reverse order. For example, I would like to be able to say "if this window is really wide, split it vertically so things don't get wrapped/cutoff, and if it is really long, split it horizontally". This seems more "sensible" to me, but am I missing something in the rational for having the settings work the way they do? – elethan Nov 24 '15 at 16:10
  • 1
    @elethan absolutely agree on this. Code/text is usually located in left part of your buffer, so splitting it vertically doesn't cut amount of code you see and must go by default if it's possible, otherwise (when it's too narrow) – go with splitting vertically, cutting amount of code you see in half. – Kostiantyn Rybnikov Nov 25 '15 at 10:57
  • Looking at the source code for split-window-sensibly, there's no way to reverse the order. You will have to write (or find) a new function and set it as split-window-preferred-function. – bmag Nov 25 '15 at 17:57
  • I used this answer to fix it for myself. – Matthew Piziak Oct 9 '16 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.