Friday, August 14, 2009

Syntax highlighting in vi/vim editor on ubuntu

To turn on syntax highlighting, use this command. :syntax on
When you open any file in vi editor, press escape and enter :syntax on.
Ubuntu by deafult has vim-tiny installed. So syntax command may not work. You may get this message: "E319: Sorry, the command is not available in this version"

ubuntu vi editor screenshot

To install full version of vim, use following command.

$ sudo apt-get install vim
or
$ sudo apt-get install vim-full
You can also check which package is ubuntu using by entering following command.
$ dpkg -l vim*
priyank@priyank-laptop:~$ dpkg -l vim*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=======================-=======================-============================================
ii vim 2:7.2.079-1ubuntu5 Vi IMproved - enhanced vi editor
ii vim-common 2:7.2.079-1ubuntu5 Vi IMproved - Common files
un vim-doc (no description available)
un vim-gnome (no description available)
un vim-gtk (no description available)
un vim-lesstif (no description available)
un vim-nox (no description available)
ii vim-runtime 2:7.2.079-1ubuntu5 Vi IMproved - Runtime files
un vim-scripts (no description available)
ii vim-tiny 2:7.2.079-1ubuntu5 Vi IMproved - enhanced vi editor - compact version

Once you install vim, and open any file using vi/vim editor turn on syntax highlighting by using the commnad given above. You should be able to see your code like this.

No comments:

Post a Comment