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
Best Answer
There are two problems:
The
:highlight
command does not evaluatectermfg
values as expressions. It accepts only a literal color number, or a color name (see:help cterm-colors
). You get E421 becauses: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 whatcolors/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 uses:fg_base00
/s:bg_base00
instead ofs:base00
since the former coverguifg
vs.ctermfg
so that your group would automatically work on both GUIs and terminals).