19

I have a problem with making vim show a colorscheme fully (like in gvim). I've read about how to enable 256 color mode in terminal and it vim, but somehow it just doesn't work. The state of now is:

:echo &t_Co returns 256

[~]$ tput colors
256
[~]$ echo $TERM
xterm-256color

Colortest shows all the colors: colortest

But yet, vim doesn't show grey20 color of the colorscheme, instead using the terminal background. I also tried changing it to grey without success: hi Normal

The system is ubuntu 14.04. and the terminal gnome terminal, although I've tried with terminator and tmux, with no success.

Any idea what could gone wrong?

1
  • 13
    And just for the next guy looking for colortest.vim: :so $VIMRUNTIME/syntax/colortest.vim Commented Sep 23, 2018 at 18:42

1 Answer 1

11

The colorscheme must be missing cterm definitions, the full highlight command should look like:

hi Normal cterm=NONE ctermfg=15 ctermbg=7 gui=NONE guifg=White guibg=grey20

If your terminal supports 256 colors, you might need color codes greater than 16.

If you have a true color terminal, you could add these settings instead to enable 24-bit compatibility:

set termguicolors

" Correct RGB escape codes for vim inside tmux
if !has('nvim') && $TERM ==# 'screen-256color'
  let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif

From the help for 'termguicolors':

Note that the cterm attributes are still used, not the gui ones.

Read more:

1
  • Good, simple solution. You may need to use tmux-256color in your comparison, nowadays.
    – Walf
    Commented Sep 15, 2021 at 3:07

Your Answer

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

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