VIM: Setting a colorscheme
Every good text editor deserves to have a customizable color scheme.
For vim, colorschemes are installed as any other plugin. Most colorschemes
can be downloaded as a
.vim file. If you are not using a plugin manager,
you need to copy the
.vim file to an
autoload folder inside a
in your home directory.
However, if you are using a plugin manager, (as you should), then depending on the plugin manager, the colorscheme may be installed like a plugin. Personally, I suggest you install a colorscheme-pack. Since it makes it trivially easy to switch to any colorscheme (it has almost all colorschemes you can think of, and you can create a pull request for missing ones).
Once the colorscheme pack is installed, you can go ahead and try out the colorschemes for yourself.
Suppose you want to try out jellybeans colorscheme (my favorite, BTW). Open up vim, and while in normal mode, type:
You can also try some other famous colorschemes:
- Solarized - Both dark and light background variants are widely popular.
- Vividchalk - High contrast colorscheme
- Lucius - One of the few good light color schemes
- Tomorrow Night
Vim colorschemes can be tricky. Most colorschemes should work without any problems on
gvim, however, if you like to do all your work on terminal, then you might not have the luxury of 16 million colors. Most new terminals support atleast 256 colors.
If you are unsure, there is a script called 256color.pl which can be used to find out if your terminal supports all 256 colors. If it does, and vim still isn't showing proper colors, try
:set t_Co=256to force vim to use 256 colors. Alternatively you can try setting the terminal name manually by typing
TERM=xterm-256colorin a terminal and then running vim.
Some themes however, would never appear well (or at all) on 256 color terminals. That's because they don't support them. To still use those themes, you can use plugin
csapproxwhich would make map the colors to a 256 color pallete as best as it can. For inquisitive minds, searching for truecolor terminals might also be a good workout.
If you can't find a colorscheme in the pack, that's probably because the names are case sensitive for example, the correct names for the above are:
As always, use tab completion in vim to make searching for colorschemes easier.