Open In App

Enabling Syntax Highlighting in Vim Editor

In this article, we will cover how to highlight syntax in Vim editor. First, we look at what Linux and VIM editors followed by syntax highlighting in the Vim editor with examples and screenshots we will also look at different color schemes available and how we can change the default settings of Vim editor to enable syntax highlighting by default.

VIM Editor

VIM Editor is a text editor generally used in Unix/Linux systems and is well known for its efficiency and flexibility. VIM editor was initially developed by Bill Joy in 1976 as vi editor and later an improved version of vi editor was released in 1991 which is known as VI IMproved (VIM) editor.



Syntax Highlighting in Vim editor

When we open the Vim editor the text is displayed plain and there is no syntax highlighting by default the editor looks like the screenshot below:



Enable Syntax Highlighting

To enable syntax highlighting in the Vim editor follow the below

:syntax on

Disable syntax Highlighting

To disable the syntax highlighting follow the below simple steps:

:syntax off

Color Schemes in Vim editor

There are different colors schemes available in the Vim editor to personalize the editor and get syntax highlighting based on the preferences, to check the list of available colors in the Vim editor run the following command,

    ls -l /usr/share/vim/vim*/colors/

After executing the above command you get the list of available color schemes which you can also see in the below output screenshot like desert, Murphy, evening, etc.

To apply Colorscheme in the Vim editor follow the below simple steps:

    :colorscheme [colorscheme name]

Example:

:colorscheme evening

Configure the Default Settings of Vim editor

We have to configure the Vim editor configuration file (.vimrc) to change the default settings of Vim editor, so whenever the editor opens it loads with the default settings, to configure the default settings follow the below steps,

vi ~/.vimrc

Conclusion

In this article, we had covered how to highlight syntax in Vim editor and how to enable and disable syntax highlighting we will also look what are the available color schemes in vim editor and how to apply the color schemes in the Vim editor, followed by how can we configure the default settings of the vim editor so whenever we open the editor if loads with the default settings.

Article Tags :