vim - 在tmux session 中从vim复制的文本用右边的空格填充

标签 vim copy-paste tmux

当我从一个tmux session 中运行Vim并将一些文本复制到剪贴板时,每行右边都用空格填充。

例如,说我有一个像这样的文本文件:

^some$
^text$

注意:我已经使用^$分别标记了一行的开始和结束。它们不属于文件内容。

我启动tmux并在Vim中打开此文件。我按下Shift键(以防止Vim处理鼠标单击),然后按住鼠标左键单击以标记完整的文本。然后,使用Shift + Ctrl + c将其复制到剪贴板。

剪贴板中的结果类似于:
^some                                                  $
^text                                                  $

注意多余的空格。间距的数量取决于端子的宽度。

如果我不使用tmux启动Vim,或者只是对文件内容cat然后复制它,则没有多余的空格。因此,它必须与Vim + tmux的组合有关。我已经在不同的Linux风格上看到了这一点,即在Ubuntu和Mint上。我在那里使用默认终端(Gnome终端3.6.2)。

那么我该如何预防呢?

编辑:我的tmux.conf
set-option -g prefix C-a
set-option -g mouse-utf8 off

set-option -g status-keys vi
set-window-option -g mode-keys vi
set-window-option -g mode-mouse on
set-option -g terminal-overrides 'xterm*:smcup@:rmcup@'

bind-key C-a last-window
bind-key C-h select-pane -L
bind-key C-l select-pane -R

# colors:
set-option -g status-bg black
set-option -g status-fg white
set-option -g status-left '#[fg=green]#H'
set-window-option -g window-status-current-bg red

编辑2:我也尝试过不使用上述.tmux.conf,使用tmux的默认设置-没什么区别。

最佳答案

经过更多调查,我找到了问题的根源。这是因为tmux不支持bce功能。从xterm FAQ:

The term "bce" stands for "back color erase". Terminals such as modern xterm and rxvt implement back color erase, others such as dtterm do not. (Roughly half of the emulators that I know about implement bce). When an application clears the screen, a terminal that implements back color erase will retain the last-set background color. A terminal that does not implement back color erase will reset the background color to the default or initial colors. Applications that paint most of the screen in a single color are more efficient on terminals that support back color erase. Inevitably, there are tradeoffs and issues with standardization of the feature as noted in the ncurses FAQ. Unsurprisingly, ncurses supports xterm's behavior.



原始的screen多路复用器具有此功能。我打开了一个feature request issue,但是不幸的是他们拒绝实现它。所以硬道理是:tmux无法解决。

更新:对于那些检查功能请求的人-祝你好运!作者非常有见地,皮肤也很瘦。他完全禁止我进入资料库,因为我敢于反驳他的卑鄙评论之一。小心。

关于vim - 在tmux session 中从vim复制的文本用右边的空格填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28749919/

相关文章:

powershell - 如何使用 Powershell 在 Windows 服务器上远程工作获得 *tmux* 体验?

vim - 如何导航 Vim 文件历史记录

python - 将字符串作为变量而不是可执行代码片段粘贴到 IPython 中

bash - 如何在打开新的 tmux session 后执行命令

copy-paste - CITRIX 和禁用 "Copy/Paste"

java - 检测复制或相似的文本 block

tmux - 根据远程主机名更改 tmux Pane 的背景颜色

windows - 在 Windows 中使用来自 Git 的 Vimdiff 时,颜色会变高

vim - vim 中不可能出现 `imap <s-bs> cmd` 吗?

vim - 如何将光标放在 `tab` 的开头