我有一些定义为
的功能function! myfunc()
let s = 'hello world'
return s
endfunction
我可以将其作为statusline=%{myfunc()}
包含在我的状态行中,它可以很好地打印“hello world”。我也可以将其设为statusline=%#mycolor#%{myfunc()}
,其中mycolor
是我定义的颜色。
现在我想分别为每个单词着色,所以我将我的功能重新定义为
function! myfunc()
let s = '%#mycolor1#hello %#mycolor2#world'
return s
endfunction
但是,当我在状态行中设置它时,输出只是文字字符串"%#mycolor1#hello %#mycolor2#world"
,而我希望hello
根据mycolor1
和{{1}进行着色根据{{1}}着色。
我该怎么做?
答案 0 :(得分:2)
我认为这个vim实用程序可以部分回答你的问题:
http://www.vim.org/scripts/script.php?script_id=3383
所以看起来你的'myfunc'功能不能改变颜色。但是您可以通过使用exec命令分配状态行来获得颜色更改,例如:
:let sl_statement = 'set statusline=%#' . color1highlight .
\ '#%{myfunc1()}%#' . color2hl . '#%{myfunc2()}'
:exec sl_statement