Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim tears display of tmux panes

I'm running a Ubuntu virtual machine on a Win10 host (via vagrant) and having trouble getting tmux to behave properly when running vim in one of its panes. On its own, vim displays fine; however, when inside a tmux pane, the line breaks get all confused and it tears across the pane boundaries:

enter image description here

I'm using ConEmu in the video; however, the same thing happens in cmd.exe.

Update: changing panes fixes the issue temporarily, but certain kinds of edits make it happen again.

like image 955
FMM Avatar asked May 09 '16 14:05

FMM


1 Answers

You can, once vim is running, set the width (the number of columns) :

according to vim's help: the "columns" or "co" setting is:

'columns' 'co'    number  (default 80 or terminal width)
      global
      {not in Vi}
  Number of columns of the screen.  Normally this is set by the terminal
  initialization and does not have to be set by hand.  Also see
  |posix-screen-size|.
  When Vim is running in the GUI or in a resizable window, setting this
  option will cause the window size to be changed.  When you only want
  to use the size for the GUI, put the command in your |gvimrc| file.
  When you set this option and Vim is unable to change the physical
  number of columns of the display, the display may be messed up.  For
  the GUI it is always possible and Vim limits the number of columns to
  what fits on the screen.  You can use this command to get the widest
  window possible:
    :set columns=9999
  Minimum value is 12, maximum value is 10000.

You should also check if you don't have "COLUMNS" set in your environment (and therefore "inherited" inside tmux), and in that case vim may be relying on its value instead of interrogating the terminal? (here is an exemple of discussion around that kind of issue, but for another environment (debian linux, instead of windows tmux for you) : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=605279 : shows that you shouldn't export COLUMNS before launching tmux, if possible)

You should also be able to launch vim while specifying the COLUMNS value just for the duration of its invocation, with:

  COLUMNS=40  vim

for example

like image 137
Olivier Dulac Avatar answered Sep 23 '22 22:09

Olivier Dulac