Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Has anyone got (or can point in the direction of) a nanorc file that contains syntax highlighting for C# and/or ASP.Net?

share|improve this question
    
You probably won't find one for ASP seeing as how it's typically a Windows language and up until recently wasn't able to function on Linux Machine. –  Marco Ceppi Aug 13 '10 at 13:47
    
Duplicated unix.stackexchange.com/questions/454/… and –  Marco Ceppi Aug 13 '10 at 20:38
    
Marco - duplicated because not all Ubuntu stackexchange people have access to the Unix one cos its in private beta. Also, some people on the Unix one may use distros other than Ubuntu. –  Rob Cowell Aug 14 '10 at 9:34
    
@Marco Not a duplicate for the same reason the @Rob mentioned. –  jrg Jun 5 '11 at 18:44
add comment

2 Answers

up vote 1 down vote accepted

I don't know of an existing highlight for C# in Nano but you could write your own. The syntax for syntax highlighting is pretty simple. Here's the one for Java (which will be very similar to a C# syntax - mainly just different keywords):

## Here is an example for Java.
##
syntax "java" "\.java$"
color green "\<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\>"
color red "\<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\>"
color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>"
color red ""[^"]*""
color yellow "\<(true|false|null)\>"
color blue "//.*"
color blue start="/\*" end="\*/"
color brightblue start="/\*\*" end="\*/"
color ,green "[[:space:]]+$"

That's sitting in /usr/share/nano/java.nanorc. If you write your own you'll need to link to it from /etc/nanorc. There may be a user-local version of both too but I don't know it.

Edit: for ASP.NET you could just clone the HTML one and alter the syntax slightly to handle ASP.NET tags. It won't be perfect (it won't handle <script runat="server">...</script> contents for example) but it should be better than a poke in the eye with a sharp stick.

share|improve this answer
    
Ok, I'll make a start, was looking for a pre-made one cos I'm lazy ;-) –  Rob Cowell Aug 14 '10 at 9:35
add comment

Replicating my answer at: http://unix.stackexchange.com/questions/454/nano-syntax-highlighting-for-c-and-or-asp-net/1252#1252

Using the Java example from http://wiki.linuxhelp.net/index.php/Nano_Syntax_Highlighting, you can try to add something like the following into your ~/.nanorc:

syntax "C# source" "\.cs$"
color green "\<(bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|new|object|short|ushort|string|base|this|void)\>"
color red "\<(as|break|case|catch|checked|continue|default|do|else|finally|fixed|for|foreach|goto|if|is|lock|return|switch|throw|try|unchecked|while)\>"
color cyan "\<(abstract|class|const|delegate|enum|event|explicit|extern|implicit|in|internal|interface|namespace|operator|out|override|params|private|protected|public|readonly|ref|sealed|sizeof|static|struct|typeof|using|virtual|volatile)\>"
color red ""[^\"]*""
color yellow "\<(true|false|null)\>"
color blue "//.*"
color blue start="/\*" end="\*/"
color brightblue start="/\*\*" end="\*/"
color brightgreen,green " +$"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.