Pan Ruochen
Pan Ruochen

Reputation: 2070

How vim resolve color names in 256-color term?

For example,

ctermfg=DarkBlue

How vim decides the rgb value for the color name DarkBlue? It was said that it was described in $VIMRUNTIME/rgb.txt. But in some release of vim this file does not exist.

BTW, how vim decides the rgb value for a numeric color, such as

ctermfg=0

Upvotes: 0

Views: 922

Answers (2)

spro
spro

Reputation: 1593

The numeric colors are ANSI escape codes based on xterm's 256 color map, seen here: https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg

There used to be only 8 colors (0 to 7): Black, Red, Green, Yellow, Blue, Magenta, Cyan, and White. The other 248 are defined as following:

0x08-0x0F:  high intensity colors
0x10-0xE7:  6 × 6 × 6 = 216 colors: 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
0xE8-0xFF:  grayscale from black to white in 24 steps

Information from https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

Upvotes: 1

romainl
romainl

Reputation: 196606

Vim doesn't decide anything about those colors.

It just tells the terminal emulator to use DarkBlue or 0, without caring about the actual RGB values at all.

Upvotes: 0

Related Questions