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.

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.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/open-vim.png" data-lazy- height="448" src="data:image/svg xml,” width=”721″>

In .vimrc disable syntax highlighting with the following code

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/vim-syntax-off.png" data-lazy- height="134" src="data:image/svg xml,” width=”363″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/vim-syntax-on.png" data-lazy- height="932" src="data:image/svg xml,” width=”979″>

Notice the file is mostly unreadable!

Here is the file with syntax highlighting off:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/vim-syntax-off-example.png" data-lazy- height="932" src="data:image/svg xml,” width=”979″>

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

<img alt="" data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/wolfman-150×150.jpg" height="112" src="data:image/svg xml,” width=”112″>

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.