vimstatusline

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?


Solution

  • 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#