4

I've been experimenting with different colorschemes in vim lately. My problem is that the colors used by the schemes only use the 16 colors in my Profile Preferences, even though my terminal supports a 256 palette.

When I put in tput colors it returns 256. I have my TERM variable set to xterm-256color. I have set t_Co=256 in my .vimrc. On this question How do I enable full-color support in Vim? there is a python script that will display your available colors. I see the full range of colors that the person shows in their screenshot.

Yet even after all of this, the colors in my vim are only the ones listed in Profile Preferences. I know this because I can change the colors and see the corresponding "darkgreen" (or whichever color I am selecting) font change to whatever color I changed it to.

So whenever I specify a colorscheme, it has the general look and appearance of it, but it's not exactly correct. I would like to have my color schemes look how they do in the screenshots I see of them.

Is it possible to do this or will I always have to manually change the 16 colors in my Profile Preferences to perfectly match a colorscheme?

I'm using the vim-gnome package in Ubuntu 14.04 with gnome-terminal. Thanks for any help.

Sterling
  • 215
  • What does :set term and :set t_Co return? – muru Feb 18 '15 at 03:47
  • term=xterm-256color – Sterling Feb 18 '15 at 03:47
  • Try install vim-full – Panther Feb 18 '15 at 03:54
  • 1
    It seems that vim-full was replaced by vim-gnome according to http://superuser.com/questions/149027/what-ever-happened-to-vim-full-package-that-used-to-be-available-in-ubuntu. I also tried to install vim-gtk, but that did not help. – Sterling Feb 18 '15 at 03:58
  • 1
    vim-gnome is about as full as it gets now. How about another terminal? xterm? xterm's sibling whose name I don't recall? Or gvim directly, without a terminal? – muru Feb 18 '15 at 04:01
  • I tried xterm, but the result is the same. I checked :set term, tput colors, etc. and it's all the same. – Sterling Feb 18 '15 at 04:03
  • gvim works! It has the correct colors. So what's different about gvim and using vim in the terminal? – Sterling Feb 18 '15 at 04:04
  • @Sterling On vim in a terminal, see if there's any difference between :set t_Co=256 and :set t_Co=8 – muru Feb 18 '15 at 04:13
  • Yes, there is a difference. – Sterling Feb 18 '15 at 04:15
  • 1
    Then your vim is using 256 colours, it's just that the colour profiles of your terminal is different from that of vim-gnome, so the overall colours are different. I don't think any of the colour profiles of GNOME terminal come close to that of vim-gnome, so you'll probably have to manually adjust. – muru Feb 18 '15 at 04:23
  • So the only way to have the actual colorscheme is through using gvim? That's kind of a downer. I guess it's not too bad though if you toggle the toolbar away. – Sterling Feb 18 '15 at 04:48
  • 1
    I have the correct colors in gnome-terminal and terminator without the need of setting any TERM variables, just the :set t_Co=256 in .vimrc. – Rmano Feb 18 '15 at 08:55
  • Mine has similar colors, but not the same. It is using whatever values are in those 16 colors in the palette when I go to Edit->Profile Preferences->Colors. – Sterling Feb 18 '15 at 14:57
  • 1
    @Sterling, I stand corrected, you're right. – Rmano Feb 18 '15 at 15:29

1 Answers1

3

This is working in gnome-terminal + vim on Ubuntu 14.04:

Firstly, set the bash setting as the end of ~/.bashrc file like this:

if [ -n "$DISPLAY" -a "$TERM" == "xterm" ]; then
    export TERM=xterm-256color
fi

Next, set the vim setting at the end of ~/.vimrc file like this:

if $COLORTERM == 'gnome-terminal'
  set t_Co=256
endif

You will need to load a new terminal to see these have an effect. You may run the python script to test is the bash setting has taken effect and then testing vim's support, which I believe was the core issue above:

Install a 256 color vim theme by downloading the script and saving it to ~/.vim/colors/inkpot.vim and enable it with this command:

:colo inkpot

You should see a theme which when tested locally does not change when gnome-terminal's colours are changed. You can make these themes permanent by adding the command to your .vimrc file.

More information about vim colours can be found on their website.