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.

  • 1
    It seems that vim-full was replaced by vim-gnome according to superuser.com/questions/149027/…. I also tried to install vim-gtk, but that did not help. – Sterling Feb 18 '15 at 3: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 4:01
  • 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 4:23
  • 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 8:55
  • 1
    @Sterling, I stand corrected, you're right. – Rmano Feb 18 '15 at 15:29
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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