la11111
la11111

Reputation: 361

multi-column terminal multiplexer?

Let me explain what I'm looking for, hopefully for the terminal, but if it exists in an IDE, i'll take that too.

I have a laptop with a 1366x768 resolution screen; I use vim for code-writing, and I use a fairly small font in my terminal (~7pt). So, as you might imagine, there's a lot of "wasted" horizontal space, especially when coding in a compact language like python.

I just checked and found that with a 6pt. font, the maxyx of my terminal is 82 rows x 271 columns. What I'd like to have, essentially, is a single terminal with the dimensions of 246 rows x 90(89?) cols, split into 3 panes and displayed side by side. But, they would need to behave as one contiguous vertical pane, i.e., when i scroll in my editor, all three of them scroll synchronously.

Does anyone know of a hack or anything to accomplish this? Maybe for vim/screen/similar?

Patching screen might be a fun project, but I don't have time to chase that rabbit. If someone out there does, though, I'll order them a pizza or something ;)

(although if i get around to it first, i'll have to order myself a pizza)

Upvotes: 8

Views: 3557

Answers (3)

nikolay_turpitko
nikolay_turpitko

Reputation: 826

I came here in search for a way to read long texts in 2 columns (newspaper-like).

column file.txt was not sufficient for my needs, because it rendered whole text at once and I was not able to use pager (like less) with it.

As suggested by other comment, I was able to use vim or tmux for this.

Here my snippets of code:

# vim (^F below is typed with `Ctrl+v Ctrl+f` in the terminal)

alias split-vim='vim -u NONE -R +vs "+normal ^F" "+wincmd x" "+windo set scb"'

split-vim _books/fiction/dune.md

# tmux

function split-tmux { tmux new-session "$*" \; split-window -h "$*" \; send-keys -t 1 PageDown \; set-window-option synchronize-panes \; attach }

split-tmux less _books/fiction/dune.md
split-tmux mcview _books/fiction/dune.md
split-tmux vim -u NONE -R _books/fiction/dune.md

vim variant:

  • -u NOME option allows to skip heavy initialization to make it start faster;
  • -R opens it read-only and without swap file;
  • +vs splits the view;
  • +normal ^F send keybinding to scroll one page;
  • +wincmd x exchanges views, so that scrolled view was on the right;
  • +windo set scb sets scrollbinding;

tmux variant:

  • starts new session, executing rest of the args as a shell command;
  • splitting window, executing same args as a shell command in it (second time);
  • sends PageDown keystroke to the second pane;
  • sets option to sync panes;

Actually, I like tmux variant more, because of it's flexibility, though, I guess, it takes a bit more resources.

Upvotes: 0

Helmut Grohne
Helmut Grohne

Reputation: 6778

I had the very same desire and others want this as well. Lacking any options I implemented my own two column virtual terminal. See the --columns option for selecting a different number of columns than two.

Upvotes: 10

laher
laher

Reputation: 9110

EDIT: based on comments, I now understand the requirement better. i.e. viewing one text file in a newspaper-like multi-column format.

It seems more like an editor feature rather than a multiplexer feature (because the 2 editors should be linked). Thanks to @romainl for mentioning :set scrollbind. This seems capable of doing the job in combination with some additional vim magic.

Here's an superuser q&a showing how to use scrollbind for your purposes: https://superuser.com/questions/243931/how-do-i-maintain-vertical-splits-with-scrollbind-in-vim .

Original answer: vim and [recently] screen both offer vertical-split, as does tmux.

I don't know about any way to scroll simultaneously, but tmux's 'synchronize-panes' does offer simultaneous input. Can be useful!

  • For vim, use :vsplit
  • For screen (recent versions), use C-a |
  • Alternative to screen, I use tmux. It offers (default keys) C-b %, then you can use C-b :setw synchronize-panes for simultaneous input across panes.

Hope this helps.

Upvotes: 2

Related Questions