Code Syntax Highlighting in NANO (Linux Editor)

Today i was looking for a way to enable extended code syntax highlighting in the linux text editor nano, out fo the box nano comes with limited functionality to do this. I will tell you how to download the needed files and add them to the nano configuration and you will be looking at much prettier code in no time.

Firstly we need the syntax files:

nano syntax highlighting files

Secondly we need to extract the contents and move to the correct location:

Shell
1
2
3
tar -xvf nano-supplement.tar
sudo chown root:root *nanorc
sudo mv *nanorc /usr/share/nano

Thirdly the nanorc file needs to be modified to reference the new syntax files we just extracted and moved:
Open the nanorc file for editing

Shell
1
sudo nano /etc/nanorc

Insert below lines at end of the nanorc file

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
## Config Files (.ini)
include "/usr/share/nano/ini.nanorc"
## Xorg.conf
include "/usr/share/nano/xorg.nanorc"
## CSS
include "/usr/share/nano/css.nanorc"
## XML
include "/usr/share/nano/xml.nanorc"
## Generic .conf
include "/usr/share/nano/conf.nanorc"
## PHP
include "/usr/share/nano/php.nanorc"

All done.

You should now be able to open PHP, CSS & XML files for example and see the new colours.

Posted: August 8th, 2011
Categories: Linux, Programming
Tags: , ,
Comments: 2 Comments.
Comments
Pingback from MEDOIX » Code Syntax Highlighting in VI (Linux Editor) - August 12, 2011 at 1:54 pm

[...] I recently wrote about how to enable syntax highlighting in the linux editor NANO. [...]

Pingback from Code Syntax Highlighting in VI (Linux Editor) | MEDOIX - January 26, 2012 at 7:30 am

[...] I recently wrote about how to enable syntax highlighting in the linux editor NANO. [...]