I had to notice that this doesn't work:
let test=128
highlight Normal ctermbg=test
Is it possible to use variables in colorschemes?
I had to notice that this doesn't work:
let test=128
highlight Normal ctermbg=test
Is it possible to use variables in colorschemes?
Vimscript is evaluated exactly like the Ex commands typed in the :
command-line. There were no variables in ex
, so there's no way to specify them. When typing a command interactively, you'd probably use <C-R>=
to insert variable contents:
:sleep <C-R>=timetowait<CR>m<CR>
... but in a script, :execute
must be used. All the literal parts of the Ex command must be quoted (single or double quotes), and then concatenated with the variables:
execute 'sleep' timetowait . 'm'
execute "highlight Normal ctermbg=" . test
– romainl Sep 25 '16 at 19:05