On 2020-09-26, Nikolay Belikov wrote:
> Hello all,
> 
> I've stumbled upon strange behavior in Vim 8.2 regarding `t_Co`
> variable.  This might be a bug, but more probably is just a case of
> PEBCAK, so maybe someone could point me towards what I'm doing wrong.
> 
> Background: I want to use my terminal emulator (which is plain old
> `xterm`) color scheme across all TUI programs, including Vim.  I've
> added `set t_Co=16` to my `.vim/vimrc` file and expected Vim to limit
> itself to 16 base colors (at least this is what all sources on Internet
> say to do, which I managed to find).  However, it appears that Vim does
> not honor my will and resets `t_Co` to 256, unless I manually type `:set
> t_Co=16` in command-line mode.
> 
> I reduced my `vimrc` to the bare minimum needed to reproduce the
> problem, and now it contains a single line:
> 
>     set t_Co=16
> 
> At this point I'm unsure what to do and ask for your assistance.  I
> attach a log captured by running `vim -V100vim.log` as well as version
> info (`vim --version >vim.version`), and I'm willing to provide any
> other info that may be of help.

Vim may change t_Co when it receives a terminal's termresponse.
I noticed the same strange behavior some years ago with Vim setting
t_Co to 256 in an xterm.  See

    :help v:termresponse
    :help t_RV
    :helpgrep termresponse

You can test this by adding this to your vimrc,

    set t_RV=

and seeing if t_Co is still mysteriously reset to 256.

You may be able to reset t_Co to 16 with this in your vimrc:

    autocmd TermResponse * set t_Co=16

I say "may" because I've found that not everything works as I would
expect it to in the environment of a TermResponse autocommand.

See

    :help TermResponse

Regards,
Gary

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20200929150547.GA31849%40phoenix.

Reply via email to