.nanorc settings for Objective-C
For better or for worse, I have an affection for the
nano text editor
(the improved successor to
pico).
In general, I write my Objective-C code in Xcode,
but it's nice to have a command-line option at the ready.
Nano includes a simple, if relatively unsophisticated, way
to color code while you program, and I mocked up my own
custom coloring coding scheme for Objective-C after
not being able to find one for nano.
Below are the settings I have so far.
It's not a complete .nanorc file, but you can check out
a semi-current nanorc file here if it helps.
If anyone has suggestions, there is message board at the
bottom of the page, and it might be fun to tune this.
This color coding is meant for dark terminal screens.
I made all objects appear with a background color;
one for NS objects and a different one for custom objects.
Obviously, this doesn't always work, but the current scheme
works enough to make it fairly easy for my eyes to find
objects when looking at code.
Last note about nanorc color coding.
It's regex expressions, but has a few quirks, like no '?' characters.
It goes top to bottom, so finding ways to keep the list of
color coding commends small is a huge savings in terms of how
fast nanorc works. It can really slow down if you get too crazy.
##--------------------------------------------------------------------------------- objective-c
syntax "obj-c" "\.(c|h|m)$"
# available: white, blue, green, magenta, cyan, yellow, red
# objects: dark background, light text (for NSObjects?)
# messages: magenta # function: ?
# constant: white # structs: cyan
# strings: yellow # numbers: brightcyan
# comments: green # compiler: brightcyan
# syntax: braces, brackets, parenthesis: white
# math, comparisons, etc : ?
color white "[a-zA-Z0-9_]*( |\]|\[|,|\+\+)"
# Numbers:
color brightcyan "[\:\<\>=] {0,1}[0-9\.]*[;\) ]"
color brightcyan "[\[\:][0-9\.]*\]"
color white "\([a-zA-Z0-9_ ]*\)"
# Casts, types, structs, object instantiatives
color red "\<[A-Z_]{2,}\>"
color cyan "\((float|char|int|void|static|const|struct|id|BOOL|bool)\)"
color cyan " {0,1}(float|char|int|void|static|const|struct|id|BOOL|bool|return|MYSQL|MYSQL_[A-Z]*) "
color cyan "\((NSDecimal|NSPoint|NSRange|NSRect|NSSize)\)"
color cyan "NS[a-zA-Z0-9_]*\("
# Compiler directives:
color brightyellow "\<(if|while|do|else|case|switch)\>"
color brightcyan "^#( )*(define|import|include|ifn?def|endif|elif|else|if)"
color brightcyan "^@(implementation|interface|end)"
color magenta " [a-zA-Z0-9_]*\]"
color magenta " [a-zA-Z0-9_]*:"
color brightmagenta "[a-zA-Z0-9_]*\:\("
# Objects:
color white,blue "(self|super)"
color white,magenta "\[[a-zA-Z_][a-zA-Z0-9_]*"
color white,magenta "\*[a-zA-Z0-9_]*[;,]"
color white,blue "\[(self|super)"
color white,blue "\[NS[a-zA-Z]*"
color white "\[[a-zA-Z_][a-zA-Z0-9_]*\]"
color white " (&{1,2}|\|\||\+|\-|\*|\^{1,2}|/) "
color white "(>={0,1}|<={0,1}|==)"
color cyan "[a-zA-Z0-9]* \*"
#color cyan "( |\t)*[a-zA-Z0-9]*\("
# Finishing up with some corrections from effects of the above
#color brightblue "(NULL|nil|true|false|TRUE|FALSE)"
#color magenta " \*"
color white "[{};\<\>=]"
color white "(\[|\])"
color white "(\(|\))"
color white " \* "
#color white "[\+\-]"
color yellow "<[^= ]*>" "@{0,1}"(\\.|[^\"])*""
## This string is VERY resource intensive!!!
# color brightyellow start=""(\\.|[^\"])*\\( | )*$" end="^(\\.|[^\"])*""
color green "//.*"
color green start="/\*" end="\*/"
|
|