3

I'm trying to use a vim while inside a screen session. For some reason, the background color for the parts of the screen without text are displaying as dark while the parts with text are displaying as light (screenshot below). When I switch the bg to dark (set bg=dark), everything is fine, but that's not really what I want. I should point out that everything works as expected when not in a screen session.

I'm happy to provide bash/vim/screen rc files if it would be helpful, but I won't blindly paste them all in here unless asked.

vim screenshot

3 Answers 3

2

No. set t_Co=256 is not the solution, setting up your terminal emulator and screen is the solution.

Assuming your terminal emulator is set to advertise itself as xterm-256color, you only have to add this line to ~/.screenrc:

term "screen-256color"
1
  • You're probably right here. Unfortunately, I'm using a script with screen that prevents me from doing the correct thing at the moment and fixing that script is a lower priority at the moment than a quick and dirty fix. Dec 17, 2013 at 18:14
1

Inside screen or tmux, the value of $TERM needs to begin with screen, not xterm.

See Vim not colouring the end of lines when run inside screen for the same question, and also a detailed explanation of the answer.

1
  • Occasionally it is also necessary to restart the terminal. At least for the bash in cygwin the change was only picked up after the restart.
    – GWD
    Dec 1, 2021 at 22:23
0

I ended up finding the answer. I needed to add

set t_Co=256

to my .vimrc and that fixed the issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .