4

When vim is started inside of gnu screen it does not colour the background after text.

White background

Screen looks like it should be setup for handling 256 colours correctly:

$ screen
$ tput colors
256
$ echo $term
xterm-256colors

OS & Shell I am using:

$ cat /etc/redhat-release 
Red Hat Enterprise Linux WS release 4 (Nahant Update 9)
$echo $shell
/bin/tcsh

The Colour test looks like it is working ok except the end of lines:

:runtime syntax/colortest.vim
:source %

vim colour test inside screen

And when not using screen:

vim colour test

Is there any other settings I should be checking, is there a screen mode I can force to allow the colours to be redrawn correctly?

2

Partly based on: tmux-and-screen-256-term-not-supported.

The issue resolves itself when using a 'screen' term. To identify as 256 colors correctly it should be 'screen-256colors'. Which leads to the error below :

E558: Terminal entry not found in terminfo
'screen-256colors' not known. Available builtin terminals are:
    builtin_gui
    builtin_ansi
    builtin_xterm
    builtin_iris-ansi
    builtin_d

To create a screen-256colors entry:

infocmp screen > screen-256color.ti

Changing (screen-256color.ti)

#       Reconstructed via infocmp from file: /usr/share/terminfo/s/screen
screen|VT 100/ANSI X3.64 virtual terminal, 
        am, km, mir, msgr, xenl, 
        colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,

to :

#       Reconstructed via infocmp from file: /usr/share/terminfo/s/screen
screen-256color|VT 100/ANSI X3.64 virtual terminal, 
        am, km, mir, msgr, xenl, 
        colors#256, cols#80, it#8, lines#24, ncv#3, pairs#64,

Now create the terminfo :

tic screen-256color.ti
| improve this answer | |
1

Inside screen or tmux, the value of $TERM needs to begin with screen (e.g. screen, screen-256color) rather than with xterm.

The current issue appears due to the difference in the bce (background color erase) capability of the two terminals.

The TERM=screen* descriptions do not contain this flag, and accordingly, in screen or tmux a "clear from the cursor to the end of the line" escape sequence paints that with the terminal's default background color.

On the other hand, TERM=xterm* descriptions do contain this flag, and accordingly, xterm erases using the currently active background color.

In your case, vim incorrectly sees that the terminal has the bce flag (because of TERM=xterm*) and so uses the shorthand clear operation to fill with the currently active background color, which would appear correctly directly under xterm, but appears incorrectly under screen/tmux. If you correctly give it TERM=screen* then it will notice the lack of bce and will choose to emit plenty of space characters rather than the "clear to the end of the line" sequence, which will look correctly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.