I'm using a recent version of GNU Screen, supporting vertical splits.

Once I have split a window in 2, how can I switch so that they are both dividing the whole region in half horizontally versus vertical?

I need to change to horizontal in order to copy some text with mouse from one window without the visual selection overflowing and grabbing text from the other window.

Then I would need to switch back again to a vertical split from horizontal.


GNU screen doesn't come with any layouts predefined, so you need to roll your own. Here is what I've added to my ~/.screenrc :

# define layouts
layout new 'horizontal'
layout new 'vertical'
split -v
layout new  'main' 

# bind control sequences for new layouts
bind V layout select 'vertical'
bind H layout select 'horizontal'
bind ' ' layout next # <- actually means Ctrl-a + Space

With this it's possible to switch layouts with Ctrl+a Space | V | H.

(Actually, all control sequences start with Ctrl+a by default, so I'll omit it from now on.)

This solution is not ideal - after starting a screen session you initially have to tediously focus on each 'region' (parts of a layout) with TAB, and attach a process (man screen of all places insists on calling them 'windows' ) with n|p|0-9|Ctrl+c or a different method of your choice.

I imagine you'll want to detach instead of killing when possible.

... and this should hopefully cover your use case. Cheers!

  • Thanks for the revised solution. As you can write such a solution for screen but prefer tmux, it's time for me to check it out! – ljs.dev Oct 25 '13 at 23:53
  • 1
    just as an update - I did move to tmux shortly after this and never missed screen at all :) – ljs.dev May 29 '14 at 22:19
  • I looked ages for the vertical split: split -v, thanks a lot! – Daan Jul 29 '16 at 7:24

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.