Vim or vi is a text editor. It can be used to edit all kinds of plain text files, editing programs, and UNIX/Linux configuration files. Vim supports additional options and it includes a lot of enhancements above old good vi text editor.
Syntax highlighting is nothing but a feature of vi/vim text editors that displays text, especially source code, in different colors and fonts according to the category of terms.
Task: Turn on color syntax highlighting
Open a file, for example open existing file called file.c, enter:
$ vi file.c
Now press ESC key, type ": syntax on" i.e. type as follows:
C source code editing while syntax highlighting is on in vi or vim:
Task: Turn off color syntax highlighting
To turn it back off, press ESC key, type : syntax off
How do I make the syntax highlighting permanent?
You can edit ~/.vimrc file and add append vim command syntax on to it. This ensures that vim will start with color syntax highlighting option:
$ vi .vimrc
Append the following line:
Save and close the file.