2016-04-21 103 views
2

我知道如何改变javascript和CSS的突出显示颜色。我添加到我的积极tm.Theme文件<array></array>之间的字符串:Sublime Text 3中的不同突出显示JS和CSS

<dict> 

    <key>name</key> 

    <string>Embedded source</string> 

    <key>scope</key> 

    <string>text source, string.unquoted</string> 

    <key>settings</key> 

    <dict> 

    <key>background</key> 

    <string>#804A7D99</string> 

    </dict> 

    </dict> 

结果:

Violet background

但如何让JS的背景和CSS不同,这是更方便在小地图上引导?例如:

JS - 蓝色

Blue background

CSS - 绿

Green background

感谢。

+0

我注意到你在过去几天一直在寻找色彩方案。你正在开发一个版本还是只是你的个人设置? – Enteleform

+0

另外 - 请提供[** Gist **](https://gist.github.com/)或[** PasteBin **](http://pastebin.com/)代码样本与您的问题进行测试解决方案更易于回答问题。 – Enteleform

回答

2

enter image description here

 

包括在你的tmTheme文件来处理混合JSCSS,& HTML下面的代码。

<dict> 
     <key>name</key> 
     <string>JS_Source</string> 
     <key>scope</key> 
     <string>source.js.embedded.html</string> 
     <key>settings</key> 
     <dict> 
      <key>background</key> 
      <string>#2D6A73</string> 
      <key>foreground</key> 
      <string>#7B91B9</string> 
     </dict> 
    </dict> 

    <dict> 
     <key>name</key> 
     <string>CSS_Source</string> 
     <key>scope</key> 
     <string>source.css.embedded.html, meta.attribute-with-value.style.html source.css</string> 
     <key>settings</key> 
     <dict> 
      <key>background</key> 
      <string>#2D7333</string> 
      <key>foreground</key> 
      <string>#7B91B9</string> 
     </dict> 
    </dict> 

    <dict> 
     <key>name</key> 
     <string>HTML_Text</string> 
     <key>scope</key> 
     <string>text.html</string> 
     <key>settings</key> 
     <dict> 
      <key>background</key> 
      <string>#783727</string> 
      <key>foreground</key> 
      <string>#7B91B9</string> 
     </dict> 
    </dict> 

 

正如在评论中提到由@KeithHall,使用范围的:

CSS: source.css.embedded.html, meta.attribute-with-value.style.html source.css 
JS: source.js.embedded.html 

将允许您将这些自定义背景色适用于HTML语法,而不影响CSS & JS语法。

+2

请注意,这也会影响独立css和js文件的背景颜色 - 您可以使用'source.css.embedded.html,meta.attribute-with-value.style.html source.css'范围来仅影响css嵌入在html和'source.js.embedded.html'中只会影响嵌入到html中的js –

+1

@KeithHall:良好的调用!更新:) – Enteleform

+0

@KeithHall我可以在哪里阅读关于HTML/CSS/JS的所有范围,除了source.css.embedded.html,meta.attribute-with-value.style.html source.css,text.html',由Sublime Text 3支持?谢谢! –

1

您可以将语言特定的崇高设置(例如js.sublime-settings)添加到Sublime Text 3/Data/Packages/User中,并为此语言定义完全不同的配色方案(js)。

{ 
    "color_scheme": "my_js_specific_theme.tmTheme", 
} 

,或者你可以尝试在你的.tmTheme如下:

<dict> 
    <key>scope</key> 
    <string>source.js</string> 
    <key>settings</key> 
    <dict> 
     <key>background</key> 
     <string>#000000</string> 
    </dict> 
</dict> 

更换#000000当然是有你的颜色代码。