FUNDAMENTALS A Complete Guide for Beginners
To set the Vim color scheme in Linux, follow the steps below:
- Open Vim Text Editor with the
vim
command. - Use
:colorscheme
command to view available color schemes. - Select the desired color scheme.
- Set the color scheme with the
:colorscheme [scheme_name]
command.
To know each step in detail, go through this article. Here, I will show you how to install the Vim color scheme. Additionally, you will learn how to change, view, control, and make the color scheme permanent.
What is Vim Color Scheme?
The Vim color scheme is one of the unique features of the Vim text editor that determines the color for the syntax highlighting. The color scheme of Vim is composed of different colors that can be selected per choice. Vim color scheme improves the visual experience of the user throughout the code. It enhances the readability of any code by making it easier for the user to recognize variables, keywords, or other code elements.
How to install Vim Color scheme?
There are two ways to install the Vim color scheme. Check them out:
1. Manual Installation
To install the Vim color scheme manually, follow the steps below:
- First, create a directory where to download the color scheme file:
mkdir -p ~/.vim/colors
The
mkdir
command with the-p
option will create a sub-directory “colors” in the directory “.vim”. - Now, download the color scheme file from the GitHub repository using the wget command:
wget https://raw.githubusercontent.com/altercation/vim-colors-solarized/master/colors/solarized.vim -O ~/.vim/colors/solarized.vim
The solarized color scheme has been saved in the
/home/mou/.vim/colors
directory:
2. Using Vim-Plug
To install a solarized Vim color scheme utilizing the Vim-Plug plugin manager, follow the below steps:
- First, install the Vim-Plug by following this linked article.
- After installing the Vim-Plug, open the
.vimrc
file with this command:vim ~/.vimrc
- Now, install plugins for the Vim solarized color scheme by writing the following lines in the
.vimrc
file:call plug#begin('~/.vim/plugged') Plug 'altercation/vim-colors-solarized' call plug#end()
- Save and exit the configuration file with
:wq
command. - Reopen the
.vimrc
file and execute:PlugInstall
command to successfully install the color scheme plug:
4 Steps to Set Vim Color Scheme
Here are detailed 4 steps to set the Vim color scheme:
Step 1: Open Vim Text Editor
Open a terminal window with CTRL+T and type Vim to open the Vim text editor:
vim
Step 2: View Color Scheme
To view the Vim color scheme, execute the command below:
:colorscheme
You will see the default color scheme here.
To see all the available color schemes, run :colorscheme
command followed by a space, and then press CTRL+D:
Step 3: Select Color Scheme
After viewing all the colors, select your desired color scheme in Vim. In this case, I will select the “solarized” color scheme from the available options:
Step 4: Set Vim Color Scheme
Once you have selected the color scheme, set it using :colorscheme [colorscheme_name]
command. To set a solarized color scheme, apply the following command in the Vim text editor:
:colorscheme solarized
How to Manage Vim Color Scheme?
To use the Vim color scheme effectively and get the most benefit out of it, users should know how to operate it. Here are some crucial operations associated with the Vim color scheme:
A. Set Default Vim Color Scheme
The color scheme changes are temporary. When you close Vim, the color scheme will go back to the default settings. To set the desired color scheme as default and make it persistent, you can follow the steps below:
- Set the desired color using Step 4: Set Vim Color Scheme.
- Open the
.vimrc
file and add the following lines to set the solarized color scheme as default:syntax on set background=dark colorscheme solarized
EXPLANATIONHere,syntax on
enables syntax highlighting. Theset background
command sets the background color to “dark” and the color scheme is set to solarized.
- After that, save and exit the .vimrc file using
:wq
command to make the color scheme permanent.
B. Change Vim Color Scheme
To change the color scheme, use :colorscheme [colorscheme_name]
command. For example, to change it from solarized to blue, type this line:
:colorscheme blue
After writing the command, press ENTER to get the output as follows:
Now, to change the “blue” color scheme to “morning”, execute :colorscheme morning
command:
Thus, you can change the color scheme in Vim.
C. Control Vim Color Scheme
To control the Vim color scheme, use the highlight
command. It can alter the whole color scheme or a part of it. For instance, to turn the text color “red” from the default color, run the following command from the normal mode in Vim:
:highlight Normal ctermfg=Red
You can also set the background color scheme from default to “red” with the highlight
command. Here’s how:
:highlight Normal ctermbg=Red
To see the list of Vim’s default highlight groups, run this command:
:help highlight-groups
Conclusion
To wrap up, I have explained the basics of the Vim color scheme to ease the life of Vim users. I have also added how to install the Vim color scheme, and how to set, and install it. By reading this article, you will know everything about the color schemes for the Vim text editor. Happy reading!
People Also Ask
How to Make the Vim Color Scheme Persistent?
To make the Vim color scheme persistent, write colorscheme [colorscheme_name]
in the .vimrc
file. Then save and exit the configuration file using :wq
command.
How do I install a color scheme file in Vim?
To install a color scheme in Vim, download the desired scheme using the wget
command. After that, add the plug script to the .vimrc
file and save it.
How to highlight text in Vim?
To highlight text in Vim, use the highlight
command. This command can change the text color as well as the background color.
Related Articles
- How to Install Vim in Ubuntu? [5 Methods]
- How to Edit With Vim in Linux? [Explained]
- How to Install and Use Vim-Plug in Linux [Explained]
<< Go Back to Vim in Linux | Linux Text Editors | Learn Linux Basics