Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim colorschemes not changing background color

I try to apply various color schemes in vim that I have seen on the net. Whatever scheme I choose, the background remains white, even though screenshots of the applied scheme shows that the background should be colored.

In some schemes, some of the background change color, but space right of lines containing text still remains white.

I'm using Vim 7.2 on a mac. I have just started messing with non-gui applications, so everything should be pretty much as it was out of the box..

Does the overall settings for the terminal window have something to do with it?

When running macvim, everything looks ok. Its only when starting vim from the terminal things looks strange..

like image 217
Vegar Avatar asked Dec 01 '10 15:12

Vegar


People also ask

How do I change the background color in Vim editor?

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.

How do I enable color scheme in Vim?

You can change color schemes at anytime in vi by typing colorscheme followed by a space and the name of the color scheme. For more color schemes, you can browse this library on the vim website. You can enable or disable colors by simply typing "syntax on" or "syntax off" in vi.

How do I change Vim to dark?

In Vim, if your color scheme supports both a light and dark mode, you switch between by using the command: set background=dark or set background=light . In Alacritty, you can define multiple color schemes and switch between them easily in the config file alacritty.


2 Answers

I have this in my .vimrc and it solved this problem for me using while using PuTTY.

set t_Co=256 set background=dark colorscheme mustang highlight Normal ctermbg=NONE highlight nonText ctermbg=NONE 

It's important to load the colorscheme before the ctermbg settings in .vimrc because they need to override the same ones set by the colorscheme. This also means you can't switch colorscheme while Vim is running and expect it to work.

like image 192
cptloop Avatar answered Sep 22 '22 12:09

cptloop


I'm adding a second answer from me because it's very different from my first answer and may point to actual problem.

If you look at the actual website for the colorscheme here: Molokai website

you will see a question very similar to yours. Here's answer given, which suggests trying command :set t_Co=256 in your vimrc to see if it fixes things:

"- Make sure you’re using a console terminal capable of 256 colors; not all of them do (particularly on mac). You might need to explicitly force Vim to use that by doing “set t_Co=256″ on your .vimrc file. - The windows console is well… totally unsupported, that only does 16 colors so it’s a mess"

like image 45
Herbert Sitz Avatar answered Sep 18 '22 12:09

Herbert Sitz