When I use the following command to set the color of my vim,
:highlight Error ctermfg=#00afff
it prompts E421: Color name or number not recognized: ctermfg=#00afff
ctermfg
and ctermbg
use indices into the limited color palettes (8 / 16 / 88 or 256 colors) of terminals and do not support the full 24-bit RGB values.
I think you're looking for the 'termguicolors'
option, which makes Vim apply the GUI color attributes to capable terminals. Colors (by name or #RGB) are specified via guifg
/ guibg
; only cterm
is used for text attributes.
It's because :h highlight-ctermfg
says:
ctermbg={color-nr} *highlight-ctermbg*
The {color-nr} argument is a color number. Its range is zero to
(not including) the number of tui-colors available.
The actual color with this number depends on the type of terminal
and its settings.
[...]
The following (case-insensitive) names are recognized:
*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 command is not supposed to support hex color mode.