Home Download Buy Blog Forum Support

Syntax specific highlighting with Sublime Text 2

Syntax specific highlighting with Sublime Text 2

Postby NotJustClarkKent on Sun Feb 19, 2012 12:01 am

I'm wondering if there is a way to have two different tag colours ("colors" for those in the US) for different language tags in the same file.

For example, lets say I have ColdFusion code and HTML code in the same .cfm file. Could I make the ColdFusion tags red and the HTML tags Blue?

For instance, lets call the below file HelloWorld.cfm - could I colour the tags differently?

Code: Select all
<cfset myvar = "hello, world" />
<html>
<head>
  <title>This is my title</title>
</head>
<body>

<div><cfoutput>#myvar#</cfoutput></div>

</body>
</html>


NOTE: I also posted this question on Stack Overflow: http://stackoverflow.com/questions/9345222/syntax-specific-highlighting-with-sublime-text-2

Thanks!
NotJustClarkKent
 
Posts: 2
Joined: Sun Feb 19, 2012 12:00 am

Re: Syntax specific highlighting with Sublime Text 2

Postby nick. on Sun Feb 19, 2012 2:40 am

Yes, this is possible through includes in the language definition. Have a look here: http://manual.macromates.com/en/languag ... #rule_keys
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Syntax specific highlighting with Sublime Text 2

Postby atomi on Sun Feb 19, 2012 5:55 am

What you need to do is add to your tmTheme file color rules for


Code: Select all
punctuation.definition.tag.begin.cfml
entity.name.tag.cf
punctuation.definition.tag.end.cfml


Im not sure if all tags are defined. What I'll try to do is match any tag that starts with "cf" as entity.name.tag.cf.
You'll get some initially but when I update entity.name.tag.cf should color all cf tags.

HTH

Edit: grammar
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Syntax specific highlighting with Sublime Text 2

Postby NotJustClarkKent on Sun Feb 19, 2012 6:05 am

Thanks atomi - I'll give that a shot! :)
NotJustClarkKent
 
Posts: 2
Joined: Sun Feb 19, 2012 12:00 am


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot], prmaple and 14 guests