[R] nano syntax highlighting for R

Mike Miller mbmiller+l at gmail.com
Sun Mar 14 02:34:44 CET 2010

Nano is Free Software and a nice intro text editor.  It also starts up 
very quickly and has good syntax highlighting functionality, so it makes a 
nice file viewer.  The syntax highlighting is configured in the ~/.nanorc 
file.  See the attached code and screenshot.

I was looking for good nano syntax highlighting code for R when I found by 
Stephen Haptonstahl's code here:


He is happy for others to use the code, modify it and distribute it.  My 
edited version of his code is attached.  To use it, just append it to your 
~/.nanorc file.  There's also a systemwide way to use it, but I don't know 
offhand.  To use nano in a view-only mode, just use the -v option to turn 
off editing functionality:

nano -v file.R

The .R file extension will cause Nano to use the R syntax highlighting, 
but it can also be triggered with the -Y option:

nano -v -Y R file.whatever

Of course, nano also is an editor, so just drop the -v option if you want 
to edit a file.

The screenshot looks pretty nice now (I'm using xterm with white on black 
and haven't tested with black on white), but I'm sure it can be improved 
further.  I don't have time to work on it much now, but maybe someone else 
will want to pick it up.


Michael B. Miller, Ph.D.
Bioinformatics Specialist
Minnesota Center for Twin and Family Research
Department of Psychology
University of Minnesota
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: R_nanorc.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100313/f9e51f27/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nano_R.png
Type: image/png
Size: 35111 bytes
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100313/f9e51f27/attachment.png>

More information about the R-help mailing list