no color in vim

1,526 views
Skip to first unread message

Yakun Sun

unread,
Mar 15, 2011, 12:15:17 AM3/15/11
to mintty
I used msys.bat to start mintty. It is great, except for one thing --
no color when I started vim. I have my .vimrc configured and color
scheme set, but no color when I am editing any file with syntax. What
did I miss?

Chris Sutcliffe

unread,
Mar 15, 2011, 12:40:22 AM3/15/11
to mintty-...@googlegroups.com

It's not a mintty issue, it's due to the fact that msys vim doesn't
support colours (i.e. there is no terminfo support).

Chris

Yakun Sun

unread,
Mar 15, 2011, 12:53:15 AM3/15/11
to mintty
Thanks for the insight. However, if I start rxvt using msys.bat (not
directly invoke rxvt in mingw's cmd terminal), vim has color. Does
msys.bat do some magic behind?

Thanks,
-Yakun

Chris Sutcliffe

unread,
Mar 15, 2011, 1:55:55 AM3/15/11
to mintty-...@googlegroups.com
On 15/03/2011 12:53 AM, Yakun Sun wrote:
> Thanks for the insight. However, if I start rxvt using msys.bat (not
> directly invoke rxvt in mingw's cmd terminal), vim has color. Does
> msys.bat do some magic behind?

Hrm, looks I spoke to soon, there is limited terminal support in msys
vim. In mintty set Options > Terminal > type to 'msys' (without the
quotes), restart mintty, and you will have a similar experience to
rxvt. This is based on the TERM variable being set to 'msys' when
running msys.bat --rxvt.

Chris

Yakun Sun

unread,
Mar 15, 2011, 1:59:19 AM3/15/11
to mintty
It works! So the term type has to be msys. Interesting to know.

Thanks,
-Yakun

Andy Koppe

unread,
Mar 16, 2011, 8:55:16 AM3/16/11
to mintty-...@googlegroups.com
On 15 March 2011 05:59, Yakun Sun wrote:

> On Mar 14, 10:55 pm, Chris Sutcliffe wrote:
>> On 15/03/2011 12:53 AM, Yakun Sun wrote:
>>
>> > if I start rxvt using msys.bat (not
>> > directly invoke rxvt in mingw's cmd terminal), vim has color. Does
>> > msys.bat do some magic behind?
>>
>> Hrm, looks I spoke to soon, there is limited terminal support in msys
>> vim. In mintty set Options > Terminal > type to 'msys' (without the
>> quotes), restart mintty, and you will have a similar experience to
>> rxvt. This is based on the TERM variable being set to 'msys' when
>> running msys.bat --rxvt.
> It works! So the term type has to be msys. Interesting to know.

I don't think that's the right fix. TERM=msys is intended for the MSYS
console, which isn't all that xterm-compatible, as mintty tries to be.
Hence you're likely to find other problems due to this.

The underlying problem here is that MSYS still uses the prehistoric
termcap library instead of terminfo. Termcap has the rather
unfortunate restriction that entries in its /etc/termcap database are
limited to 1023 characters. The MSYS console's somewhat limited
capabilities fit into that, but xterm's do not. Therefore some xterm
capabilities have been left out of /etc/termcap, including those for
changing colour.

However, instead of falsifying TERM, you can fill in the missing
capabilities in .vimrc. For example, to enable 8-colour mode:

let &t_Co=8
let &t_AF="\e[3%dm"
let &t_AB="\e[4%dm"

Or to enable the full 256 colours:

let &t_Co=256
let &t_AF="\e[38;5;%dm"
let &t_AB="\e[48;5;%dm"

If you're using mintty's default white-on-black colours, I'd also
recommend adding the following to get vim to adapt its use of colours
to the dark background:

set bg=dark

Regards,
Andy


ps: Of course the real fix here is to use latest Cygwin instead of
MSYS (née Cygwin 1.3), which among countless other advances uses
terminfo rather than termcap.

Chris Sutcliffe

unread,
Mar 17, 2011, 8:45:21 AM3/17/11
to mintty-...@googlegroups.com
Hi Andy,

> let&t_AB="\e[4%dm"


>
> Or to enable the full 256 colours:
>
> let&t_Co=256
> let&t_AF="\e[38;5;%dm"

> let&t_AB="\e[48;5;%dm"


>
> If you're using mintty's default white-on-black colours, I'd also
> recommend adding the following to get vim to adapt its use of colours
> to the dark background:
>
> set bg=dark

This is a great tip! Mind if I re-post to the msys mailing list and add
it to the MinGW wiki?

Thank you,

Chris

Andy Koppe

unread,
Mar 18, 2011, 2:07:13 AM3/18/11
to mintty-...@googlegroups.com

Of course not, that would be good. Better tone down the 'prehistoric'
bit though. ;)

Thanks,
Andy

Andy Koppe

unread,
Mar 19, 2011, 2:46:46 AM3/19/11
to mintty-...@googlegroups.com
On 18 March 2011 06:07, Andy Koppe wrote:
>>> However, instead of falsifying TERM, you can fill in the missing
>>> capabilities in .vimrc. For example, to enable 8-colour mode:
>>>
>>> let&t_Co=8
>>> let&t_AF="\e[3%dm"
>>> let&t_AB="\e[4%dm"
>>>
>>> Or to enable the full 256 colours:
>>>
>>> let&t_Co=256
>>> let&t_AF="\e[38;5;%dm"
>>> let&t_AB="\e[48;5;%dm"
>>>
>>> If you're using mintty's default white-on-black colours, I'd also
>>> recommend adding the following to get vim to adapt its use of colours
>>> to the dark background:
>>>
>>> set bg=dark
>>
>> This is a great tip!  Mind if I re-post to the msys mailing list and add it
>> to the MinGW wiki?
>
> Of course not, that would be good. Better tone down the 'prehistoric'
> bit though. ;)

Or, as the (new?) MSYS vim maintainer, you could include it in the
global vim config at /share/vim/vimrc, guarded by

if &term=="xterm"
...
endif

Regards,
Andy

Chris Sutcliffe

unread,
Mar 19, 2011, 5:26:29 PM3/19/11
to mintty-...@googlegroups.com
On 19/03/2011 2:46 AM, Andy Koppe wrote:
> Or, as the (new?) MSYS vim maintainer, you could include it in the
> global vim config at /share/vim/vimrc, guarded by
>
> if&term=="xterm"
> ...
> endif

Done, thank you again for the tip! ;)

Chris

Andy Koppe

unread,
Mar 23, 2011, 3:23:32 AM3/23/11
to mintty-...@googlegroups.com
On 19 March 2011 21:26, Chris Sutcliffe wrote:
> On 19/03/2011 2:46 AM, Andy Koppe wrote:
>>
>> Or, as the (new?) MSYS vim maintainer, you could include it in the
>> global vim config at /share/vim/vimrc, guarded by
>>
>> if&term=="xterm"
>> ...
>> endif
>
> Done

Great.

I thought of a small improvement to that: check whether &term starts
with 'xterm' rather than whether it's equal to 'xterm', in case the
user has set it to 'xterm-256color' or some such.

if &term =~ "^xterm"
...
endif

Cheers,
Andy

Renato Silva

unread,
Jun 20, 2013, 6:58:54 PM6/20/13
to mintty-...@googlegroups.com
Which is exactly my case, and would avoid my little odyssey. So that would be appreciated, Chris. Thanks Andy for the tip.
Reply all
Reply to author
Forward
0 new messages