How To Turn Color On and Off in Vim

Color coding different types of words, depending on the programing language you are using is an extremely useful feature of vim. Vim is smart enough to know that when you are editing a .js JavaScript file, then you want words such as ‘function’ and ‘for’ to be highlighted and stand out. This coloring of certain key words makes code much easier to read and edit. vim calls this feature ‘syntax’.

To turn on syntax in vim just type:syntax onin the file you are editing. To turn color highlighting off just type:syntax offinside vim.

To permanently turn syntax color coding on edit/create the .vimrc file.vi ~/.vimrcand ensure the file contains the linesyntax on.

Be sure to check out the available vim addon scripts. There’s a ton of them out there, just search and set the ‘type’ to syntax. If you code in a particular language, try searching for that language specifically.

Leave a Reply

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