Color scheme(s) in Vim not properly working

3

On Archlinux, using Vim 7.4 (installed with pacman), I tried to use the lucius color scheme. However, the moment I turned it on, all color went away. This happened in the Xfce Terminal emulator under XFCE (black on white, since that was the color scheme of the emulator), or before even starting X11 (then, white on black). Going back to the default coloring scheme turned colors back on.

Using Vim under uxterm did not have this problem.

On Ubuntu 12.04, using Vim 7.4 (compiled from source) with the exact same .vimrc and .vim contents, on the same Xfce terminal emulator, under XFCE, did not have this problem.

I did manage to get it to work on Archlinux for Xfce terminal and command line: I added the following to the top of my .vimrc:

set t_Co=256

This suggestion came from here.

What was wrong with my setup before that? What is the correct way to get this to work?

XXX

Posted 2015-05-21T17:19:47.987

Reputation: 133

Answers

2

set t_Co=256 enables Vim to use 256 Colors in terminals that support that (I think most of them do). Without that command Vim will only show 8 or 16 different colors.

If you load a colorscheme that is 256 colors only (or made for that in mind) it will look off or just not display correctly if t_Co is not set to 256.

http://vim.wikia.com/wiki/256_colors_in_vim

ap0

Posted 2015-05-21T17:19:47.987

Reputation: 1 180

The same setup (as close as it gets) but on Ubuntu 12.04 did not have this problem (see the edit). The .vimrc on the Ubuntu installation did not have the set t_Co=256 either, but the colors showed perfectly fine. So I guess there must be something more to it? – XXX – 2015-05-21T18:18:56.980

Yes. Some Colorschemes set this option by them self in their configuration such that the user doesn't have to. – ap0 – 2015-05-21T18:19:37.533

Yes, but it was the same colorscheme, the same .vimrc, and (as far as I am aware) the same .vim contents.... – XXX – 2015-05-21T18:20:43.613

1Have you checked wether that option was already set by default on ubuntu? Either in /.vimrc or /etc/vimrc? – ap0 – 2015-05-21T18:24:53.160

Good point. The Ubuntu installation is my work computer: I will check it when I get there tomorrow. Thank you for your help. – XXX – 2015-05-21T18:26:49.673

1It also depends on the terminal database. Vim might automatically detect 256 colors on your Ubuntu; :set t_Co? will tell. – Ingo Karkat – 2015-05-21T18:51:20.237