Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Improved syntax highlighting for GNU nano

branch: master
Octocat-spinner-32 examples Add support for Java properties files April 04, 2014
Octocat-spinner-32 mixins Make lint patterns more generic and add hook for appending custom rules August 16, 2013
Octocat-spinner-32 .gitignore Add build.mk March 12, 2013
Octocat-spinner-32 Makefile Add support for Java properties files April 04, 2014
Octocat-spinner-32 README.md Fix some broken links in README.md April 22, 2014
Octocat-spinner-32 awk.nanorc Use +TODO mixin for various languages November 28, 2012
Octocat-spinner-32 c.nanorc Formatting May 03, 2013
Octocat-spinner-32 cmake.nanorc Add boolean pattern to cmake.nanorc March 24, 2013
Octocat-spinner-32 coffeescript.nanorc Add (incomplete) support for CoffeeScript October 07, 2012
Octocat-spinner-32 colortest.nanorc Add color test to example files November 28, 2012
Octocat-spinner-32 csharp.nanorc Improvements to C# nanorc April 18, 2013
Octocat-spinner-32 css.nanorc Add "opacity" to CSS keywords February 01, 2013
Octocat-spinner-32 cython.nanorc Add "inline" keyword to cython.nanorc November 27, 2012
Octocat-spinner-32 default.nanorc Remove main.nanorc and only install an includable syntax file July 31, 2013
Octocat-spinner-32 dot.nanorc Add syntax and example files for the Graphviz DOT language December 26, 2012
Octocat-spinner-32 email.nanorc Make first level email quotes the same colour as GMail July 13, 2012
Octocat-spinner-32 git.nanorc Fix comment and lint highlighting in git.nanorc August 03, 2013
Octocat-spinner-32 glsl.nanorc Add glsl.nanorc April 13, 2013
Octocat-spinner-32 go.nanorc Don't allow escaped delimiters in Go backtick strings January 10, 2013
Octocat-spinner-32 html.nanorc Formatting May 03, 2013
Octocat-spinner-32 ini.nanorc Add "header" pattern to ini.nanorc April 22, 2013
Octocat-spinner-32 inputrc.nanorc Add highlighting for escaped characters in inputrc files August 30, 2012
Octocat-spinner-32 java.nanorc Replace +GOTO mixin with more general JUMP: type December 02, 2012
Octocat-spinner-32 javascript.nanorc Add +FUNCTION mixin to javascript.nanorc December 11, 2012
Octocat-spinner-32 json.nanorc Convert remaining GNU regex extensions to strict POSIX ERE October 03, 2012
Octocat-spinner-32 keymap.nanorc Merge Xmodmap syntax into keymap.nanorc November 28, 2012
Octocat-spinner-32 kickstart.nanorc Convert remaining GNU regex extensions to strict POSIX ERE October 03, 2012
Octocat-spinner-32 ledger.nanorc Use ledger syntax for files simply called "ledger" (not just *.ledger) January 08, 2013
Octocat-spinner-32 lisp.nanorc Use Lisp highlighting for zile configuration files November 30, 2012
Octocat-spinner-32 lua.nanorc Don't highlight escapes in Lua long strings May 14, 2013
Octocat-spinner-32 makefile.nanorc Add extra COMMENT pattern to makefile.nanorc April 07, 2013
Octocat-spinner-32 man.nanorc Use colour scheme for man.nanorc August 21, 2012
Octocat-spinner-32 markdown.nanorc Convert remaining GNU regex extensions to strict POSIX ERE October 03, 2012
Octocat-spinner-32 mixins.sed Replace +GOTO mixin with more general JUMP: type December 02, 2012
Octocat-spinner-32 mpdconf.nanorc Add basic mpd.conf highlighting October 31, 2012
Octocat-spinner-32 nanorc.nanorc Add header pattern for nanorc.nanorc July 31, 2013
Octocat-spinner-32 nginx.nanorc Improve nginx.nanorc January 05, 2013
Octocat-spinner-32 patch.nanorc Remove "magic" headers June 05, 2012
Octocat-spinner-32 peg.nanorc Fix comment pattern in peg.nanorc May 18, 2013
Octocat-spinner-32 php.nanorc Improve PHP header matching August 23, 2013
Octocat-spinner-32 pkg-config.nanorc Convert some GNU regular expression extensions to strict POSIX ERE October 03, 2012
Octocat-spinner-32 pkgbuild.nanorc Fix file matching patterns in pkgbuild.nanorc November 27, 2012
Octocat-spinner-32 po.nanorc Replace duplicated comment patterns with theme macros August 25, 2012
Octocat-spinner-32 privoxy.nanorc Add "tolerate-pipelining" to privoxy.nanorc April 07, 2013
Octocat-spinner-32 properties.nanorc Add support for Java properties files April 04, 2014
Octocat-spinner-32 python.nanorc Fix Python operators January 10, 2013
Octocat-spinner-32 rpmspec.nanorc Convert remaining GNU regex extensions to strict POSIX ERE October 03, 2012
Octocat-spinner-32 ruby.nanorc Use Ruby syntax highlighter for Rakefiles May 22, 2013
Octocat-spinner-32 sed.nanorc Convert remaining GNU regex extensions to strict POSIX ERE October 03, 2012
Octocat-spinner-32 shell.nanorc Rename sh.nanorc to shell.nanorc July 31, 2013
Octocat-spinner-32 sql.nanorc Add "INTEGER" type to sql.nanorc May 18, 2013
Octocat-spinner-32 systemd.nanorc Add support for systemd .{timer|mount|slice|target|path} units February 09, 2014
Octocat-spinner-32 tex.nanorc Add SECTION pattern to tex.nanorc April 05, 2013
Octocat-spinner-32 theme.sed Add TAG: and ATTRIBUTE: tokens and use for html.nanorc December 26, 2012
Octocat-spinner-32 vala.nanorc Add "using" keyword to vala.nanorc July 31, 2013
Octocat-spinner-32 vi.nanorc Make filename matching pattern in vi.nanorc more specific November 08, 2012
Octocat-spinner-32 xml.nanorc Fix named entity highlighting and allow hexadecimal entities in XML/HTML December 26, 2012
Octocat-spinner-32 xresources.nanorc Change xresources.nanorc syntax identifier to match the filename November 28, 2012
Octocat-spinner-32 yaml.nanorc Convert remaining GNU regex extensions to strict POSIX ERE October 03, 2012
Octocat-spinner-32 yum.nanorc Add more yum configuration file variables September 21, 2012
README.md

Unmaintained

I am no longer using nano as my editor and hence have little motivation to continue working on this project. It remains available on GitHub for archival purposes only.

Everything in the repository is in the Public Domain. Feel free to fork it and/or use the files for any purpose.

P.S. I highly recommend dex as a simple but much more capable editor.


Description

The syntax highlighting definitions that come bundled with nano are of pretty poor quality. This is an attempt at providing a good set of accurate syntax definitions to replace and expand the defaults.

Installation

Using make install will install the syntax definitions to the ~/.nano/syntax/ directory.

To enable highlighting for all languages after installation, add the following command to your ~/.nanorc file:

include ~/.nano/syntax/ALL.nanorc

To enable only a subset of languages, include them individually:

include ~/.nano/syntax/c.nanorc
include ~/.nano/syntax/python.nanorc
include ~/.nano/syntax/sh.nanorc
# ...

If you prefer to install to a location that all users can access, using sudo make install-global will install to /usr/local/share/nano/. Syntax files installed under this directory can then be included in either /etc/nanorc or any user's personal ~/.nanorc.

Note: If your terminal text color isn't black, you'll need to specify it when installing, using make install TEXT=color, where color must be one of: red, green, yellow, blue, magenta, cyan or white.

After installation, the various source code samples in the examples directory can be used to check that highlighting is working correctly. If it doesn't work as expected, see the FAQ below.

Theme System

All *.nanorc files are passed through mixins.sed and theme.sed before installation. These scripts allow rules to be specified in terms of token names or mixins, instead of hard-coded colors.

For example, the following named rule:

TYPE: "int|bool|string"

becomes:

color green "int|bool|string"

and the following "mixin":

+BOOLEAN

becomes:

color brightcyan "\<(true|false)\>"

This system helps to keep colors uniform across different languages and also to keep the definitions clear and maintainable, which is something that becomes quite awkward using only plain nanorc files.

Note: if ~/.nanotheme exists it will be used as a custom theme, in place of theme.sed. A custom theme may also be specified by installing with make THEME=your-custom-theme.sed. Themes must be valid sed scripts, defining all color codes found in theme.sed in order to work correctly.

FAQ

Why does syntax highlighting only work for a subset of supported files?

There appears to be a bug in older versions of nano that causes highlighting to fail when /etc/nanorc and ~/.nanorc both contain syntax rules. The usual workaround is to remove all syntax and include commands from one file or the other, or to use a newer version of nano.

Why do I get weird errors when running nano < 2.1.5 on *BSD systems?

In order to reliably highlight keywords, this projects makes heavy use of the GNU regex word boundary extensions (\< and \>). BSD implementations also have these extensions but use a different, incompatible syntax ([[:<:]] and [[:>:]]). Since version 2.1.5, nano can automatically translate the GNU syntax to BSD syntax at run-time, but for the benefit of people running a pre-2.1.5 version of nano on OS X or *BSD, the .nanorc file itself can be translated by installing with make BSDREGEX=1.

Why not use \s instead of the verbose [[:space:]] pattern?

Because nano compiles against the platform's native regex library and some platforms don't support \s (as it's not required by POSIX ERE).

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Something went wrong with that request. Please try again.