Vertical split for GNU screen

Now that I have a 24″ widescreen monitor at work, I have a lot of horizontal space at my disposal. One of the nice things about this is that I can split my Emacs window down the middle with C-x 3 and have one pretty nice-size buffer on the left and another on the right. This is nice when working with two files and it’s also a pretty nice setup if I keep a file on one side and a shell buffer on the other. Normally, I don’t use Emacs shell buffers much, because I never really got accustomed to the paradigm and I end up losing some of the nice key bindings and tab completions that I have set up for bash. But with my recent work, which is Firefox extension development, I am frequently restarting the browser from the shell (thanks, Mozilla!) and so it’s kind of nice to have the shell very handy right there in Emacs.

This all got me to thinking that it would be cool to try using GNU screen with a vertical split, except that it quickly became apparent that classic GNU screen only does horizontal splits. Well, until you patch it at least:

Vertical split for GNU screen

I just applied this patch to screen-4.0.3 and built screen on my PowerBook. If you are using screen to connect to an already running screen process, then you’ll need to restart that screen process. Once you fire up the new version of screen and look at the help screen, you’ll see a new command called “vert_split” assigned to V (capital V).

Vertical split patch for GNU screen

Incidentally, for some strange reason, all the GNU mirrors have screen-4.0.2.tar.gz as the latest version, but it seems that there is a screen-4.0.3.tar.gz but I could only find it at

Incidentally #2, what is called a “vertical split” by this GNU screen patch and by me in this blog post (namely, that the line that splits is a vertical line, resulting in two regions side by side) is actually called a “horizontal split” by Emacs (the command which performs the aforementioned split is called split-window-horizontally). While this is not unreasonable, since “horizontal” was presumably meant to refer to the fact that the resulting regions are horizontally adjacent to each to other, it’s confusing and annoying that the terminology differs from program to program. Sigh.

12 thoughts on “Vertical split for GNU screen

  1. Interesting. I got curious as to why 4.0.3 isn’t on the GNU servers. So, I downloaded the latest official version (4.0.2) and then this 4.0.3 version (which, interestingly enough, is not signed). Anyway, “diff -u” reports that only two files changed: encoding.c and patchlevel.h, and encoding.c has some UTF-8 changes that I don’t quite understand.

    But, all that junk having been said, I think I will try out this patch. I use GNU screen quite a bit, and I would love the ability to split it down the middle like that!

  2. “It hurts us!”

    Screen is evil. It’s like the anti-emacs. What could you possibly want screen for when you have the one, true, text-based windowing system?

  3. Chris, I use GNU screen (in addition to Emacs) because I’ve never found a way to make Emacs do the best thing that screen does – suspend and resume sessions, sort of like text-mode VNC. So the most typical way that I work is that I am using my PowerBook ssh’d into my Linux box, which is where I’m doing my editing and compiling (in fact, pretty much everything except web browsing, email, and iTunes).

    So if I run Emacs as an X client, the minute I unplug to go home, it dies (I hope that a future version of X allows switching the display dynamically – then one could switch a program to a headless X server to suspend it and then switch to another X server later – hmmm, maybe I should just use NX…)

    If I run Emacs in text mode inside an ssh session to my Linux box, well, that dies too.

    And also, I’ve never quite gotten use to shell buffers in Emacs. It’s definitely convenient to have them right there in Emacs and searching for things in the buffer history is super easy, but I tend to miss things from vanilla bash like the up and down keys for history and tab completion which is much smarter than what Emacs can do AFAIK (please enlighten me if I’m wrong). I’m surprised that you’d like shell buffers, since I think you’re a zsh user and you might be missing out on even more zsh goodies when you’re using Emacs shell buffers?

  4. Amen to that. 🙂

    I have used GNU Screen to teach people how to use CLI software and perform system maintenance, as well. Awfully convenient, that.

  5. Nice, was just searching Google for the exact same thing. I’ve been using Ratpoison as my primary window manager (on a small laptop) for longer than I’ve been using GNU Screen, so I was miffed to find that I couldn’t just do +Capital_S to split vertically.

    Funny that the solution I find is from another VMware hacker (recognized your name from mailing lists) 🙂

  6. I know you won’t like to hear it, but vim calls splitting the window into two side by side sections a vertical split and uses the command ‘:vs’.

  7. I tried this patch. however, all vertical splits are gone after a putty screen resize. this makes it virtually unusable at least for remotes, I guess. also, a line marking the split would make it something useful not just shadows in the dark 😉

  8. Screen is very good at what it does and hasn’t been rivaled in my eyes.

    – Multiple sessions
    – Send commands to multiple sessions
    – Split Vertically/Horizontally (yes different distro’s call diff versions the latest, run ubuntu and win, if not remove from you maintainer repo’s and install from elsewhere)
    – Session persistence. (EMAC’s wont save you from issues where you were doing something important over ssh or something and then a network issue occured which disconnected your session, for those who dont nohup everything or have nohup built into their shell’s job controls then you SOL. And thats for anything you are doing in a terminal, not just editing a file.)
    – Super Configurable.

    Screen + Vi FTW x1
    Screen + Vi + ZSH x2
    Screen + Vi + Zsh + Terminator — omg FTW x3 for functionality woohoot!

    PS – Serra, my lines are rather defined in my vsplits and hsplits, in fact, i get a border and 2 or however many splits i have open status lines. Looks sweet for me what terminal/configuration you using?

  9. With readline-complete and/or bash-completion (search the emacs wiki to know what I am talking about), it is now possible to have readline completion inside an emacs shell. It is still wip but it is promising.

Leave a Reply

Your email address will not be published.