Sunday, July 26, 2009

How to show perl/C program files in colors in vi?

I want to see the program files (perl/C/C++ etc) in color font when opened in vi editor. Generally it shows, e.g. the 'for' or 'if' will be shown in orange color. But in my PC (I have installed open suse very recently) it shows in simple black. I have seen the settings already with no result. Please suggest..

How to show perl/C program files in colors in vi?
Press ESC and type : syntax on


or


Open /etc/vimrc and add (or uncomment ) this line : syntax on








Best wishes, Mel
Reply:There's quite a few things. First you have to be using vim rather than vi. However, on linux hosts, vim and vi are the same binary. You also have to have your TERM variable set to a terminal that supports color. ( example: xterm, ansi, linux not vt100 ).





For a shell with color I do this...





For sh/bash:


export CLICOLOR=1


export TERM=linux





For csh:


setenv CLICOLOR 1


setenv TERM linux





Nornally, the system will automatically enable "syntax on" and "hlsearch". Or you can add them to your .virmrc





set syntax on


set hlsearch


No comments:

Post a Comment