Fruit Loops

Sam Hart

2007-08-28 18:08:47

People who know me know that after my 8+ years of being a Vi/Vim user I left that world of arcane commands and time wasted on endless configuration tweaking to use editors that got the fuck out of my way and just let me focus on editing. Well, one of the editors I do tend to use a lot now is Nano. However, there's been barriers preventing me from using Nano "full-time" (e.g., on everything I edit from source code to configuration files). Because of these barriers I was only using Nano when I wasn't otherwise at a desktop (where I was just using Kate). Specifically, the barriers for general Nano usage were:


The first problem is one I just kind of have to wait until Nano upstream fixes (mainly because I don't have time to get up to speed on Nano dev and hack on it myself). It has an easy workaround, but it's still an annoyance.

The second problem, however, was something I could do something about, and, due to recent frustrations with Kate, I was finally spurned into starting a Nano Python syntax highlighting rewrite.

What I've come up with is pretty good. It isn't perfect, but it is passable:


It's stored in the config section of http://dev.samhart.net/docs/ and I intend to keep it up to date there. Right now I'm just using the stock highlighting for other languages, but my specific changes for Python are in the .nano_syntax file. My .nanorc is there as well.

I think the big complaint I have about it now is it doesn't handle """ docstrings well. Nanorc syntax allows for things like:

color SOMECOLOR start="foo" end="bar"


So you find a lot of people suggesting something like the following for Python docstring comments:

color SOMECOLOR start="\"\"\"" end="\"\"\""

The problem is that something in this breaks the "end" tag. So the syntax highlighting for docstrings never end. My solution is just not to highlight them, but that's not so much of a solution as it is an admission of defeat.

Anyway, if you need a better Python syntax highlighting solution in Nano, I recommend checking mine out. It's not perfect, but it's better than the others I've tried.