0

I'm receiving the following error:

Color name or number not recognized: ctermbg=g:extra_whitespace_color guibg=g:extra_whitespace_color

Pointing to these lines:

let g:extra_whitespace_color = 'black'
highlight ExtraWhitespace ctermbg=g:extra_whitespace_color guibg=g:extra_whitespace_color
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=g:extra_whitespace_color guibg=g:extra_whitespace_color

when I don't use a variable, everything works but I'm unclear what I'm doing wrong.

autocmd ColorScheme * highlight ExtraWhitespace ctermbg=black guibg=black
2

Variable interpolation is not automatic in certain contexts.

Use

execute printf('highlight ExtraWhitespace ctermbg=%s guibg=%s', g:extra_whitespace_color, g:extra_whitespace_color)

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.