【问题标题】:Set text color to a string in statusline将文本颜色设置为状态行中的字符串
【发布时间】:2019-04-27 07:38:25
【问题描述】:

我先说我使用 Airline、plytophogy/vim-virtualenv 插件和 gruvbox 作为 Airline 主题。

我正在尝试将状态行中某些字符串的颜色更改为橙​​色。 在我的情况下,这是说明我当前工作环境的“@my_env”字符串:

目前,我的 .vimrc 中负责此文本的行是:

let g:airline_section_c='%t @%{virtualenv#statusline()}'

基于此question,我尝试将我的 .vimrc 行更改为

let g:airline_section_c='%t %#orange#@%{virtualenv#statusline()}'

似乎从“@my_env”开始突出显示状态行:

似乎单独使用%#any_color# 甚至%## 会产生相同的效果。

我已经阅读了所有:h 'statusline',但似乎没有找到合适的解决方案。

所以我的问题是:有没有办法为状态行中的字符串设置颜色?

编辑

问题已回答here

似乎没有办法在不改变整个格式组(包括背景)的情况下改变屏幕的文本颜色。

%#airline_c# 附加到字符串的末尾以添加修复了突出显示的问题:

这就是它的样子

let g:airline_section_c='%t %#Special#%{virtualenv#statusline()}%#airline_c#'

其中Special 是一个随机高亮组

【问题讨论】:

    标签: vim


    【解决方案1】:

    :help statusline的格式化说明中,可以找到:

       * -   Set highlight group to User{N}, where {N} is taken from the                                                                                                                                          
              minwid field, e.g. %1*.  Restore normal highlight with %* or %0*.                                                                                                                                    
              The difference between User{N} and StatusLine  will be applied                                                                                                                                       
              to StatusLineNC for the statusline of non-current windows.                                                                                                                                           
              The number N must be between 1 and 9.  See hl-User1..9 
    

    所以如果你改变:

    let g:airline_section_c='%t %#orange#@%{virtualenv#statusline()}'
    

    进入:

    let g:airline_section_c='%t %#orange#@%{virtualenv#statusline()}%*'
    

    它应该在 virtualenv 之后停止着色。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-21
      • 2014-08-31
      • 2020-02-01
      相关资源
      最近更新 更多