Vim is also one of the most customizable text editors out there. Let’s check out how to improve your Vim experience with color schemes!
Vim color schemes
With the help of various Vim tweaks, it’s possible to have fine-grained control over the color settings. There are also plenty of plugins for all the greatest color schemes.
By default, Vim uses the following structure for changing the scheme.
Alternatively, you can use the shorter version of the command.
What does it do? According to the Vim help,
Vim will search for the “colors/<theme>.vim file in the ‘runtimepath’. Vim loads the very first file that’s encountered. If there’s no such theme, it’ll show the following warning.
In the above examples, the color scheme of Vim isn’t permanent. Every time you restart Vim, you have to reload your favorite color scheme. Really boring, right? Why not just take the help of the vimrc file?
Edit the vimrc and add the following line at the top/end.
Don’t forget to test the changes before you move forward.
Want to know what color schemes are currently installed? Check out the following directory for the complete list.
The following directory usually holds all the color schemes for the current user only.
Installing Vim color scheme
There are different ways you can install a new color scheme for Vim. The very first step is to find out a suitable one. For example, let’s check out the Monokai theme for Vim.
Download the color scheme from GitHub and put it in “~/.vim/colors” directory.
Inside Vim, run the following command.
If you want to make this theme permanent for all your Vim sessions, add the following lines in the vimrc file.
Color scheme using the plugin manager
This is the easiest way to install and use a color scheme for Vim is through a suitable Vim plugin manager. Yes, the number of Vim plugins is so big that for proper management, a plugin manager is necessary. There are a number of Vim plugin managers out there. Check out how to use the Vim plugin manager.
In this example, I’ll be using vim-plug. Feel free to find out your favorite Vim color scheme from Vim Awesome – the largest collection of Vim plugins across the universe.
For example, let’s install Solarized 8.
As the page suggests, add Solarized 8 in the plugin list of vim-plug in the vimrc file.
Complete the installation by running the following Vim command.
Once the installation is complete, update the vimrc file to load the theme.
Check out the result!
Vim MEGA color scheme collection
There are definitely a ton of color schemes out there for Vim. Installing all of them one by one is literally the most painful task. How about getting all the Vim color schemes in one fell swoop?
Check out vim-colorschemes by flazz on GitHub. It’s a MEGA collection of Vim color schemes in the form of a single plugin. The recommended way of installing this plugin is using a suitable plugin manager like Vundle or Pathogen. Vim-plug also does the job.
As I’m using vim-plug, I have to add the following line in the vimrc file.
If you’re using Pathogen, use the following one.
For Vundle, it’s quite similar to vim-plug.
Finally, reload vimrc and complete the install.
Check out the complete list of installed color schemes by this MEGA plugin.
To try out a different color scheme, use the aforementioned trick.
Here’s another trick that you can directly perform from the Vim’s command line. Type “:colo”, then <space>, then hit “Tab”.
Note: The above plugin includes a lot of color schemes but those are very old (not updated for years). So, my personal recommendation would be using it to only check out different color schemes. If you happen to like one, search for it in Vim Awesome and install the latest one.
There are also other such big collections.
A color scheme can dramatically influence your experience with any text editor. In the case of Vim, it’s more important. It’s a console text editor and a handy coloring will surely help your eyes to focus on where you need to focus. It also helps to imrpove the aesthetics.