Vim is a free and open source text editor that functions much like other text editors, such as Sublime and Notepad++. Vim can operate from a command-line interface (CLI) or a graphical user interface (GUI). This article explains how to change the colors and themes of your Vim CLI in Linux.
This GIF demonstrates how convenient it is to use Vim from the command line to edit a code file.
Understanding Vim themes
Themes are essentially color schemes, which are combinations of colors that create a good aesthetic when they're used together. Vim comes packed with ready-to-use color schemes.
Note that the Vim color schemes described in this article are applied to the code rather than the terminal's background. If you would like to change the background color of your terminal, I recommend reading How to change the color of your Linux terminal.
If you want to change Vim's color scheme, simply start a Vim session and type the command:
:colorscheme
To see the default color schemes available to you, enter:
:colorscheme + space + tab
By tapping the Tab key, you can cycle through the available schemes. They vary from basic color schemes, such as Red, Blue, or Dark Grey, to special ones such as Desert.
Finding and applying a new theme
Welcome to the world of open source! You can find tons of great Vim themes on GitHub, and you can access many of them through Vimcolors.com. Some of these themes change not only the color of your code or syntax but also the background color.
Vimcolors contains a wide variety of color schemes—to access one, just click on the GitHub logo at the bottom-right of the thumbnail image and the theme's GitHub repo will open.
Once you've found a theme you like:
- Create a Vim directory with:
mkdir ~/.vim
-
Clone the repo to your Vim folder with:
git clone <https://github.com/flazz/vim-colorschemes.git> ~/.vim
Now, if you open Vim and use the colorscheme command along with the name of your chosen new theme (e.g., if you want cooltheme.vim, use :colorscheme cooltheme), it should be ready to use!
To ensure Vim always uses your chosen them when you launch the application, enter the following (you may need to be in sudo/root mode):
echo 'colorscheme <desert>' >> ~/.vimrc
How to choose a theme
Which theme you use is all a matter of personal preference! I like the Desert theme because it is bright, which I like; however, some people prefer darker or even colorful themes. For beginner command-line users, the default black color scheme may feel intimidating, largely due to all the movies about hackers that have sullied the basic black command line's reputation. For this reason, more colorful options may seem more welcoming and help new users feel more comfortable.
If you're not sure where to begin in selecting a theme, here are a handful of my favorite Vim themes from Vimcolors.
What is your favorite Vim theme? Please share it in the comments.
Comments are closed.