# How to enable syntax highlighting in less

**URL:** <https://linux-tips.com/t/how-to-enable-syntax-highlighting-in-less/208>\
**Category:** Shell\
**Created:** [October 6, 2008, 10:27am UTC](https://linux-tips.com/t/how-to-enable-syntax-highlighting-in-less/208 "2008-10-06T10:27:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [October 6, 2008, 10:27am UTC](https://linux-tips.com/t/how-to-enable-syntax-highlighting-in-less/208/1 "2008-10-06T10:27:24Z")

</div>

If you want syntax highlighting in less, you must install gnu **source highlight** software first: [GNU Source-highlight - GNU Project - Free Software Foundation (FSF)](http://www.gnu.org/software/src-highlite)

In Debian based distributions you can install with:

```auto
sudo apt-get install source-highlight

```

When you have source-highlight package installed, you just need to set two environment variables as below:

```auto
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=' -R '

```

> You should add this lines into `~/.bashrc` or `~/.profile` which is executed in every login.

Here is an example output with less:

![](https://linux-tips.com/uploads/default/original/1X/311f40a1adcc0544e35125cc8ec4adad11815918.png)
