How to Customize VIM Color Schemes and Syntax Highlighting

Vim is a well-known text editor used in the Linux operating system. You can work with most Linux utilities by making use of the command-line interface (CLI). However, at times, this interface gets quite dull and boring. Like any other text editor, Vim provides you with various customization options with which you can make this program look more attractive and eye-catching. This article will talk about some of the methods you can use to customize Vim color schemes and syntax highlighting in Ubuntu 20.04.

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:

1. 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:

2. Type the command below in your terminal, followed by pressing the Enter key:

vim

Running this command will open the Vim text editor in your terminal. You can see the command in the image below:

3. Once you have the Vim text editor opened in front of you, type the following command:

:colorscheme CTRL+D

Next, type a colon (;), followed by ‘colorscheme,’ and then a space, and press Ctrl+D, as shown in the image below:

4. 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:

5. 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:

:colorscheme ChosenScheme

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:

6. 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:

1. 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:

vim FileName.txt

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:

2. 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:

3. 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:

:wq

Running this command will save your newly created text file. The image below shows this command:

4. Next, type the following command in your terminal and press the Enter key:

:hi Normal ctermfg=Color ctermbg=Color

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:

5. 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.



from Linux Hint https://ift.tt/32Ji5KJ

Post a Comment

0 Comments