In vim, background color changes on scrolling

16

6

Occasionally I get a weird error with the background color in vim when scrolling up in a long file. The background over the text is correct, but everywhere there is no printable character the background turns black.

After a bit of hunting and experimenting, I have found that :redraw! fixes the problem, but I would like to know why this occurs and if there is anything I can do to permanently fix the issue.

Although I have gotten this error to occur with other color schemes, for what it is worth I am using the lucius color scheme with vim 7.3 editing a bunch of python files.

jlund3

Posted 2012-08-05T21:55:39.817

Reputation: 457

I've done a bit more playing, and it seems to happen only when I have my terminal geometry set with a height larger than 30 or so. I'll have to do more testing to see if this holds, but maybe that information will help someone figure out what is wrong... – jlund3 – 2012-08-06T00:58:03.843

Here is an example screenshot of this behavior. I scrolled up and instead of the lovely grayish background, there is some ugly black stuff.

screenshot

– jlund3 – 2012-08-06T01:22:44.967

Have you tried several different terminal emulators (like xterm, gnome-terminal, etc.)? – amcnabb – 2012-08-07T20:48:35.043

I've managed to reproduce the behavior in both lxterminal and gnome-terminal. – jlund3 – 2012-08-07T21:18:14.260

I have the exact same problem. Mine started to happen when i moved stuff to ftplugin/<filetype>... – RedX – 2013-03-15T13:48:57.457

Answers

25

As explained here and here, you can fix this by turning off Background Color Erase. Change in your .vimrc:

if &term =~ '256color'
    " Disable Background Color Erase (BCE) so that color schemes
    " work properly when Vim is used inside tmux and GNU screen.
    set t_ut=
endif

You can also type Ctrl+L to reset the screen.

brice

Posted 2012-08-05T21:55:39.817

Reputation: 2 206

0

This may be a plugin or configuration related, perhaps try

vim -u NONE

to load vim without the vimrc and without plugins and see if the problem persists.

As far as configuration, I think you should probably look at lazyredraw and ttyfast.

You can read the documetation by typing (:help lazyredraw) and find out if you've unknowingly set it (:set lazyredraw?) and probably unset it (:set nolazyredraw).

And it may help if you set ttyfast (:help ttyfast).

carlosdc

Posted 2012-08-05T21:55:39.817

Reputation: 328

I tried both nolazyredraw and ttyfast, but the behavior remains the same. – jlund3 – 2012-08-06T00:54:42.770

@jlund3 I've edited my answer a little bit. – carlosdc – 2012-08-06T01:55:11.880

With -u NONE there are no colors for this to happen. However, with just the command :colorscheme lucius it still happens... – jlund3 – 2012-08-06T02:46:24.300