Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
3  
"an error" is not very useful. Please state the exact error message you're getting. –  Mat Oct 27 '12 at 13:44
    
E421: Color name or number not recognized: ctermfg=s:base00 –  Kitaro Oct 27 '12 at 14:40
add comment

1 Answer 1

up vote 2 down vote accepted

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).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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