Syntax Highlighting in Nano

Being an astronomer my life at work quite often involves me using a commandline text editor. I’m a big fan of nano/pico and overwhelming prefer them to vi (I know this topic is easy the start a flame war – I’m just not one for vi, never could remember the commands etc). Now today my other half (being the geek that she is) wondered if I knew how todo syntax highlighting in nano since vi by default on her system does this and people were suggesting she did that. Me, I’m not one for syntax highlighting on the commandline (if I want that I just open up gedit/emacs)… but I thought this would be interesting to see if nano can, and indeed it can… so here is simply how to do it:
Put the following into ~/.nanorc
# Colour setup
include “/usr/share/nano/asm.nanorc” # Assembler
include “/usr/share/nano/sh.nanorc” # Bourne shell scripts
include “/usr/share/nano/c.nanorc” #C/C++
include “/usr/share/nano/groff.nanorc” # Groff
include “/usr/share/nano/html.nanorc” #HTML
include “/usr/share/nano/java.nanorc” # Java
include “/usr/share/nano/man.nanorc” # Manpages
include “/usr/share/nano/nanorc.nanorc” #Nanorc
include “/usr/share/nano/perl.nanorc” # Perl
include “/usr/share/nano/python.nanorc” # Python
include “/usr/share/nano/ruby.nanorc”# Ruby
include “/usr/share/nano/tex.nanorc” # TeX
and it is that simple!
Oh and some other useful settings to include:
set mouse # Enable mouse support, i.e. set the marker!
set boldtext


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: