85

Every once in a while I see people using what looks like terminal in their Mac, except that in what seems to be one window they have a vertical 'split.' On one side of the split, they have emacs or something, and in the other they have something else.

How can I have two independent things happening at once in the same terminal window, divided by a vertical split? It looks a lot like split pane, but split pane is a horizontal split and the actions are mirrored in the panes.

1
  • does the built in terminal in mac still does not support vertical split?
    – morpheus
    Sep 17, 2015 at 22:55

11 Answers 11

33

Possibly GNU Screen with vertical split?

image

It should already be installed on your Mac, type screen in the terminal.

You can also do this with emacs by itself.

5
  • 1
    hmm... i split emacs vertically, but it seems to be mirroring my actions... is there anyway to get two "instances" of emacs running side by side in this split view?
    – Tony Stark
    Oct 14, 2009 at 23:47
  • 21
    How does typing screen make it a split screen? May 24, 2016 at 21:10
  • @IgorG. You need to get the vertical split plugin for screen: fungi.yuggoth.org/vsp4s
    – Samie Bee
    Jun 8, 2017 at 19:34
  • With latest version of GNU screen the vertical split is built-in. Unfortunately, macOS comes with a very old version pre-installed (seems like Apple has no intention of updating it). You can manually update it though, and easily do vertical splits without any plugin. See my answer for details: superuser.com/a/1812319/117986
    – ADTC
    Oct 12, 2023 at 10:58
  • Okay, I split things, but there's no terminal running in the new splits. The first one has zsh in the bottom margin, but the newly created splits just have --. So it looks promising, but maybe not super intuitive. (I am a VIm user, so I'm up for a learning curve, so let's just give a warning that this, so far, isn't a nano level of intro hand-holding (yes, I found Ctrl-A ?).) Looks like ole 1931 has left the building, however. (hang on - help has arrived)
    – ruffin
    Apr 8 at 22:33
63

Download iTerm2 for macOSX from here.

Use cmd + d for vertical split and cmd + shift + d for horizontal split

To navigate between the vertical splits in left/right or up/down fashion use cmd + [ and cmd + ]

I recommended iTerm 2 because of these features.

Also, I like the autocomplete feature which occurs when you press cmd + ;

Features in short include the following:

  • Split Panes
  • Hotkey Window
  • Search
  • Autocomplete
  • Mouseless Copy
  • Paste History
  • Instant Replay
  • Configurability
  • Full Screen
  • 256 Colors
  • Unix-like
  • Readability
  • Mouse Reporting
  • Growl Support
  • Exposé Tabs
  • Tagged Profiles
  • Multi-Lingual
6
  • 4
    Welcome to SuperUser. please include the features in your answer, instead of relying on a link. if it ever gets broken, so does your answer. Sep 27, 2013 at 8:00
  • 2
    cmd + d, is the one!! Nov 24, 2015 at 0:07
  • In terminal, cmd + d does a horizontal split in terminal
    – Christia
    Jul 28, 2017 at 17:55
  • 1
    Oh, a lot features. That's why I prefer Terminal.
    – KcFnMi
    Aug 9, 2018 at 10:48
  • 4
    for me, cmd + d opens horizontal split and cmd + shift + d closes it. May 9, 2021 at 13:54
31

Tmux will allow you to split your screen into halves vertically or horizontally.

# install tmux
brew install tmux          # on mac
sudo apt-get install tmux  # on debian

# run it
tmux

# split the screen vertically using this shortcut
CTRL+B %

# split the screen horizontally using this shortcut
CTRL+B "

# switch between screens using this shortcut
CTRL+B o

tmux split screen

2
  • 2
    That much better since we no need to install another terminal app
    – Finn
    Jan 2, 2019 at 3:39
  • 2
    Love this once more than iTerm2
    – Vuongg
    Jun 12, 2021 at 4:59
30

If you like to work with your terminal windows in fullscreen, you can use macOS' built in screen splitting feature like so:

  1. Open two terminal windows
  2. Toggle one of the terminal windows fullscreen
  3. Activate 'Mission Control' (default: F3)
  4. Drag the second terminal window onto the first's fullscreen space
  5. Enjoy your vertically split fullscreen terminal windows

You can switch keyboard focus between terms with -[ and -]

2
  • Yep!, cool one, but I can't add multiple tabs in the same window more than 2.
    – Dexter
    May 31, 2017 at 12:47
  • you are genius!! ✌️👏🙏🏻🎓
    – SamSol
    Oct 25, 2017 at 16:41
15

According to here, native terminal (MacOS 10.15) supports splitting pane horizontally by using Command-D.And Shift-Command-D for closing pane.

It's weird to me there is no vertically splitting.

2
  • 7
    As @Arjan mentions, that feature is mirroring an existing terminal. I.e. it doesn't allow "to execute different actions" in the two panes.
    – akauppi
    May 3, 2020 at 7:51
  • 3
    How do you go from upper pane to lower and vice-versa?
    – aerijman
    Mar 2, 2021 at 17:48
9

John T's accepted answer (GNU screen, accessed with screen) was what I needed, but I needed a few minutes learning some basics to make it useful. Here is the jump start I needed on key bindings (straight from the man page) - note that you need to install the GNU version for vertical splits (listed after the FAU version that was in my Mavericks).

Also, I highly recommend you skim man screen to see what suits your needs. You can always just launch another terminal using screen and then read the manual...

Screen version 4.00.03 (FAU) 23-Oct-06

(included in Mavericks and likely similar in earlier)

       The following table shows the default key bindings:

       C-a '       (select)      Prompt for a window name or number to switch to.

       C-a "       (windowlist -b)
                                 Present a list of all windows for selection.

       C-a 0       (select 0)
        a|            a|
       C-a 9       (select 9)
       C-a -       (select -)    Switch to window number 0 - 9, or to the blank window.

       C-a tab     (focus)       Switch the input focus to the next region.  See also split, remove, only.

       C-a C-a     (other)       Toggle to the window displayed previously.  Note that this binding defaults
                                 to  the command character typed twice, unless overridden.  For instance, if
                                 you use the option "-e]x", this command becomes "]]".

...

      C-a S       (split)       Split the current region into two new ones.

...

       C-a ?       (help)        Show key bindings.

       C-a \       (quit)        Kill all windows and terminate screen.

...

       C-a *       (displays)    Show a listing of all currently attached displays.

Additional items with 'Screen version 4.02.01 (GNU) 28-Apr-14'

(installed using sudo port install screen just now)

All of the items listed above in the 4.00.02 (FAU) version, as well as:

      C-a S       (split)       Split the current region horizontally into two new ones.   See  also  only,
                                 remove, focus.

Same above, but this clarifies that it is horizontal. ...

       C-a |       (split -v)    Split the current region vertically into two new ones.
1
  • Okay, another pro tip: Splitting doesn't create a terminal. You have to create a "screen" w/ a term and then tell screen to show it in the new space. More here: To [have another term open], split the terminal window using Ctrl-a S. Once you have split panes, you can easily switch between them using Ctrl-a [Tab]. Once you are in the second pane, you need to select the terminal you want to see in that pane. You can do this using any of the methods described above: Ctrl-a ", Ctrl-a n, Ctrl-a p, or Ctrl-a [term-num].
    – ruffin
    Apr 8 at 22:41
3

After you vertically split on screen, you can type screen to create new instance. Or you can also use iTerm or iTerm2 which can use vertical split. See this link for splitted panes. www.iterm2.com/#/section/features/split_panes

0
2

very similar to John T's answer about screen, but you can also do this with tmux (http://tmux.sourceforge.net/). Nice thing about tmux compared to screen is that the vertical split feature comes even with the version you can get from packages(macports or homebrew for Mac, apt-get for ubuntu etc.).

1

To split this in emacs use ctrl + x, b (control and x together, then b) to switch to another buffer that is already open. You can also click on the filename at the bottom to switch to another buffer.

Here is a list of shortcuts to resize windows and do much more with emacs link text

3
  • Fantastic link for the cheat sheet! Thanks for sharing.
    – gbc
    Apr 30, 2011 at 14:11
  • I don't think this shortcut has any effect in Mac terminal. May 24, 2016 at 21:11
  • This command doesn't do splits at all, it just switches buffers. Also, the link is dead.
    – 8bittree
    Oct 18, 2016 at 16:04
1

How is this possible, to have two independent things happening at once in the same terminal window, divided by a vertical split?

You could say it's basically just running two programs within the same window.

In OS X Snow Leopard a horizontal split is built-in, but that indeed is a mirroring function. See also Mac OS X Snow Leopard - split Terminal windows.

1
  • i meant more of 'how can i accomplish this effect' rather than 'how does it work.' And i don't think screen is my answer; i want them side by side and independent.
    – Tony Stark
    Oct 15, 2009 at 7:20
0

The wonderful thing about screen command is that you can pre-configure it using a .screenrc file in your home directory. That being said, the default FAU version of screen in macOS is too old (4.0.3), so we need to update it to the latest GNU version first (as of now, 4.9.1).

  1. With Homebrew already installed, run brew install screen to get the latest version. (Without Homebrew, it may be possible via other options like sudo port or sudo apt - these are not explored here.)
  2. You need to open a new Terminal to use the new version.
  3. In your home directory, create a .screenrc file with these contents:
    startup_message off
    defmousetrack on
    mousetrack on
    split -v
    screen
    focus right
    screen
    focus left
    
    (You can remove the focus left command if you want the focus to remain on right.)
  4. Run screen command in the new Terminal window.
  5. Since mousetrack is turned on, you can simply click on each pane to focus on it. You can also use Ctrl-A, Tab keyboard shortcut to switch between the two panes. (Note, it's the control key, not the command key.)
    • You can hold the Fn key to temporarily disable mousetrack in order to do normal mouse actions like selecting and copying.
  6. Using exit on each window will eventually quit screen when done so in the last window with a shell. However, when you want to kill all windows and quit screen, you can just use Ctrl-A, Ctrl-\ then press Y.

Tip: There are a lot more options in screen such as the resize command. Simply type man screen to explore the documentation! Some tips:

  • All keyboard shortcuts are listed in the doc. C-a means Ctrl-A.
  • Adding resize +20% after focus right will make the right pane 70% wide.
  • You can customize the .screenrc file with more split and split -v commands to create more windows.
  • You can also create similar configuration files and pass them with screen -c path/to/file.
  • Use the focus command to switch between the windows: focus [ next | prev | up | down | left | right | top | bottom ]
  • Use the screen command (inside the file) to start a new shell in the focused window.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .