If you want syntax highlighting in less, you must install gnu source highlight software first: http://www.gnu.org/software/src-highlite
In Debian based distributions you can install with:
sudo apt-get install source-highlight
When you have source-highlight package installed, you just need to set two environment variables as below:
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=' -R '
You should add this lines into
~/.profile which is executed in every login.
Here is an example output with less: