我想要做的事情如下所示:
"define our language struct variables with their default syntax color values
let s:procedural_fg = "Red"
let s:declarative_fg = "Blue"
let s:string_fg = "DarkGray"
...
"Now the actual highlighting directives based on the groups defined elsewhere
hi cyLoops guifg=s:procedural_fg
hi cyConstants guifg=s:declarative_fg
hi cyString guifg=s:string_fg但是VIM不允许我以这种方式设置guifg值(“错误:无法分配颜色s:procedural_fg”...对于每个变量名依此类推)。我想以这种方式定义语法突出显示,以便可以通过更改局部变量值,然后刷新缓冲区(或任何需要应用新颜色值的方法)来动态更改它。
这可以在VIM语法脚本中完成吗?如果是这样的话,是怎么做的?
我已经尝试了几种变体:
"define our language struct variables with their default syntax color values
let s:procedural_fg = Red
let s:declarative_fg = Blue
let s:string_fg = DarkGray
...
"Now the actual highlighting directives based on the groups defined elsewhere
hi cyLoops guifg=s:procedural_fg
hi cyConstants guifg=s:declarative_fg
hi cyString guifg=s:string_fg和
"define our language struct variables with their default syntax color values
let s:procedural_fg = v:Red
let s:declarative_fg = v:Blue
let s:string_fg = v:DarkGray
...
"Now the actual highlighting directives based on the groups defined elsewhere
hi cyLoops guifg=s:procedural_fg
hi cyConstants guifg=s:declarative_fg
hi cyString guifg=s:string_fg这导致错误,抱怨Red、Blue等或v:Red、v:Blue等是未定义的和/或无效的表达式。
谢谢,CCJ
发布于 2012-01-06 01:33:43
使用:exec,就像eval对于Perl或bash shell一样:
:exec 'hi cyLoops guifg=' . s:procedural_fghttps://stackoverflow.com/questions/8745585
复制相似问题