Unexpected cterm-colors

14 views
Skip to first unread message

Enan Ajmain

unread,
Apr 21, 2023, 6:57:06 AM4/21/23
to vim_use
I know colorschemes have been a source of issue for ignorant vimmers
for a long time. This is not an attempt to restart old conversation. I
am looking for pointers where to research this question.

From ':h cterm-colors':

NR-16 NR-8 COLOR NAME
0 0 Black
1 4 DarkBlue
2 2 DarkGreen
3 6 DarkCyan
4 1 DarkRed
5 5 DarkMagenta
6 3 Brown, DarkYellow
7 7 LightGray, LightGrey, Gray, Grey
8 0* DarkGray, DarkGrey
9 4* Blue, LightBlue
10 2* Green, LightGreen
11 6* Cyan, LightCyan
12 1* Red, LightRed
13 5* Magenta, LightMagenta
14 3* Yellow, LightYellow
15 7* White

The color codes for NR-16 don't make sense to me. Take Yellow, for example.
Why is it numbered 14? 16-bit terminals use 11 for bright yellow [1]. Why is
it different inside Vim?

For extra info: I used guicolors before. That's why I hadn't noticed this.

[1]: https://jeffkreeftmeijer.com/vim-16-color/


--
Enan

Christian Brabandt

unread,
Apr 21, 2023, 7:25:50 AM4/21/23
to vim...@googlegroups.com
It's not like Vim chose a different color, it's more like this documents
"standard" behaviour back in the time.

I believe this is just documenting the CGA standard. You can find it
e.g. here: https://en.wikipedia.org/wiki/Color_Graphics_Adapter and
check the Full CGA 16-color palette chart.

Best,
Christian
--
Die Zahl derer, die durch zu viele Informationen nicht mehr informiert
sind, wächst.
-- Rudolf Augstein

Enan Ajmain

unread,
Apr 22, 2023, 1:37:47 AM4/22/23
to Christian Brabandt, vim...@googlegroups.com
On Fri, 21 Apr 2023 13:25:42 +0200
Christian Brabandt <cbl...@256bit.org> wrote:
> On Fr, 21 Apr 2023, Enan Ajmain wrote:
> > [...]
> > The color codes for NR-16 don't make sense to me. Take Yellow, for example.
> > Why is it numbered 14? 16-bit terminals use 11 for bright yellow [1]. Why is
> > it different inside Vim?
>
> It's not like Vim chose a different color, it's more like this documents
> "standard" behaviour back in the time.
>
> I believe this is just documenting the CGA standard. You can find it
> e.g. here: https://en.wikipedia.org/wiki/Color_Graphics_Adapter and
> check the Full CGA 16-color palette chart.

Thanks for the info. I haven't understood why CGA 16-color palette is
different than terminal 16-color palette, but I will try and find out.

Another thing: what does NR-16 and NR-8 mean? I can't find these terms
on the internet. Every hit I get is in the context of Vim.

P.S. In the thread-top email, I mistakenly wrote "16-bit terminals"
instead of "16-color terminals." I hope that didn't cause confusion.

--
Enan

Romain Lafourcade

unread,
Apr 22, 2023, 2:54:44 AM4/22/23
to vim_use
> Another thing: what does NR-16 and NR-8 mean? I can't find these terms
> on the internet. Every hit I get is in the context of Vim.

They are explained a few lines below the block you cited.

Vim is not very good at detecting terminal features in general and it is pretty bad with colors so you should probably notch down your expectations regarding syntax highlighting.

Basically, if you stop at that table you would _think_ that 1 and DarkBlue should be interchangeable when &t_Co == 16, while they are very different when testing it in your terminal emulator.
There is a very short explanation a few paragraphs below the table:

> Note that for 16 color ansi style terminals (including xterms), the
> numbers in the NR-8 column is used.  Here '*' means 'add 8' so that
> Blue is 12, DarkGray is 8 etc.

That explanation is frustrating, though, because most terminal emulators in use nowadays fall into that broad "color ansi style terminals (including xterms)" category… which is still treated ("brushed off", even) as a special case.
This makes the table and most of the text below it unnecessarily confusing.

IMO, that specific part of the documentation should document the behavior experienced by most users rather than the antiquated heuristics that are used under the hood.

Enan Ajmain

unread,
Apr 22, 2023, 12:27:25 PM4/22/23
to vim...@googlegroups.com
On Fri, 21 Apr 2023 23:54:44 -0700 (PDT)
Romain Lafourcade <romainla...@gmail.com> wrote:
> > Another thing: what does NR-16 and NR-8 mean? I can't find these terms
> > on the internet. Every hit I get is in the context of Vim.
>
> They are explained a few lines below the block you cited.
>
> Vim is not very good at detecting terminal features in general and it is
> pretty bad with colors so you should probably notch down your expectations
> regarding syntax highlighting.
>
> Basically, if you stop at that table you would _think_ that 1 and DarkBlue
> should be interchangeable when &t_Co == 16, while they are very different
> when testing it in your terminal emulator.
> There is a very short explanation a few paragraphs below the table:
>
> > Note that for 16 color ansi style terminals (including xterms), the
> > numbers in the NR-8 column is used. Here '*' means 'add 8' so that
> > Blue is 12, DarkGray is 8 etc.
>
> That explanation is frustrating, though, because most terminal emulators in
> use nowadays fall into that broad "color ansi style terminals (including
> xterms)" category... which is still treated ("brushed off", even) as a
> special case.
> This makes the table and most of the text below it unnecessarily confusing.

Thanks for the explanation. It's clear to me now, or close enough.

For completion's sake: I dug into this issue because I saw cterm-colors
were different in my Windows terminals (both xterm-like Windows Terminal
_and_ old Conhost terminal) than in Ubuntu suckless/Gnome terminals
(both xterm-like). I guess Vim doesn't consider Windows terminals as
xterm-like.

I recently switched from using 256-colors to 16-colors on my Ubuntu
machine (because Vim colors would then correspond to the terminal
emulator colors: I'll need to change only terminal emulator colors).
When I pulled my config changes to my Windows computer, the colors were
different.

--
Enan
Reply all
Reply to author
Forward
0 new messages