vim

How to Disable VIM Syntax Highlighting

The VIM editor provides a cool feature to highlight syntax based on whatever language you are programming in. This makes it easier to edit the code and visually understand the syntax of the code. However as a system admin or DevOps engineer you may find yourself editing many configuration files of various formats and on various remote machines and because of the systems you login to, the syntax highlighting makes the file unreadable in your session.

Therefore in this post, we will show how to disable syntax highlighting in the .vimrc configuration file. This way all files that you open will have plain text, without any color schemes, and you can quickly get to work.

I found myself frequently opening files and then disabling syntax highlighting dynamically, its more efficient to add the command to the .vimrc file on each machine you use.

How to Disable VIM Syntax Highlight in the .VIMRC file

First make sure vim is installed. For example run apt-get install vim, or yum install vim, or whatever command is applicable to your distribution. On Windows, the process is less easy to install vim, but I will leave that for you to figure out.

Then in your home directory open the file, or create the file .vimrc.

In .vimrc disable syntax highlighting with the following code

Now let’s compare loooking at a file with syntax highlighting on and off.

I was just logged into a virtual box for Ubuntu 20.04 and trying to edit a configuration file in systemd.

Here is the file with syntax highlighting on:

Notice the file is mostly unreadable!

Here is the file with syntax highlighting off:

Notice you can now easily read the file contents!

Syntax highlighting will help programmers who have configured it properly for their language of choice to match their terminal settings. But for random access of files on multiple systems, it frequently gets in the way of productivity.

Conclusion on syntax highlighting with vim

You can see clearly in the above example, that when logging in to many different machines you might find your self annoyed by VIM syntax highlighting. As the highlighting needs to be configured to useful, and for configuration file editing on new systems, its frequently not optimized and annoying.

This article gives you the configuration to disable syntax highlighting. Please use it as needed.

About the author

Linux Wolfman

Linux Wolfman is interested in Operating Systems, File Systems, Databases and Analytics and always watching for new technologies and trends. Reach me by tweeting to @linuxhint and ask for the Wolfman.