1

When tweaking color themes, one thing I really miss is a highlighting that would color the color strings with the corresponding color.

Maybe this sounds confusing? An example: here is a fragment of a Vim theme:

hi Constant    ctermfg=Magenta      guifg=Magenta
hi Special     ctermfg=Red          guifg=Red
hi Identifier  ctermfg=Cyan         guifg=Green

I would like to have a syntax highlight that would color Magenta in magenta, Red in red, and so on, similar to what happens with color codes for dircolors file:

dircolors file displayed in Vim editor

01;34 is the color code for blue, thus Vim displays it in blue, 01;36 is cyan, etc.

I searched into the syntax directory for files with "color" in their name,

$ find . -iname '*color*'
./colortest.vim
./dircolors.vim
./syncolor.vim

but none of these do the job for the color strings.

Am I missing some resource or do I have to create my own syntax file?

  • This may not be what you want, but I find :hi helpful. – DK Bose Aug 19 '20 at 3:51
  • Have a look at github.com/gu-fan/colorv.vim. It has commands to preview colors in line – Steve Aug 19 '20 at 4:28
3

There are a number of plugins that do this for colour names, hex colours, and RGB colours:

  • Colorizer by Christian Brabandt, (who appears to be modestly refraining from answering this question with a link to his own plugin),
  • Coloresque by Konstantin,
  • vim-css-color by Aristotle Pagaltzis,
  • vim-css-color (a different one) by Max Vasiliev

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.