- Details
- Written by Tech Notes
- Published: 23 April 2014
How To Add, Turn On, or Off Coloring To VIM (VI) Editor
Turning on text coloring for code syntax that the VIM (VI) editor recognizes helps immensely. Just being able to separate the Comments from the Code is a huge help by itself.
No Colored Text Example (click to see larger image):
Colored Text Example (click to see larger image):
The above example was randomly chosen from a .c file on a linux server just to demonstrate the major difference. This coloring occurs on most code or script files (php, perl, C language, HTML, bash, and many others)
This article assumes you know VIM (VI) program/software. It is typically a standard installation on Linux or Unix based servers. At a terminal or SSH or Telnet session command prompt, simply type vi test.txt
to see it in action. A graphical version, like gvim, could also be used.
Steps To Turn On Or Off The Coloring
Open the file you want to editvi YourFileName.extension
Enter Shift : and type syntax on, push Enter key. If that does not work, then push ESC key, and then enter Shift : and type syntax on, push Enter key.:syntax on
That is all. To turn off the coloring, do syntax off.:syntax off
To Make Coloring Automatically Occur Or A Permanent Feature.
Locate the .vimrc file. This could be in a home directory of a user, or in /etc, or locations. Edit the .vimrc file, and add the line syntax on. You can use the VIM editor to do this.
Dovi .vimrc
and then scroll to the bottom and go into Insert Mode by pushing i, and type:syntax on
Then push ESC to get out of Insert Mode, and save and exit the updated file by typing:wq
What If Doing The Above Does Not Work
If you do not see the text show with colors after the above is done, then the article of Solution To VIM Not Showing Colors may provide a answer.
Feel Free To Leave A Good Comment. :)
Look around, and you may find other useful articles.