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?
Asked
Active
Viewed 1,102 times
4

josemota
- 974
- 1
- 8
- 27
-
1Look [here](http://stackoverflow.com/questions/5375240/a-more-useful-statusline-in-vim/5380230#5380230) for an example – Tassos Dec 05 '11 at 13:20
1 Answers
5
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!

Prince Goulash
- 15,295
- 2
- 46
- 47
-
by any change did you manage to find a way of knowing the colors Solarized or any other scheme is using, so I could its default fg and bg colors in an automated way? – josemota Dec 11 '11 at 18:15
-
It probably belongs in a new question, but I have added my method for finding the current fg/bg colours. Hope it helps. – Prince Goulash Dec 12 '11 at 08:27