Nano
is a popular, user-friendly text editor for Linux which runs in console mode, without the need of an X server.
By default, Nano comes with syntax highlighting for programming languages disabled, however it provides default
rules for several languages like Perl, Python or C, among others. These highlighting definitions are kept inside
the /usr/share/nano/ directory, and a file with rules corresponds to each language.
For example, ls /usr/share/nano/ will show the following output on my system, which has Nano 2.0.7 installed:
In order to enable syntax highlighting in Nano based on one of these files, edit the ~/.nanorc file (or create it
if it doesn't exist), where ~ is your home directory, and add lines like this:
These three lines will include the files c.nanorc, perl.nanorc and sh.nanorc,
which will define highlighting
rules for C, Perl and Bash respectively. This can also be accomplished by copying the contents of one file
directory into ~/.nanorc. For example:
This will append the contents of /usr/share/nano/c.nanorc at the end of ~/.nanorc.
You can also search on Google
for other rules, which fit better with your taste (e.g. provide different colors or are more precise).
For example, ls /usr/share/nano/ will show the following output on my system, which has Nano 2.0.7 installed:
debian$ ls /usr/share/nano/ asm.nanorc java.nanorc patch.nanorc ruby.nanorc c.nanorc man.nanorc perl.nanorc sh.nanorc groff.nanorc mutt.nanorc pov.nanorc tex.nanorc html.nanorc nanorc.nanorc python.nanorc nano-menu.xpm
include "/usr/share/nano/c.nanorc" include "/usr/share/nano/perl.nanorc" include "/usr/share/nano/sh.nanorc"
cat /usr/share/nano/c.nanorc >> ~/.nanorc