change status line colours in .vimrc?
From this question : How can I change vim status line colour? I learnt how to change the status line colouring, like this :
hi StatusLine ctermbg=3 ctermfg=4
That's fine but how can I do that for every window, all the time rather than having to apply the command for each new window that I open. I would expect to do this in .vimrc but I can't work out how to .
I'm running vim in a terminal not a gui; I'm using desert as a colorscheme.
ANSWER!: After the answers offered by Ingo and Kent reassured me that I was doing the right thing it still didn't work. Then I discovered I had a line in my vimrc which read
set background = dark
I'm not sure why that was in there but when I commented it out I got the status line colours I wanted.
NOT THE ANSWER ! : Hmm OK. I've just discovered that making that change to .vimrc does indeed give me the right colours when I was editting vimrc but when I edit python files the status colours are gone. I'm guessing this is something to do with filetypes=on ?
Either way I'll have to re-ask this question when I have more time to think about it but it seems the 'set background = dark' thing was a problem but it's not the entire solution.
For what's worth my vimrc looks like this :
colorscheme desert autocmd BufRead,BufNewFile *.py syntax on autocmd BufRead,BufNewFile *.py set ai autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class set tabstop=4 set expandtab set shiftwidth=4 filetype indent on "GLAUCON START :set ignorecase "make searches case insensitive by default :set incsearch :set hlsearch " Returns true if paste mode is enabled function! HasPaste() if &paste return 'PASTE MODE ' en return '' endfunction " Always show the status line set laststatus=2 " Format the status line set statusline= %{HasPaste()}%F%m%r%h %w CWD: %r%{getcwd()}%h Line: %l hi StatusLine ctermbg=3 ctermfg=4 "set background=dark "GLAUCON END
I think the StatusLine
is ok (with big S
). the problem is (I guess):
you put the hi StatusLin...
before your colorscheme desert
call. so that the colorscheme overwrites your statusline highlighting.
You should put it after the colorscheme desert
in your .vimrc
First, you have to put the :hi
command after any :colorscheme
command in your ~/.vimrc
, as the colorscheme probably provides its own definition. Similar for :set background=...
and :syntax on
.
If the statusline colors still vanish, maybe (this wasn't totally clear from your question) even when switching / opening new windows, there must be an :autocmd
that does this. Check your installed plugins then.
下一篇: 更改.vimrc中的状态行颜色?