Home Download Buy Blog Forum Support

C# tmLanguage help!

C# tmLanguage help!

Postby xAbsolut Zero on Sat Feb 22, 2014 12:25 am

Hello, New user here although I have been enjoying SublimeText3
for a long time now. A preface to my issue is that I am terrible
with Regular Expressions, and I have been having a crazy time trying
to get this to work.

Anyway I have used PackageResourceManager to extract and modify my
C#.tmLanguage & Monokai.tmTheme files to try and add something simple.
(or so I thought)

All I want is for the semicolon (;) to denote end of statements to
be highlighted in orange(#E5C100)

This has proved to be a difficult task.

so far, I have tried many different things, and tried pasting the
code block in different <key>patterns</key> sections of the tmLanguage file,
but that either doesnt change anything or breaks the whole file.

I've tried changing the scope as well, but when I do that even changing
the corresponding scope in the tmTheme seems to make it not work at all.

anyways sorry for the wall of text, heres the code I have for the
tmLanguage file

C#.tmLanguage:19
<dict>
<key>match</key>
<string>\z(;)|\);|;$</string>
<key>name</key>
<string>semicolon.cs</string>
</dict>

Which is placed just after the first array after the <key>patterns</key> tag

The corresponding tmTheme, placed right before the ending array & uuid;
Monokai.tmTheme:392
<dict>
<key>name</key>
<string>semicolon</string>
<key>scope</key>
<string>semicolon</string>
<key>settings[/color]</key>
<dict>
<key>foreground</key>
<string>#E5C100</string>
</dict>
</dict>


This kind of works, but it doesn't work inside of classes, or more specifically,
inside anything that is wrapped with a curly brace. (which is most of the code)

For Example
HelloWorld.cs
using System;
class HelloWorld
{
static void Main()
{
//Use the System Console object
Console.WriteLine("Hello World! "); //<-Here is where I need it to be #E5C100

}
}
//something outside of classes will work, even though this syntax is incorrect
private static string OutsideCurlys;


I am at a loss trying to figure this out, I have searched online extensivley
to try and find a solution or a pre made .tmLanguage file that will work,
but is nowhere to be found.

I have a thought that the problem might be somewhere in the Regexp on line 158 of C#.tmLanguage

C#.tmLanguage:158
<key>begin</key>
<string>([^;]?=\w?[\w\s]*(?:class|struct|interface|enum)\s+\w+)</string>
<key>end</key>
<string>}</string>
<key>endCaptures</key>

But I don't know exactly how to modify that particular Regexp without messing up other functionality.

Anyone who took the time to read this post I applaud you and extend my greatest gratitude
for anyone who might be able to help me with this. I know it's something small
and rather insignificant but I am OCD like this and I think it would be easier
for debugging if I happen to miss a (;) it would be easier to notice with
it highlighted.

If there is no solution to this problem then so be it but I thought I would
reach out to a community and see what someone else might have to say about it.
Thanks again and have a great day, sorry for the wall of text again.
xAbsolut Zero
 
Posts: 2
Joined: Fri Feb 21, 2014 10:24 pm

Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 51 guests