tmux / vim split panes

6

I am borrowing this screenshot from another question:

enter image description here

The terminal background seems to leak through into vim left of the dividing border. This is most noticeable near Top.

Can anyone tell me why/what this is and if I can get rid of it so the divide is clean?

DanS

Posted 2012-10-12T16:20:54.077

Reputation:

Going to guess here that what you're seeing is a side effect of the fact that characters in a terminal emulator must take up a full block. That block has a single foreground and a single background color. Because the line is drawn with characters within the terminal emulator you're going to have this "leak". – Randy Morris – 2012-10-12T17:12:04.513

Does that block appear outside of tmux? My educated guess is that Vim simply doesn't paint that block, because to do so (at least in certain terminals) would cause the cursor to wrap around, thus scrolling the whole screen/pane up one line. – echristopherson – 2012-10-12T21:21:16.837

Answers

8

The character used by tmux for drawing its pane border is or U+2502. It is a 1px or 2px wide line in the middle of the cell. The rest of the cell is empty and you are just seeing your terminal's background color on each side of the line.

I see three ways to "fix" this.

  • Use the same background color in Vim and your terminal emulator.

  • Tell tmux to draw borders with the same color for the background and the foreground.

  • Tell tmux to use some other character like █ to draw the borders.

The two last solutions will make your borders noticeably fatter and the last one may introduce display glitches depending on the font you use.

I personnally have my Vim background and my terminal background set to the same color.

(thanks ZyX)

romainl

Posted 2012-10-12T16:20:54.077

Reputation: 19 227

I really don't think there's a way to replace the border character - not without tweaking the source at least. – dev – 2017-02-14T11:29:47.873

1One correction: tmux does not use bar for drawing border, it is using U+2502 “BOX DRAWING LIGHT VERTICAL” character instead which looks much better (bar symbol does not occupy full height (in terminus and almost all other fonts I tried), and even contains a space in the middle in some other fonts). – ZyX – 2012-10-12T20:10:41.623

6By the way, what is the option for changing border character? I found a number of them for changing border colors, but not for changing border character. – ZyX – 2012-10-12T20:34:05.710

3

Following the third @romainl advice you can use U+258C or U+2590 characters (LEFT and RIGHT HALF BLOCK characters respectively) and tell tmux to set (in case of LEFT and vim being on the left) foreground color to vim background and background color to shell background.

This option is to be set from the vimrc when $TMUX variable exists and is non-empty (it is set by tmux inside child processes) and reset on the VimLeave event. This assumes that you always open vim in left pane only. With some adjustments you can detect what pane you are in (tmux list-panes, one with (active) at the end) whether there is vim in adjacent window (by checking the border key) and adjust tmux settings accordingly.

ZyX

Posted 2012-10-12T16:20:54.077

Reputation: 253