Enable syntax highlighting for Vim editor

From time to time, you have to edit a file through the console on the server. Most of the time you probably use the Vim Editor
(“Vi IMproved”). I also use this editor on two servers and I am doing quite good in using it.

But on one server the syntax highlighting in the Vim editor is disabled. You can enable it by typing “:syntax enable” but this setting gets lost each time you close the editor. To activate the syntax highlighting permanently you have to edit the “vimrc” file. You can either use the file in your home directory or the system vimrc which is usually located at /etc/vim/vimrc. In that file you should find the following line:

"syntax on

The double quote comments the syntax command out. After removing the double quote, saving the vimrc file, the next time you open a file with source code, it should be highlighted automatically. In the Vim editor’s documentation you may find more useful tips on how to work with the editor.

I hope that this post was helpful for you. I always wanted to buy me a little book about the vi editor, but as it only has one chapter about the Vim editor, I am not sure if it will be helpful. So I put it on my wish list and maybe someone will buy it for me one day 🙂

Posted by

Bernhard is a full time web developer who likes to write WordPress plugins in his free time and is an active member of the WP Meetups in Berlin and Potsdam.

Leave a Reply

Your email address will not be published. Required fields are marked *