Reputation: 57
I am a fairly new user of WSL and vim, and I wanted to install a new colorscheme for terminal vim. I do the standard steps: Create a ~/.vim/colors directory, then move the theme.vim files there. And when I open vim I can select them with :colorscheme, but the theme I get is entirely different from the one I installed. I have tried three different themes now and none of them have worked as expected.
Anyone one here knows what the cause of this could be?
Upvotes: 3
Views: 2698
Reputation: 196926
Tl;dr: make sure the colorscheme fits your environment.
Vim colorschemes can have any of the following properties, alone or in combination…
8/16color-friendly colorschemes use the terminal emulator's 0-based 16 colours palette. Since various terminal emulators have different defaults and that palette is user-configurable it is impossible to predict accurately how it will look like.
You can expect these colorschemes to work reasonably well in most terminal emulators.
256color-friendly colorschemes use a semi-standardised 0-based 256 colours palette with the lower 16 indices corresponding to the aforementioned 16 colours palette. This means that colours 16 to 255 can reasonably be expected to look the same across modern terminal emulators.
You can expect these colorschemes to work well in many terminal emulators if your $TERM
environment variable is set to something ending with 256color
, xterm-256color
being the most common correct value.
GUI-friendly colorschemes use hexadecimal values like in HTML/CSS for the best possible experience. If a colorscheme is GUI-friendly, it is automatically true-colors-friendly, which makes it suitable for use in terminal emulators that support the so-called "true color" feature.
If you use GUI Vim, then you don't have to worry about anything with these colorschemes. If you use Vim in a terminal emulator, then you will have to check if it supports the "true colors" feature and, if that's the case, enable it in Vim with :help 'termguicolors'
.
Colorscheme authors are usually explicit about those things so you should be able to tell if a colorscheme fits your needs or not just by reading its README
. If that is not the case, you can try looking for these hints in the code:
ctermbg
and ctermfg
only set to colour names or to numbers 0-15 means that the colorscheme is 8/16color-friendly.
Note that the name notation is more portable than the number notation.
ctermbg
and ctermfg
set to numbers 0-255 means that the colorscheme is 256color-friendly.
guibg
and guifg
present means that the colorscheme is GUI-friendly/true-color-friendly.
Upvotes: 5