Sublime Forum

Syntax highlight reg ex error?

#1

Hello all, I’m trying to create a custom syntax highlighting rule for sublime text 2. Here is what I want:

/***
special comment goes here
***/

I just want the above to be a different color than the default comment color. I’m using javascript so I added this to the JavaScript.tmLanguage file:

            <dict>
		<key>begin</key>
		<string>/\*{3}</string>
		<key>captures</key>
		<dict>
			<key>0</key>
			<dict>
				<key>name</key>
				<string>comment.block.special.js</string>
			</dict>
		</dict>
		<key>end</key>
		<string>\*{3}/</string>
		<key>name</key>
		<string>comment.block.special.js</string>
	</dict>

and this doesn’t seem to work. However if I have:

/aaa
special comment goes here
bbb/

and this added to the tmLanguage file:

begin
/a{3}
captures

0

name
comment.block.special.js


end
b{3}/
name
comment.block.special.js

Then the lines get the styling specified by comment.block.special.js. I’m pretty sure that regular expression is correct and I have tested it in some online editors and it matches correctly. Is there something I am doing wrong?

Thanks!

0 Likes

#2

Maybe:

<key>match</key> <string>/(\*){3}</string>

I think it may mess up on repeating the escaped asterisk, could be wrong though.

Edit: Actually your code as posted works just fine for me. Try moving it to the top of the syntax file and see it if works for you. Then try using ScopeHunter to see what is matching instead of your text (probably /* … */, if your addition comes after it in the syntax file).

0 Likes

#3

Moving it to the top of the syntax file worked for me too! Thanks for the speedy response!

0 Likes