Galder’s Passionate Blog

What's the point of living if you can't love or hate?

Getting Emacs 23 To Split Windows Vertically (Above/Below)

145px-emacs-logosvgSoon after I discovered grep UNIX command a few years ago, I discovered Emacs which included grep like functionality and was able to link up grepped lines with the actual lines in the log. So, if you clicked on a line that satisfied the grepped expression in the lower part of the screen, it would navigate to the actual line in the upper part of the screen. That is sooo useful when debugging logs.

Put it this way: I simply couldn’t do my job without a tool like Emacs that provided grep-like functionality.. Other tools have tried to do this, but they’re pretty poor. One such example is jEdit, which is dead slow and can’t cope with big files.

A few months ago when I upgraded from Fedora 7 to Fedora 9, I encountered a bitter-sweet surprise. The sweet part was that Emacs 23 was finally shipped by Fedora which meant that you’d get both the nice look and feel and the anti aliased fonts, wicked!. Fedora 7 didn’t had any of that, so I was building my own Emacs from CVS head source tree to get these features. The bitter part came from the fact that Emacs 23 had changed the default way in which windows were split. In the past, the split used to be vertical so that you had windows above and below. However in Emacs 23, they changed the split to be horizontal so that you’d have windows left and right. This was very annoying since I used the secondary window to check log lines and hence, a vertical split where I had an upper part and lower part would suit me much more!

I looked around and none of the suggestions I found would work, so I ended up asking help to Takayoshi Kimura, who’s a colleague of mine at work and incidentally, happens to be an emacs guru! So, to get Emacs back to splitting windows vertically add the following to your ~/.emacs:

(setq split-width-threshold most-positive-fixnum)
Someone called this a truly appalling hack but it works! Taking in account that I encountered this issue around 5-6 months ago, Emacs might already have gone back to old default of splitting windows vertically but I haven’t verified that yet.

Tagged as , + Categorized as How To


  1. Thank you for sharing this tip.

    I had the same experience with Emacs 23. Especially for grep commands I need the horizontal split of the windows by default. Your tip works perfect for me …


  2. @Markus, absolutely delighted to hear that the tip helped you :). Grep functionality in Emacs rocks and this was a proper show stopper for me as well.

  3. I realize I’m way late to the party here, but I found this via a Google search, and I believe

    (setq split-width-threshold nil)

    Is a more elegant way of solving the same issue.

  4. @Brian, indeed, that works as well :). Thanks!

  5. And how to do that horizontally?

Leave a Reply