我想知道是否有一种方法可以为同一文件中的不同语言标签提供两种不同的标签颜色(美国的“颜色”)。
例如,假设我在同一个 .cfm 文件中具有 ColdFusion 代码和 HTML 代码。我可以将 ColdFusion 标签设为红色,将 HTML 标签设为蓝色吗?
例如,我们调用以下文件HelloWorld.cfm- 我可以给标签涂上不同的颜色吗?
<cfset myvar = "hello, world" />
<html>
<head>
<title>This is my title</title>
</head>
<body>
<div><cfoutput>#myvar#</cfoutput></div>
</body>
</html>
Thanks!
是的,只要您安装的语言定义可以将标签识别为具有不同的范围,您就可以编辑配色方案以使用特定颜色和其他样式来定位这些范围。
在包文件夹中,语言范围在已安装语言的 .tmLanguage 文件中定义,而样式在“配色方案 - 默认”文件夹中的 .tmTheme 文件中定义。
If you position your cursor inside a tag, and press shift+ctrl+alt+p (shift-cmd-p in OSX I think) the status bar will display the current scope. You can also copy this to the clipboard via the console with this command:
sublime.set_clipboard(view.syntax_name(view.sel()[0].b))
您可以使用此信息来创建样式,有点像 css 选择器,但使用 XML。例如我用这个冷熔封装我的自定义 .tmTheme 文件中有如下所示的范围选择器,用于区分 cf 标签和 HTML 标签。
<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>
更多信息:范围选择器.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)