Skip to content

Instantly share code, notes, and snippets.

@NatWeiss
Created October 24, 2013 06:35
Show Gist options
  • Save NatWeiss/7132307 to your computer and use it in GitHub Desktop.
Save NatWeiss/7132307 to your computer and use it in GitHub Desktop.
A .nanorc file which automatically colors source code, scripts, diffs, etc.
#
# .nanorc
# colors: white, black, red, blue, green, yellow, magenta, cyan.
#
set autoindent
set historylog
set nohelp
set nowrap
set smooth
set tabsize 5
set multibuffer
#
# code
#
syntax "Code" ".*$"
# strings
color brightwhite ""(\\.|[^\"])*""
color brightwhite "'(\\.|[^\'])*'"
# php variables
color brightyellow "\$[A-Za-z0-9_\>-]*"
# comments
color green "//.*"
color green start="/\*" end="\*/"
icolor green "^[[:space:]]*#.*$"
icolor red "^[[:space:]]*#!\/.*$"
# diff
icolor brightwhite "^[[:space:]]*Index: .*$"
icolor brightwhite "^[[:space:]]*====.*$"
icolor yellow "^[[:space:]]*-.*$"
icolor yellow "^[[:space:]]*< .*$"
icolor brightyellow "^[[:space:]]*\+.*$"
icolor brightyellow "^[[:space:]]*> .*$"
# traling whitespace
color ,red "[[:space:]]+$"
#
# html
#
syntax "HTML" "\.html$"
color brightyellow start="<" end=">"
color red "&[^;[[:space:]]]*;"
#
# nanorc
#
syntax "nanorc" "\.?nanorc$"
## Possible errors and parameters
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
## Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>"
icolor green "^[[:space:]]*(set|unset|include|syntax)\>"
## Colors
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
## Strings
icolor white ""(\\.|[^"])*""
## Comments
icolor brightblue "^[[:space:]]*#.*$"
icolor cyan "^[[:space:]]*##.*$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment