Setting background color in gvim
Solution 1
set background
does not change the background; it tells vim
whether your background is dark or bright (light).
You could use your .gvimrc
file to set colors specific to gvim. I set my color scheme to slate, desert, or evening because I like light-on-dark color schemes:
colorscheme slate
Or you could add this to your .gvimrc
or .vimrc
to set the colors to white-on-black:
highlight Normal guifg=white guibg=black
Solution 2
I found below settings in .vimrc/.gvimrc are more easy and convenient for dark theme in gvim
" Dark mode settings
colors koehler
highlight LineNr guifg=DarkGray
highlight Search guibg='Purple' guifg=#FFFFFF
highlight String guifg=#FF5733
highlight Visual guibg=#000000
highlight Pmenu guifg=#000000 guibg=#808080
For gray theme instead of dark
colorscheme evening
set bg=light
Related videos on Youtube
petersohn
Updated on September 17, 2022Comments
-
petersohn over 1 year
I use a terminal with white text on black background (I just like it better), so I wrote the following line in my
.vimrc
file:set background=dark
However,
gvim
has black on white text. How do I do either of the following:- Set the background of
gvim
to black - Check in
.vimrc
if I'm usinggvim
I tried this: I started up
gvim
, and typedecho &term
. The answer was "builtin_gui". So I wrote the following into.vimrc
:if &term == "builtin_gui" set background=light else set background=dark endif
Somehow, it didn't work.
- Set the background of
-
petersohn about 14 yearsWhen I start gvim, does both .vimrc and .gvimrc run?
-
Trey Hunner about 14 yearsYes. Anything in
.gvimrc
should run after.vimrc
, so.gvimrc
preferences will take precedence over.vimrc
.