Nano Syntax Highlighting

As a nano user I often get flack from those around me who use Vim about not having syntax highlighting. So, after taking this for some time I decided to find a way to add syntax highlighting to nano and to my surprise, it is actually already built in and simply not enabled.

Here is the simple, step-by-step process:

  1. Copy the /etc/nanorc file to ~/.nanorc (depending on your distribution this file may be located elsewhere)
  2. Open ~/.nanorc with your favorite text editor (in this case, odds are good it’ll be nano)
  3. Find the commented lines beginning with “include”
  4. Uncomment for the languages you want to have syntax highlighted in

Amazingly simple. I’m actually rather surprised it wasn’t enabled by default, but I suppose in the spirit of being a tiny text editor (hence the name) the overhead was left to an “as needed” basis.

There are a few languages not already included, but you can simply add them in yourself. I wanted to add PHP and found this link. The syntax files themselves are also editable. Allowing you to add in rules or change syntax colors.

About samurai

I like computers... A lot. So I tend to spend a lot of time doing varied things with them. Often you'll find me playing with Python or PHP, fighting with operating systems, ranting about some off-the-wall concept, or preparing for zombies.
This entry was posted in SamuraiNet Archive and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>