Setting the Vim background colors

LinuxBackgroundVimVi

Linux Problem Overview


When I try to change the background colors in .vimrc or directly in Vim using the command:

set background=dark

... it doesn't affect my background at all. Neither does the light option. However, it looks okay when I run gvim.

Is there a way to change the background in Vim without changing my Konsole settings?

EDIT Okay, there is a difference between guifg/guibg and ctermfg/ctermbg. While the GUI accepts lots of different color combinations, cterm allows only few standard ones.

Linux Solutions


Solution 1 - Linux

As vim's own help on set background says, "Setting this option does not change the background color, it tells Vim what the background color looks like. For changing the background color, see |:hi-normal|."

For example

:highlight Normal ctermfg=grey ctermbg=darkblue

will write in white on blue on your color terminal.

Solution 2 - Linux

In a terminal emulator like konsole or gnome-terminal, you should to set a 256 color setting for vim.

:set  t_Co=256

After that you can to change your background.

Solution 3 - Linux

Try adding

set background=dark

to your .gvimrc too. This work well for me.

Solution 4 - Linux

Using set bg=dark with a white background can produce nearly unreadable text in some syntax highlighting schemes. Instead, you can change the overall colorscheme to something that looks good in your terminal. The colorscheme file should set the background attribute for you appropriately. Also, for more information see:

:h color

Solution 5 - Linux

supplement of windows

gvim version: 8.2

location of .gvimrc: %userprofile%/.gvimrc

" .gvimrc
colorscheme darkblue

Which color is allows me to choose?

Find your install directory and go to the directory of colors. in my case is: %PROGRAMFILES(X86)%\Vim\vim82\colors

blue.vim
darkblue.vim
slate.vim
...
README.txt

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaksim Vi.View Question on Stackoverflow
Solution 1 - LinuxAlex MartelliView Answer on Stackoverflow
Solution 2 - LinuxAA.View Answer on Stackoverflow
Solution 3 - LinuxLukeView Answer on Stackoverflow
Solution 4 - LinuxMichael KristofikView Answer on Stackoverflow
Solution 5 - LinuxCarsonView Answer on Stackoverflow