Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to use the desert color scheme with VIM 7.0 on CentOS 5.6 x64 located here:

http://hans.fugal.net/vim/colors/desert.vim

I've downloaded the file and saved it in my ~/.vim/colors directory. I then tell VIM to use the colour scheme by issuing:

:colors desert

It's supposed to look like this:

enter image description here

However I get this:

enter image description here

I'm logging onto this server just as a regular user (not root or sudo) using PuTTY 0.60 and have set the following options under Window -> Colours:

Allow terminal to specify ANSI colours - checked
Allow terminal to use 256-colour mode - checked
Bolded test is a different colour - checked
Attempt to use logical palettes - unchecked
Use system colours - unchecked

If I sudo or logon as root and try the same I don't get any colours at all other than white text on a black background.

Are these schemes mostly aimed at gVIM and is PuTTY just not able to display these colours?

I've google'd around a bit and bumped into articles such as this one but they don't appear to work.

share|improve this question

1 Answer

up vote 8 down vote accepted

By default, PuTTY presents itself as xterm. The terminfo database, used by various programs to determine the terminal capabilities, says xterm supports eight colors only:

$ infocmp -1L xterm | grep max_colors

This means that even if your version of Xterm does support 256-color mode, programs won't know about it.

  • The easiest fix is to set your $TERM environment variable to xterm-256color.

    (In your ~/.profile, you could use: [ "$TERM" = "xterm" ] && TERM="xterm-256color")

  • You can tell PuTTY to always identify itself as xterm-256color, via Configuration → Connection → Data → Terminal-type string.

    Note: If you use #1 or #2, and you connect to a server which doesn't have the apropriate terminfo entry, all TUI programs will break.

  • You can also set the 't_Co' option in vim to 256 to override the terminfo value.

    if &term == "xterm"
        set t_Co=256
    endif
    
  • Or you could edit the terminfo database.

    $ infocmp -L -1 xterm | sed -r 's/(max_colors)#.+/\1#256/' > /tmp/xterm
    $ tic /tmp/xterm
    

    The updated entry will be kept in ~/.terminfo.

share|improve this answer
Excellent answer. It's better, but I have feeling 256 colours isn't enough to render these pastel shades. Any idea why I don't get any colours at all when logged in as root? – Kev Sep 14 '11 at 14:44
@Kev: 1) 256-color mode is the best you can get on a VT100-compatible terminal emulator. (I heard KDE Konsole having true-color support, but it's very much nonstandard.) 2) When you log in as root, you get a separate home directory, and a separate ~/.vim/colors as well. – grawity Sep 14 '11 at 14:47
I have the color scheme in ~/.vim/colors but it seems to be ignored. I know vim can see it because if I do :colors for a scheme that isn't there it reports E185: Cannot find color scheme blahblahblah whereas no error when I do :colors desert. – Kev Sep 14 '11 at 14:50
@Kev: Hm. Do you have syntax highlighting enabled? (:syn on) How about $TERM - is it set to a sane value? – grawity Sep 14 '11 at 14:52
Hmm...colours and syntax highlighting work with vim launched as root but not vi. I can live with that I guess. – Kev Sep 14 '11 at 15:18
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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