How to Highlight Text in Vim Editor in Linux
Last Updated :
24 Nov, 2023
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:
- Open the vim editor
- Press Esc if you are in insert mode
- Type the below command to enable syntax highlighting and press Enter
:syntax on

To disable the syntax highlighting follow the below simple steps:
- Open the vim editor
- Press Esc if you are in insert mode
- Type the below command to disable syntax highlighting and press Enter
: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:
- Open the vim editor
- Press Esc if you are in insert mode
- Type the below command to apply the color scheme and press Enter
: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,
- Please open the file in Vim editor to configure it
vi ~/.vimrc
- Configure the default setting as per your requirements,
- For example, if you want to turn on the text/syntax highlighting by default when you open the vi editor add the command syntax on

- When you are done with the configuration Press Esc to exit the insert mode
- Use:wq command to save the changes and exit the editor
- After saving the changes whenever you open the vim editor it will open with the default settings you set in the configuration file.
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.
Similar Reads
How to undo in Vim editor in Linux
Vim (short for Vi Improvised) is a popular text editor mainly used in Linux and Unix-based operating systems but due to having a CLI (command line interface), it might be difficult for new users to make use of basic features such as undo in Vim. So in this article, we will learn different ways and t
3 min read
How to Edit Multiple Files in Vim Editor in Linux
Vim, short for "Vi Improved," is a highly configurable and powerful text editor built upon the foundation of Vi. Like its predecessor, Vim offers robust support for editing multiple files simultaneously, making it an indispensable tool for developers, system administrators, and anyone working extens
4 min read
How to Edit Text Files in Linux?
Need to tweak a file in Linux but not sure where to start? Editing text files in Linux is a handy skill that can help you fix settings, write scripts, or just note down notes all from your keyboard. This blog is here to help you get started, even if youâre new to Linux. Weâll show you simple ways to
4 min read
How to Edit Multiple Files in Vi Editor in Linux
Vi, short for "visual editor," is a powerful and ubiquitous text editor in the Linux ecosystem. Among its many features, one of the most useful is its capability to edit multiple files simultaneously. This ability streamlines the editing process, especially when dealing with projects that span multi
4 min read
How to Hide Line Numbers in Vim Editor
In this article, we will cover how to hide line numbers in the Vim editor. First, we look at what Linux and VIM editors and why we use them, what are its features and how can we use them followed by various options to make the Vim editor hide line numbers and how we can change the default settings o
3 min read
How to Exit Vim in Linux?
Exiting VIM quickly and easily can be done in multiple ways, depending on whether you want to save changes or quit from VIM without saving. Exiting VIM (a text editor commonly used in Linux) can confuse new users. Here's a step-by-step guide to help you exit VIM safely, whether you've made changes o
5 min read
Joining Two Lines in VI Editor
Vi is a powerful command-line text editor used by programmers, system administrators, and writers alike. They offer a vast array of features, including the ability to manipulate text efficiently. One common task you might encounter when working with Vi is joining two lines together. This article wil
3 min read
How to Save and Exit in Nano Editor in linux
Saving and exiting in the Nano text editor in Linux is a fundamental skill for anyone working with text files in the terminal. Nano is a user-friendly and straightforward text editor, making it an excellent choice for both beginners and experienced Linux users. Whether you're editing configuration f
5 min read
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
3 min read
How to Display Line Number in vim editor in Linux
In this article, we will cover how to make the Vim editor display or hide line numbers. First, we look at what Linux and VIM editors and why we use them, are its features and how can we use them Follow the basic VIM editor guide to get familiar with the editor followed by various options to make the
5 min read