Monday, November 4, 2013

Re: 't_Co' is always set to 256 if 'nocompatible' is set

Sorry for reposting this message, I accidently hit the post button when
I wasn't finished yet:

Hey,

first of all, thanks for your detailed and very helpful post :)

On Monday, November 4, 2013 2:14:24 AM UTC+1, Tony Mechelynck wrote:
> 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).

Hmm, are you sure about this? At least on my system the default colorscheme
uses more than 16 colors if t_Co is set high enough:

:colorscheme
default
:set t_Co?
t_Co=256
:highlight
SpecialKey xxx term=bold ctermfg=81 guifg=Cyan
Directory xxx term=bold ctermfg=159 guifg=Cyan
Visual xxx term=reverse ctermbg=242 guibg=DarkGrey
(only a few examples)

The funny thing is, that if TERM is 'xterm-16color' then all of these
"higher" color definitions are actually shown just as normal text (without
color), which for example breaks visual mode.
If on the other side TERM is just 'xterm' Vim can display 256 colors.
Really weird.

> 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).

Like stated above, the default colorscheme also does this.

> 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.

Well, for me the default colorscheme is totally broken if I set TERM to
'xterm-16color', so I wouldn't say that my "fears are unfounded" :)

> 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

Thanks, I will try that. This seems to be the best solution for now.

Regards,
Dustin

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment