加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim – 在状态行中包含颜色字符串

发布时间:2020-12-15 20:55:24 所属栏目:安全 来源:网络整理
导读:我有一些功能定义为 function! myfunc() let s = 'hello world' return sendfunction 我可以在状态行中包含这个作为statusline =%{myfunc()},它很好地打
我有一些功能定义为

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”,而我希望你好根据mycolor1着色并根据mycolor2进行世界着色.

我该怎么做呢?

解决方法

我认为这个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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读