(g)Vim Changing Statusline Colors

I found this somewhere, forgot exactly where, but still decided to share.

I have my (g)Vim setup to change the colors of the status line depending on the insert mode I am in; lightgray on darkgray for no insert mode, red on grey for normal insert mode, and gray on red for replacement mode. All I need for this is following function in my color theme:

   1  " Status line - changes colors depending on insert mode
   2  hi StatusLine     guifg=#666666   guibg=#1b1b1b   gui=none
   3  hi StatusLineNC   guifg=#444444   guibg=#1b1b1b   gui=none
   4  function! InsertStatuslineColor(mode)
   5    if a:mode == 'i'
   6      hi statusline guifg=#DA4939   guibg=#1b1b1b   gui=none
   7    elseif a:mode == 'r'
   8      hi statusline guifg=#0b0b0b   guibg=#DA4939   gui=none
   9    else
  10      hi statusline guifg=#666666   guibg=#1b1b1b   gui=none
  11    endif
  12  endfunction
  13  au InsertEnter * call InsertStatuslineColor(v:insertmode)
  14  au InsertLeave * hi statusline    guifg=#666666   guibg=#1b1b1b   gui=none

Cal 2011.04.25

Tag Vim