linux tmux vim 复制,从tmux会话中的vim复制的文本用右边的空格填充

当我从tmux会话中运行Vim并将一些文本复制到剪贴板时,每行都会在右边填充空格.

例如,假设我有一个这样的文本文件:

^some$

^text$

注意:我已经使用^和$分别标记一行的开头和结尾.它们不是文件内容的一部分.

我启动tmux并在Vim中打开此文件.我按Shift键(阻止Vim处理鼠标点击)并按住鼠标左键标记完整文本.然后我用Shift Ctrl c将它复制到剪贴板.

剪贴板中的结果如下:

^some $

^text $

注意额外的空格.空格数取决于终端宽度.

如果我在没有tmux的情况下启动Vim,或者如果我只是捕获文件内容然后复制它,则没有多余空格.所以它必须与Vim tmux的组合有关.我在不同的Linux风格上看到了这一点,即在Ubuntu和Mint上.我在那里使用默认终端(Gnome Terminal 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’默认设置 – 没有区别.

嗯,我找到了一个解决方法,将屏幕上的TERM更改为xterm:

TERM=xterm vim

或者在〜/ .tmux.conf中使用以下内容

set -g default-terminal “xterm”

上面我在GNOME终端的本地shell和SecureCRT的远程shell中进行了测试.

如果这仍然不起作用,也许你可以检查你的〜/ .vimrc或其他全局设置中没有“set t_ut =”,因为我发现这打破了我的解决方法.

但是在“man tmux”中,它说

“The TERM environment variable must be set to “screen” for all programs running inside tmux. New windows will automatically have “TERM=screen” added to their environment, but care must be taken not to reset this in shell start-up files.”

“Set the default terminal for new windows created in this session – the default value of the TERM environment variable. For tmux to work correctly, this must be set to ‘screen’ or a derivative of it.”

我不知道这个的副作用.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值