Skip to content

Support background color erase (bce) [was: Vim copy & paste trailing space issue] #109

@mikehaertl

Description

@mikehaertl

When I run Vim from inside a tmux session and copy some text to the clipboard, each line gets padded with spaces to the right.

For example, say I have a text file like this:

^some$
^text$

Note: I've used ^ and $ to mark the beginning and end of a line respectively. They are not part of the file content.

I start tmux and open this file in Vim. I press Shift (to prevent Vim from processing the mouse click) and mark the complete text by holding the left mouse button clicked. Then I copy it to the clipboard with Shift+Ctrl+c.

The result in the clipboard is something like:

^some                                                  $
^text                                                  $

Note the extra spaces. (The number of spaces depends on the width of the terminal window.)

If I start Vim without tmux or if I just cat the file content and then copy it, there are no extra spaces. So it must have to do with the combination of Vim + tmux. I've seen this on different Linux flavours, i.e. on Ubuntu and Mint. I use the default terminal (Gnome Terminal 3.6.2) there.

So how can I prevent this?

My 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

I've also tried without the above .tmux.conf, using tmux' default settings - no difference.

Here's my /etc/vim/vimrc.local that I use on Mint (Ubuntu derivative):
https://gist.github.com/mikehaertl/1612035

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions