jviotti
jviotti

Reputation: 18909

Vim: Using custom highlight groups in statusline

When customising my vim statusline, I'm able to use the following syntax to make use of the highlight group User1:

set statusline+=%1*

Let's say I have some custom highlights like:

highlight StatusLineStyle ctermbg=34 ctermfg=15 guibg=#00af00 guifg=#ffffff

How can I make use of those custom syntax colourings in my statusline?

Upvotes: 1

Views: 2049

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172520

Similar to the %N*, there's %#HLname# for custom highlight group names. Actually, it's documented right above that (at :help 'statusline'). So, for your example, use

:set statusline+=%#StatusLineStyle#

Alternatively, you could use the User1..9 styles, and link your highlight group to it:

:highlight link User1 StatusLineStyle

Upvotes: 3

romainl
romainl

Reputation: 196476

It's explained in :help 'statusline', just above the part on %1*:

# - Set highlight group. The name must follow and then a # again.
    Thus use %#HLname# for highlight group HLname. The same
    highlighting is used, also for the statusline of non-current
    windows.

So…

set statusline+=%#StatusLineStyle#%f#

Upvotes: 1

Related Questions