Nano Patches

nano is a console-based text editor.

The --displaysyntax and -P command line options display information about syntaxes. Each line is prefixed with the syntax name so a specific syntax can be found with grep.

nano -P |grep "^html:"
The "none" syntax name is reserved to disable highlighting from the command line. [1.3.9]

nano -Y none [<filename>]

The "default" syntax name is reserved for the default syntax. It can also be used to override a file's syntax with the default syntax. [1.3.9]

nano -Y default [<filename>]


Directives for use in /etc/nanorc and ~/.nanorc files.

# <text>

Comment - ignores text.

SET <name> <value>

Sets option to value.

UNSET <name>

Unsets option value.

SYNTAX "name" ["extension"...]
name = syntax description
extension = zero or more regular expressions


Throws error if syntax name is already defined

Creates a syntax definition for filenames matching the extension expressions. Overwrites previously defined syntaxes if used more than once with the same name. Extensionless syntaxes can only be used with the syntax override option (-Y).

DEFAULT-SYNTAX

1.3.9 uses [SYNTAX "default"]

Throws error if default syntax is already defined

Creates a syntax definition for all files that don't have a syntax. Overwrites previously defined default syntaxes if used more than once.

INCLUDE "file"

Requires the nano-1.3.0-color-0 patch

Loads default-color, color and icolor directives from another file.

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.

DEFAULT-COLOR <fgcolor>[,<bg-color>]
fgcolor = green, red, blue, white, yellow, cyan, magenta or black
bgcolor = green, red, blue, white, yellow, cyan, magenta or black

fgcolor may also be prefixed with "bright" (i.e. "brightred").


Requires the nano-1.3.0-color-2 patch

Highlights all unmatched text with this color. Useful for highlighting errors in simple syntaxes, such as nanorc. Must be used before all color directives in a syntax and is not allowed in subcolor blocks.

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.

COLOR <fgcolor>[,<bg-color>] "regex"...
COLOR <fgcolor>[,<bg-color>] start="regex1" end="regex2"
fgcolor = green, red, blue, white, yellow, cyan, magenta or black
bgcolor = green, red, blue, white, yellow, cyan, magenta or black

fgcolor may also be prefixed with "bright" (i.e. "brightred").

regex = one or more single-line regular expressions
regex1 = beginning of a multi-line regular expression
regex2 = ending of a multi-line regular expression


Highlights all matches.

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.

ICOLOR ...
Same parameters as COLOR.


Case-insensitive version of COLOR. [1.3.8]

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.

NEXT-COLOR <fgcolor>[,<bg-color>] "regex"...
fgcolor = green, red, blue, white, yellow, cyan, magenta or black
bgcolor = green, red, blue, white, yellow, cyan, magenta or black

fgcolor may also be prefixed with "bright" (i.e. "brightred").

regex = one or more single-line regular expressions


Requires the unfinished nano-1.3.0-color-3 patch

Match must begin at current position, following a previous match, and only one match per line will be highlighted.

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.

NEXT-ICOLOR ...
Same parameters as NEXT-COLOR.


Requires the unfinished nano-1.3.0-color-3 patch

Case-insensitive version of NEXT-COLOR.

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.

{

Requires the unfinished nano-1.3.0-color-3 patch

Opens a subcolor block, must follow one of the color directives.

The following example highlights the foo's in "foo bar" and "foo barbar" with red and all instances of bar with blue.

color red "foo "
{
	color blue "bar"
}


Subcolors are currently only supported on single-line expressions and may only contain single-line expressions.

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.

}

Requires the unfinished nano-1.3.0-color-3 patch

Closes a subcolor block.

Only valid when used in a SYNTAX or DEFAULT-SYNTAX.