Reputation: 984
I have successfully set my linestatus
configuration. However, the only thing missing is some background color, either for the whole line as well as in particular elements. How can I set them?
Upvotes: 4
Views: 1180
Reputation: 15735
You need to define the colours as new highlighting groups User1, User2, etc:
hi User1 ctermbg=blue ctermfg=white guibg=blue guifg=white
hi User2 ctermbg=black ctermfg=red guibg=black guifg=red
Then you can specify them in the statusline string like so:
set statusline=
set statusline+=%1* " Switch to colour User1
set statusline+=%F
set statusline+=%* " Switch to default colour
set statusline+=%P
set statusline+=%2* " Switch to colour User2
set statusline+=%c
EDIT
This probably belongs in a new question, but here is the method I use to find the existing colouring for a highlight group. In this example I set the Folded
syntax to be the same as the current Normal
syntax. I do this by directing the output of hi Normal
to a variable, and then extracting the various information from it.
redir => hinorm
sil exe 'hi Normal'
redir END
if hinorm =~ 'cleared'
sil exe 'hi clear Folded'
else
let guibg = matchstr(strtrans(hinorm),'guibg=[#a-zA-Z0-9]*')
let guifg = matchstr(strtrans(hinorm),'guifg=[#a-zA-Z0-9]*')
sil exe 'hi Folded ' . guibg
sil exe 'hi Folded ' . guifg
endif
If there is a cleaner method, let me know!
Upvotes: 5