将文本颜色设置为状态行中的字符串

问题描述 投票:0回答:1

我将序言说我使用航空公司,plytophogy/vim-virtualenv插件和gruvbox作为航空公司主题。

我试图将状态行中某些字符串的颜色更改为橙​​色。在我的情况下,这是指示我当前工作环境的“@my_env”字符串:enter image description here

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

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

基于这个question,我试图将我的.vimrc行更改为

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

这似乎突出了“@my_env”以后的状态线:Before

似乎使用%#any_color#甚至%##by本身产生相同的效果。

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

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

编辑:

here回答了这个问题

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

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

这就是它的样子

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

,其中Special是一个随机突出组

vim
1个回答
0
投票

: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之后停止着色。

© www.soinside.com 2019 - 2024. All rights reserved.