Thursday, March 22, 2012

Dusting off nano

For a number of years, nano was my favorite text editor. It was easy, modeless, and had most of the features of you need. If doesn't compete with the heavyweights, vi and emacs, but is simple and elegant.

When I am wearing my programming hat, there are two killer features I need: brace matching and syntax highlighting. I was recently jarred by how much I had come to depend on syntax highlighting when opened a source file on a foreign computer where highlighting was not configured. I thought, how am I supposed to make sense of this? Then I remembered that I didn't always have highlighting and managed to get by.

Anyway, I dug into the current release of nano and found brace matching can be enabled with this .nanorc setting:
set matchbrackets "(<[{)>]}"

A matching brace can be found by putting the cursor on one and using Alt-].

Syntax highlighting has to be defined in the .nanorc file for each type of file. In Red Hat Linux and CentOS, a lot of languages are available to be included in the .nanorc file in /usr/share/nano/. For example,
## Ruby
include "/usr/share/nano/ruby.nanorc"
Go nano!

No comments:

Post a Comment