The solarized theme defines some base colors and assigns those to variables, as seen here.

I would like to know how I can use these color definitions in my .vimrc file. Currently, I use pathogen to load solarized and it is loaded with a simple syntax enabled and colorscheme solarized, but when I want to reference e.g. s:base00 in my .vimrc file, I get an error:

E421: Color name or number not recognized: ctermfg=s:base00
  • 3
    "an error" is not very useful. Please state the exact error message you're getting.
    – Mat
    Commented Oct 27, 2012 at 13:44
  • E421: Color name or number not recognized: ctermfg=s:base00
    – Kitaro
    Commented Oct 27, 2012 at 14:40

1 Answer 1


There are two problems:

  • The :highlight command does not evaluate ctermfg values as expressions. It accepts only a literal color number, or a color name (see :help cterm-colors). You get E421 because s:base00 is not a number, nor a valid color name.

    You could use execute 'highlight GroupName ctermfg=' . s:base00 to build an command string and execute it (this is basically what colors/solarized.vim does); however there is an additional problem.

  • Variables that start with s: are script-local variables (see :help s:var), so they are not accessible in your .vimrc (or anywhere except the script in which they are defined: colors/solarized.vim).

    The defining script “exports” the color values as a part of the highlight groups that it defines, but does not seem to export the individual cterm/gui values it uses for each Solarized color. If you want to create your own highlight group that uses these values, then you will probably have to edit it into your copy of colors/solarized.vim (though you may want to use s:fg_base00/s:bg_base00 instead of s:base00 since the former cover guifg vs. ctermfg so that your group would automatically work on both GUIs and terminals).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .