Open In App

How to Highlight Text in Vim Editor in Linux

In this article, we will cover how to highlight text or 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.

Linux

Linux is a kernel for operating system(OS) it is a core part of OS which was developed by Linus Torvalds in 1991. It is an open-source kernel that allows everyone to access the source code freely which makes it more popular and widely used in the industry as well as in personal systems. There are operating systems based on the Linux kernel, some of the popular Linux distributions are Ubuntu, Debian, Fedora, Kali Linux, etc.



VIM Editor

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

Syntax/Text 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:



To enable syntax highlighting in the Vim editor follow the below steps:

:syntax on

To disable the syntax highlighting follow the below simple steps:

:syntax off

ColorSchemes 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

To change the default settings of Vim editor, we have to configure the Vim editor configuration file (.vimrc), to configure the default settings follow the below steps,

vi ~/.vimrc

Conclusion

In this article, we had covered how to highlight text/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 :