本文介绍了如何为 sublime text 2 添加语法高亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定字符串 "text text #{interpolation}" Sublime Text 2 用一种颜色突出显示整个字符串.我想突出显示插入的文本,以便于挑选.当我在插值部分按 ctrl-shift-alt-p 时,Sublime 告诉我命名空间:source.ruby string.quoted.double.ruby source.ruby.embedded.source

Given the string "text text #{interpolation}" Sublime Text 2 highlights the whole string with one color. I would like to highlight the interpolated text so it is easy to pick out. When I press ctrl-shift-alt-p in the interpolated section Sublime tells me the namespace: source.ruby string.quoted.double.ruby source.ruby.embedded.source

我想知道在哪里定义规则来突出显示(我认为在 tmLanguage 文件中),该规则将采用什么格式,以及如何为其分配颜色.

I am wondering where I would define a rule to highlight this(I think in the tmLanguage file), what format that rule would take, and how to go about assigning a color to it.

推荐答案

如果您深入研究所包含的 Dawn.tmTheme 文件(其中包含的唯一能够正确突出显示的主题之一),您将为 String embedding-source 找到这些突出显示规则,出于某种原因,某些主题完全忽略了这一点:

If you dig into the included Dawn.tmTheme file (one of the only included themes that does this highlighting properly) you'll find these highlighting rules for String embedded-source, for some reason some of the themes leave this out completely:

<dict>
    <key>name</key>
    <string>String embedded-source</string>
    <key>scope</key>
    <string>string source</string>
    <key>settings</key>
    <dict>
        <key>background</key>
        <string>#6F8BBA26</string>
        <key>fontStyle</key>
        <string></string>
        <key>foreground</key>
        <string>#080808</string>
    </dict>
</dict>

这篇关于如何为 sublime text 2 添加语法高亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 11:03