what is the difference between cterm color and gui color?

I didn't see any differences between them at all

ctermxx is used by console version of Vim (when set notermguicolors). guixx is used in GVim, or in console if set termguicolors, and the console is capable of TrueColor, obviously. Hence you must test it in different programs to see the difference.

Also, some colors could be the same or very close to each other, e.g. "blue" is "blue" both in GUI and console.

Can any one give me an illustrative example of how to use them?

hi Normal guifg=#1034a6 guibg=#f5f5dc ctermfg=19 ctermbg=230

Should look very similar but still a little different in GUI and console

For symbolic colors names see :h cterm-colors and $VIMRUNTIME/rgb.txt. The cheat sheet of 256 color indexes for console is available here.


The separate pairs allow you to specify different colors for a terminal (which may limit you to a fixed-sized palette of colors, usually 16 or 256) and a GUI (which typically provides a much larger palette or even direct access to any color your display can handle).

For example, if you start a session in your terminal using vi some_file.txt, then ctermfg and ctermbg would be used. If you start an instance of gvim (which opens its own window independent of your terminal emulator), then guifg and guibg are used instead.