Vim在tmux窗格中显示不全的问题

7

我正在Win10主机上(通过vagrant)运行Ubuntu虚拟机,当在tmux的一个窗格中运行vim时,出现了问题。单独运行vim没有问题,但是在tmux窗格内,换行符会混乱并跨越窗格边界:

enter image description here

我在视频中使用ConEmu; 然而,在cmd.exe中也会发生同样的事情。

更新:更改窗格可以暂时解决问题,但某些类型的编辑会再次导致此问题发生。


2
这几乎肯定是您的 TERM 设置问题,但这更适合在 superuser.com 上提问。 - chepner
1个回答

3

一旦vim开始运行,您可以设置宽度(列数):

根据vim的帮助文档,“columns”或“co”设置是:

'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.

您还应该检查您的环境中是否未设置"COLUMNS"(因此在tmux内“继承”);在这种情况下,vim可能依赖于其值而不是询问终端?(这里是讨论那种问题的示例,但是针对另一个环境(debian linux,而不是windows tmux):https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=605279:显示在启动tmux之前不应导出COLUMNS,如果可能的话)。您还可以在指定COLUMNS值的同时启动vim,只需在调用期间即可。
  COLUMNS=40  vim

例如

我不确定问题是否出在vim对列数的理解上。我应该明确指出:更改窗格可以暂时解决问题,但某些类型的编辑会再次引起此问题。 - FMM
@FMM:在你的动态图中,似乎 Vim 认为它少了 1 列(也许是因为中央垂直线?) - Olivier Dulac

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接