Turn On or Off Color Syntax Highlighting In vi or vim Editor
October 30, 2006in CentOS, Debian / Ubuntu, FreeBSD, Linux, Mac OS X, RedHat and Friends, Suse, UNIX, Vim last updated October 26, 2015Vim 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:
:syntax on
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
: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:
Append the following line:
Save and close the file.
$ cd
$ vi .vimrc
Append the following line:
syntax on
Save and close the file.
No comments:
Post a Comment