Colorscheme in .vimrc not working

[Answer completely revised for others.]

Since the ":colorscheme" command works manually it proves you have the colorscheme installed. This means you somehow have something coming after it in your initialization scripts that is overriding your preferred scheme. You can track this down by typing ":scriptnames" and reading through it for another colorscheme being loaded. Once you find it, you can remove or comment out that line in whatever initialization script it is being called from.


set background=dark should be before syntax enable and colorscheme whatever in your .vimrc


For others like me stumbling in:

If you are using vim or nvim inside a terminal emulator, make sure that the colors settings for your profile are right. For gnome-terminal, I had to disable "use colors from system theme" in my Preferences/Profile/Color settings before I could get my colorscheme to properly work:

enter image description here

Also, as of recently nvim has deprecated NVIM_TUI_ENABLE_TRUE_COLOR in favor of set termguicolors (see this).

Tags:

Vim