BlogSyntax Highlighting in Nano Syndicate content

Tue, 04/10/2007 - 17:14

When I’m messing around with config files on the command line my editor of choice is Nano. It’s simple, fast and pretty much straight forward. You don’t have to learn any commands and can use keyboard shortcuts just like in GUI programs.


Today I had a look on the project website and saw that there are tons of settings which I really missed before. Just have a look into your /etc/nanorc for a default config file with all settings and their default values. Here are those I like most:

  • smooth (scrolling)
  • autoindent
  • mouse (though I use it rarely)
  • smarthome
  • tabsize (8 is far to much, I love 4)
Syntax Highlighting

Yes! Nano supports syntax highlighting! And I never knew it, but heck - it’s never to late. Not for neat features like this one, though I really wonder why this is not activated by default…

In the aforementioned /etc/nanorc are already some default languages which just wait to be commented out. You might also want to have a look into /usr/share/nano, there are some languages you can include in your nanorc file with:

include “/usr/share/nano/html.nanorc”

Additionally I found some more languages on the gentoo wiki. And of course I’ll post any homebrew syntax files in my Snippets section.

my syntax highlighting files


You are my hero :) Fri, 02/28/2014 - 14:44 — ElDiablo (not verified)

You are my hero :)

thx for the .ini file :) Wed, 02/12/2014 - 02:05 — yummibunny (not verified)

thx for the .ini file :)

Was looking at nanorc, Fri, 05/03/2013 - 01:28 — Anonymous (not verified)

Was looking at nanorc, reading, and came across the git repository below. It is really cool how the author handles the highlighting to keep it consistent across languages. He also has nice key bindings.

Yes, nano supports syntax Mon, 01/28/2013 - 15:42 — Ölbaum (not verified)

Yes, nano supports syntax highlighting and it’s retarded. I love having all my variables unappear in white over my white background.

Yea what the hell is that Mon, 03/25/2013 - 06:38 — Huh (not verified)

Yea what the hell is that about? Something’s it decides should be red, some white, totally random as far as I can tell. Anyone have a fix for this?

Well, two keystrokes, one Sun, 10/18/2009 - 14:16 — Godric (not verified)

Well, two keystrokes, one forth and one back. ;-D

Milian: thx for .ini syntax file. ;-)

I always knew that Nano could Fri, 08/14/2009 - 03:50 — Raven Morris (not verified)

I always knew that Nano could do syntax highlighting, or at least I had heard that it could. I decided to go try it out today, thanks for the article.

You should be using :x instead of :wq … Save yourself one keystroke. :-P

Bloody hell nano supports Tue, 08/04/2009 - 23:44 — Jon (not verified)

Bloody hell nano supports syntax highlighting? Maybe I’ll loathe it a little less on those machines where I’m not allowed to put export EDITOR=vi in root’s .bashrc once I’ve edited that nanorc. I’ll never stop myself hitting :wq though, then growling as I have to go back and delete it before pressing Ctrl X

Post new comment

  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <pre>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options