A Temporary Solution To <cfscript /> Syntax Highlighting In TextMate and E-TextEditor
I had a co-worker ask me recently - is there any syntax support for <cfscript /> in TextMate/E-TextEditor. In short - I don’t think so, or at least my Google searching didn’t reveal anything immediate. In lieu of going back with nothing - I decided to patch up a solution that would work in the mean time.
What I did was add an entry to the tmLanguage file for ColdFusion syntax - that adds JavaScript syntax highlighting to <cfscript /> blocks. It’s not perfect - but better than all one color.
To use - open up your ColdFusion bundle, and find the ColdFusion.tmLanguage file. Within the XML tree, paste the following snippet and reload your bundles. It doesn’t matter where you paste it so much - as long as it fits within the structure.
Enjoy
<dict>
<key>begin</key>
<string>(?:^\s+)?<((?i:cfscript))\b(?![^>]*/>)</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.tag.cfm</string>
</dict>
</dict>
<key>end</key>
<string></((?i:cfscript))>(?:\s*\n)?</string>
<key>name</key>
<string>meta.tag.any.cfm</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#tag-stuff</string>
</dict>
<dict>
<key>begin</key>
<string>(?<=>)</string>
<key>end</key>
<string>(?=</(?i:cfscript))</string>
<key>name</key>
<string>meta.tag.any.cfm</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>source.js</string>
</dict>
</array>
</dict>
</array>
</dict>