sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

StatusLineHighlight : Change statusline color depending on buffer state.

 script karma  Rating 21/8, Downloaded by 984    Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
script type
This plugin indicates the state of the buffer (modified, readonly,
unmodifiable, special non-file "scratch") / window (is preview window) by
changing the highlighting of the window's status line. It defines additional
StatusLine... / StatusLine...NC highlight groups that are customizable and by
default use different colors to differentiate the buffer states.

An example screenshot can be found at

Using different colors for the status line is trickier than it seems: Though
the 'statusline' setting supports inline expressions via %{expr}, the returned
text is taken as-is; highlight items %#hlgroup# and #* are not evaluated, only
printed as text. Evaluation does happen when one %!expr is used, but the
expression seems to be evaluated only once for a complete screen redraw cycle,
not for each individual status line, so one cannot use it to set different
highlightings for different status lines.

Therefore, this plugin sets up autocmds that continually adapt buffer-local
'statusline' settings (which prepend the highlight group to the (mostly)
global setting (though local 'statusline' settings set by ftplugins are kept,

This plugin does not introduce any commands or mappings. Just observe the
changed status line colors, e.g. when using :view, :pedit, :help, etc.

You immediately see that a buffer is read-only because its status line is
gray, not black; unmodifiable buffers are even "more" gray. Unsaved, modified
buffers are indicated via a dark-red status line. Special windows like the
command and quickfix windows, as well as many "scratch" buffers used by
plugins are shown in dark blue. The preview window is now also easy to find,
because it has a blue status line.
install details
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vba.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim StatusLineHighlight.vba.gz
    :so %
To uninstall, use the :RmVimball command.

- Requires Vim 7.0 or higher.

For a permanent configuration, put the following commands into your vimrc:

You may override the default highlightings and define your own colors in the
following form. As with the built-in status line highlighting, there is a
hl-StatusLine group for the current window and a hl-StatusLineNC for all
non-current windows.  
    highlight StatusLineModified           term=bold,reverse cterm=bold,reverse ctermfg=DarkRed  gui=bold,reverse guifg=DarkRed
    highlight StatusLineModifiedNC         term=reverse      cterm=reverse      ctermfg=DarkRed  gui=reverse      guifg=DarkRed
    highlight StatusLinePreview            term=bold,reverse cterm=bold,reverse ctermfg=Blue     gui=bold,reverse guifg=Blue
    highlight StatusLinePreviewNC          term=reverse      cterm=reverse      ctermfg=Blue     gui=reverse      guifg=Blue
    highlight StatusLineReadonly           term=bold,reverse cterm=bold,reverse ctermfg=Grey     gui=bold,reverse guifg=DarkGrey
    highlight StatusLineReadonlyNC         term=reverse      cterm=reverse      ctermfg=Grey     gui=reverse      guifg=DarkGrey
    highlight StatusLineSpecial            term=bold,reverse cterm=bold,reverse ctermfg=DarkBlue gui=bold,reverse guifg=DarkBlue
    highlight StatusLineSpecialNC          term=reverse      cterm=reverse      ctermfg=DarkBlue gui=reverse      guifg=DarkBlue
    highlight StatusLineUnmodifiable       term=bold,reverse cterm=bold,reverse ctermfg=Grey     gui=bold,reverse guifg=Grey
    highlight StatusLineUnmodifiableNC     term=reverse      cterm=reverse      ctermfg=Grey     gui=reverse      guifg=Grey

Rating scripts is only available on the HTTPS page

script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
StatusLineHighlight.vba.gz 1.01 2011-07-01 7.0 Ingo Karkat Avoid losing the statusline highlightings on colorscheme commands.
StatusLineHighlight.vba.gz 1.00 2010-12-27 7.0 Ingo Karkat Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo