On 04/11/13 00:55, [email protected] wrote:
When you set Vim to be not-compatible, it checks the returned info from
xterm to figure out the number of supported colors.  So your xterm
probably actually supports 256 colors, right?

Yes, the xterm I'm using supports 256 colors.  I actually switched my
operating system recently, so thats probably the reason I didn't experienced
this before (can't remember how many colors xterm supported there).

I set TERM to 'xterm-16color' because I want all programs (and especially Vim)
to use only 16 colors.

Anyway, it seems like I have to hardcode 't_Co' in my vimrc which is quite ugly.
Or can I somehow force Vim to use the appropriate terminfo entry instead?

The colours Vim uses depend on its colorscheme. If you don't set any, you get the default colours, which use only the 16 color codes compatible with any color depth (or maybe even 16 foreground and 8 background colours; there are still some consoles in use today which don't go higher than that). Most programs displaying on the console do the same; many even use only black & white, possibly with underline if available (on some consoles, underlining becomes blue color).

To display more than 16 colours on a console in Vim, you need a colorscheme which defines highlights with ctermfg= and/or ctermbg= values higher than 15, and those who do may assume that the user knows hat he's doing, and not check that t_Co is high enough (they could test if they wanted to).

So I think your fears are unfounded. If you don't set any colorscheme, or if you choose one that supports 16-color consoles, Vim won't use more. Of course, gvim uses all 2^24 (or 16777216) colors available on modern color graphic displays.

However, even so, you can force Vim to ignore the t_Co value returned by the xterm, as follows (untested):

        :autocmd TermResponse * set t_Co=16
or even
        :au TermResponse * if &term ~= '^xterm-\=16'
                               \ | set t_Co=16 | endif

This will be triggered only when the response comes back from the xterm, thus not on any other terminals. The condition in the if clause means: if 'term' starts with "xterm16" or "xterm-16". The single quotes are essential in order to pass the backslash as-is to the regex engine.

I'm writing this second example on two lines with \ line continuation for legibility, but note that continuation lines are not supported in 'compatible' mode. If this is a concern, you may prefer to write everything on one long line.


Best regards,
Tony.
--
More are taken in by hope than by cunning.
                -- Vauvenargues

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to