To customize VIM color schemes and syntax highlighting in Ubuntu 20.04, simply follow the methods explained below.
Customizing Color Schemes in Vim
To customize color schemes in Vim, follow the steps below:
First, launch the terminal in Ubuntu 20.04. Press Ctrl+ T or click on the Activities icon located in your desktop. Next, type ‘terminal’ in the search bar that appears, and double click on the search results to open the terminal. Alternatively, you may also right-click on your desktop to launch a pop-up menu, from which you will select the Open Terminal As soon as you do this, the terminal window will appear on your screen, as shown in the image below:
Type the command below in your terminal, followed by pressing the Enter key:
Running this command will open the Vim text editor in your terminal. You can see the command in the image below:
Once you have the Vim text editor opened in front of you, type the following command:
Next, type a colon (;), followed by ‘colorscheme,’ and then a space, and press Ctrl+D, as shown in the image below:
As soon as this command runs successfully, you will see a list of different color schemes that are available for your Vim text editor, as shown in the following image:
Now, you can decide on a color scheme from this list. After choosing a color scheme, type the following command in your terminal, followed by pressing the Enter key:
Here, replace the term ‘ChosenScheme’ with the name of your desired color scheme from the list. In this example, I want to change the color scheme to blue, so I will replace ‘ChosenScheme’ with ‘blue,’ as shown in the image below:
Upon executing this command successfully, your color scheme will immediately change to the chosen scheme, as shown in the following image:
Syntax Highlighting in Vim
To highlight syntax in Vim, perform the following steps:
First, you will need to create a dummy text file with the Vim text editor to try out this method. To do so, you will first need to launch the terminal, as described previously. Once you have the terminal window open in front of you, type the following command in the terminal, and then press the Enter key:
Here, replace the term ‘FileName’ with whatever name you want to keep for your dummy text file. In this example, I have replaced ‘FileName.txt’ with ‘Testing.txt,’ as shown in the image below:
Once this command has executed successfully, an empty text file with the name Testing.txt will open in front of you. Press the Esc key to switch to the insert mode, and then type any random text in it, as shown in the following image:
To switch back to the command mode, press the Esc key again. Next, type the below command in your Vim text editor, followed by pressing the Enter key:
Running this command will save your newly created text file. The image below shows this command:
Next, type the following command in your terminal and press the Enter key:
Here, you will replace the ctermfg color term with the color that you want to keep for the foreground and the ctermbg color term with the color that you want for the background. In this example, I have replaced the first color with Black and the second color with Red, as shown in the following image:
After this command has been executed successfully, the text color of the dummy text file will be changed to black and the background color will be changed to red, as shown in the image below:
Conclusion
By following the methods described in this article, you can conveniently customize Vim color schemes and also highlight text in your text files.