1

I'm a big noob to vim here. I was trying to change the colorscheme of vim by editing the .vimrc file, but as I was playing around with different color schemes (ayu and gruvbox, for example) I noticed that only the lines that have actual text on them get highlighted, everything else stays the same black command line background color as before (see screenshots below).

I am assuming this has something to do with the fact that I am using the Windows command line and am SSH'ing to a remote Linux machine, but I have no idea how to have vim change the entire background instead of just where the text is. Does anyone know what to do/if it is possible to get the whole background highlighted?

Thanks so much! An example of the strange highlighting The .vimrc file with the strange highlighting

8
  • This can sometimes results from drawing errors or misconfigured terms (or misconfigured colorschemes). Check $TERM (env var), t_Co (vim option set based on TERM), and try doing a :redraw
    – D. Ben Knoble
    Oct 23, 2018 at 13:35
  • Thanks! Your comment lead me to checking if it was an issue with screen not supporting 256 colors, and so I added the line term "screen-256color" to my /etc/.screenvrc file, and that solved the problem! (however, it did create a new problem in that now if I add the line set termguicolors to my .vimrc file it just changes all text to white... which means I can't use themes that rely on the termgui option like ayu). But at least some custom themes work now!
    – Guy
    Oct 24, 2018 at 5:52
  • 1
    ill write the answer a bit later; as for the termguicolors, well, 256-color terms dont support truecolor (i think it’s 20-bit color? Much more than 256). If you really want termguicolors, you need a term that supports it (afaik tmux/screen do not), or use gvim. I happily live with 256 colors bc i do everything in tmux.
    – D. Ben Knoble
    Oct 24, 2018 at 13:59
  • 1
    Oh, okay, perfect. Well I'll live with 256 colors as well instead of truecolor. It looks like according this forum chain I found there is a way to get screen to support truecolor, but it's a pretty janky process to get there and I tried a little bit of what they said but it didn't immediately work and I don't want to dump a bunch of time into trying to support that. Thanks for helping me get 256 colors working!
    – Guy
    Oct 24, 2018 at 18:13
  • 1
    Looks like a problem with BCE. Does :let &t_ut='' fix it? See snk.tuxfamily.org/log/vim-256color-bce.html Oct 24, 2018 at 19:31

1 Answer 1

2

This can sometimes results from drawing errors or misconfigured terms (or misconfigured colorschemes).

A good diagnostic checklist is:

  1. Check the environment variable $TERM
  2. Check the vim option 't_Co' (it is usually set based on $TERM and should not need changed)
  3. and try doing a :redraw

Often, if the values are misaligned (or smaller than expected), colorschemes won't be able to use their full range of values (256 or truecolor/20-bit, depending).

Screen

By default, the $TERM=screen that screen uses is not 256-color. One can fix this with:

# /etc/.screenrc (or ~/.screenrc)
screen-256color

However, this is only 256 color support (the same amount the typical xterm-256color supports). If your terminal (like iTerm2, for example) supports truecolor, then you should use the --truecolor option to screen. Then you can use termguicolors.

Tmux

By default, the $TERM=screen that tmux uses is not 256-color. One can fix this with:

# ~/.tmux.conf
set -g default-terminal "screen-256color"

xterm-256color may work as well (untested).

Finally, this is again 256 color. If you want truecolor (and termguicolors) support, you'll need to set the overrides correctly (apparently this can be tricky to get right).

If often goes something like:

# ~/.tmux.conf
# OLDTERM=TERM from outside of tmux
set-option -sa terminal-overrides ",$OLDTERM*:Tc"

Make sure to restart tmux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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