Customizing nano

I’ve always loved using nano instead of the more powerful (read complex) console based text editors, despite the ribbing my co-workers give me.

To most hardcore command line geeks, nano is an upstart that’s too short on features to suit all of their needs. Emacs and vi are pretty much operating systems unto themselves, w/ tons of powerful features that serve the needs of pretty much anyone who relies upon them to be their one-and-only text editor. In Mac OS X, however, there are quite a few gui-based text editors that focus on being … well, text editors. For Windows users, if you use Notepad++, you know what I mean. With my hardcore text editing needs met by TextMate, I’ve been quite satisfied to get by with everything that nano offers.

Sorta.

Well, that’s not quite fair. It does every bit of simple text editing work that I ask of it. The tweaks I’m about to talk about don’t really add a whole lot of functionality, they just make nano a wee bit nicer to work with.

So to start with, you’ll want to edit your nano configuration file, which is located in your home folder.


nano ~/.nanorc

This opens it up for editing. The syntax highlighting files that I’ve added at the bottom of my .nanorc are all taken from examples I’ve found on the web. I’ll add the contents of each of them as sub-documents to this page in the near future.


#Behavior and Appearance Tweaks
set autoindent #primarily for coding
set smooth #arrowing down by one line at a time instead of a page
set tabsize 3
set const #shows your cursor position in menu bar
set morespace #use the blank line below the titlebar as extra editing space
set matchbrackets "(<[{)>]}" #more coding options
set mouse #mouse support
set punct "!.?" #sets the characters treated as closing punctuation when justifying paragraphs
set tabstospaces #converts typed tabs to spaces

#Syntax highlighting files
include "/Users/Shared/Documents/nano/html.nanorc"
include "/Users/Shared/Documents/nano/css.nanorc"
include "/Users/Shared/Documents/nano/sh.nanorc"
include "/Users/Shared/Documents/nano/php.nanorc"
include "/Users/Shared/Documents/nano/py.nanorc"
include "/Users/Shared/Documents/nano/c.nanorc"
include "/Users/Shared/Documents/nano/tex.nanorc"
include "/Users/Shared/Documents/nano/groff.nanorc"
include "/Users/Shared/Documents/nano/perl.nanorc"
include "/Users/Shared/Documents/nano/java.nanorc"
include "/Users/Shared/Documents/nano/ebuild.nanorc"
include "/Users/Shared/Documents/nano/makefile.nanorc"
include "/Users/Shared/Documents/nano/js.nanorc"
include "/Users/Shared/Documents/nano/sql.nanorc"
include "/Users/Shared/Documents/nano/lua.nanorc"

Leave a Reply

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