Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change vim status line color?

I'm tring to change vim's status line color by editing my .vimrc .

By using the command au, I tried to change the color of the status line when entering or leaving insert mode; by using this command nothing happens:

hi StatusLine guibg=whatevercolourIwant

By changing the status line color directly, without any au command, the background remains the same.

Is there reason why by executing

:hi StatusLine guibg=red,

for instance, the background of the status bar still remains greenish?

like image 500
gcali Avatar asked Jan 30 '12 15:01

gcali


People also ask

How do I change the color of a status line in Vim?

vimrc ( :w | so % ), and the terminal mode status line should have the same colors as your color scheme: Above, hi is a shorthand for highlight , which is used to define highlight group colors.

How do I change the background color in vim?

The ctermfg=white is used to set the foreground color to white in a terminal text editor. Finally, the ctermbg=black is used to set the background color to black in a terminal text editor.

What is status line in Vim?

The statusline in Vim is the bar along the bottom of the Vim window. By default it does not show when you open Vim until there is more than one window.


2 Answers

if you are running vim in terminal, try:

hi StatusLine ctermbg=whatever ctermfg=whatever 

guibg guifg are for GUI.

hope it helps.

like image 130
Kent Avatar answered Sep 19 '22 15:09

Kent


I use this for my status line, which changes the colour of the line depending on what mode I'm in, amongst other tidbits:

function! InsertStatuslineColor(mode)   if a:mode == 'i'     hi statusline guibg=Cyan ctermfg=6 guifg=Black ctermbg=0   elseif a:mode == 'r'     hi statusline guibg=Purple ctermfg=5 guifg=Black ctermbg=0   else     hi statusline guibg=DarkRed ctermfg=1 guifg=Black ctermbg=0   endif endfunction  au InsertEnter * call InsertStatuslineColor(v:insertmode) au InsertLeave * hi statusline guibg=DarkGrey ctermfg=8 guifg=White ctermbg=15  " default the statusline to green when entering Vim hi statusline guibg=DarkGrey ctermfg=8 guifg=White ctermbg=15  " Formats the statusline set statusline=%f                           " file name set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding set statusline+=%{&ff}] "file format set statusline+=%y      "filetype set statusline+=%h      "help file flag set statusline+=%m      "modified flag set statusline+=%r      "read only flag  " Puts in the current git status     if count(g:pathogen_disabled, 'Fugitive') < 1            set statusline+=%{fugitive#statusline()}     endif  " Puts in syntastic warnings     if count(g:pathogen_disabled, 'Syntastic') < 1           set statusline+=%#warningmsg#         set statusline+=%{SyntasticStatuslineFlag()}         set statusline+=%*     endif  set statusline+=\ %=                        " align left set statusline+=Line:%l/%L[%p%%]            " line X of Y [percent of file] set statusline+=\ Col:%c                    " current column set statusline+=\ Buf:%n                    " Buffer number set statusline+=\ [%b][0x%B]\               " ASCII and byte code under cursor 
like image 21
jhogendorn Avatar answered Sep 21 '22 15:09

jhogendorn