Special syntax highlighting with Sublime Text 2

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

For example, let's say I have ColdFusion code and HTML code in the same .cfm file. Can I make ColdFusion tags red and HTML Blue tags?

For example, you can call the file below HelloWorld.cfm - is it possible to color tags in different ways?

<cfset myvar = "hello, world" /> <html> <head> <title>This is my title</title> </head> <body> <div><cfoutput>#myvar#</cfoutput></div> </body> </html> 

Thank!

+5
sublimetext
Feb 18 2018-12-18T00:
source share
2 answers

Yes, as long as tags can be identified as having different scopes with language definitions set, you can change your color scheme to target these areas with specific colors and other styles.

In the package folder, the language areas are defined in the .tmLanguage files for the installed languages, and the styles are defined in the .tmTheme files in the "default color scheme" folder.

If you place the cursor inside the tag and press shift + ctrl + alt + p ( shift - cmd -p in OSX, I think), the status bar displays the current volume. You can also copy this to the clipboard via the console with this command:

 sublime.set_clipboard(view.syntax_name(view.sel()[0].b)) 

You can use this information to create your own styles, a bit like css selectors, but with XML. For example, I use this Coldfusion package and I have the area selectors shown below in my .tmTheme file to distinguish cf tags from HTML tags.

 <dict> <key>name</key> <string>Tag name</string> <key>scope</key> <string>entity.name.tag</string> <key>settings</key> <dict> <key>background</key> <string>#D8D0B6</string> <key>fontStyle</key> <string>bold</string> <key>foreground</key> <string>#647A4F</string> </dict> </dict> <dict> <key>name</key> <string>CF tag name</string> <key>scope</key> <string>entity.name.tag.conditional.cfml, entity.name.tag.declaration.cfml, entity.name.tag.other, entity.name.tag.cf, entity.name.tag.inline.other.cfml</string> <key>settings</key> <dict> <key>background</key> <string>#D8D0B6</string> <key>fontStyle</key> <string>bold</string> <key>foreground</key> <string>#990033</string> </dict> </dict> 

Learn more about area selectors .

+21
Feb 19 '12 at 11:08
source share

I updated ColdFusion.tmLanguage so that you need to target entity.name.tag.cf to color all entity.name.tag.cf tags. You can also target specific tags, for example entity.name.tag.cf.script or entity.name.tag.cf.query for cfscript and cfquery respectively. NTN

+4
Feb 20
source share



All Articles