主题 – Sublime Text – 修改tmTheme文件
在.tmTheme文件中:
<dict> <key>name</key> <string>Entity name</string> <key>scope</key> <string>entity.name - (entity.name.filename | entity.name.section | entity.name.tag | entity.name.label)</string> <key>settings</key> <dict> <key>fontStyle</key> <string></string> <key>foreground</key> <string>#A6E22E</string> </dict> </dict> 下一个范围字符串: <string>entity.name - (entity.name.filename | entity.name.section | entity.name.tag | entity.name.label)</string> 是一种正则表达吗?什么适用于这个定义?在同一个文件的另一部分,我可以看到这样的东西: <string>variable.parameter - (source.c | source.c++ | source.objc | source.objc++)</string> 解决方法
这不是一个正则表达;它是从TextMate借来的
scope selector.
在Sublime Text中,您可以通过转到“工具”菜单 – >找到光标右侧的字符范围.开发者 – >显示范围名称. 对于测试选择器,您可以在Sublime Text控制台(View菜单 – > Show Console)中使用view.match_selector或view.find_by_selector APIs. 查看第一个游标的范围是否与第一个示例中的选择器匹配的示例: view.match_selector(view.sel()[0].begin(),'entity.name - (entity.name.filename | entity.name.section | entity.name.tag | entity.name.label)') 更多信息: 可以使用以下运算符: > – :没有,范围内的任何地方(要清楚,这是一个由空格包围的短划线,因为短划线可以出现在范围名称的中间) 笔记: >范围应该只包含字母数字字符和点(.),因此永远不会发生与运算符的冲突. 例: 在下面的Python片段中,使用syntax test format,将通过所有测试,因此它可以作为选择器如何工作的演示: a = "hello world" # comment # ^^^^^^^^^^^^^ string.quoted.double # ^^^^^^^^^^^^^ string # ^^^^^^^^^^^^^ string.quoted # ^^^^^^^^^^^^^ string.quoted. # ^^^^^^^^^^^^^ - quoted.double # ^^^^^^^^^^^^^ string - comment # ^^^^^^^^^^^^^ string,comment # ^^^^^^^^^^^^^ string | comment # ^^^^^^^^^^^^^ string & - comment # ^^^^^^^^^^^^^ string & - comment # ^^^^^^^^^^^^^ source string # ^^^^^^^^^^^^^ source & (string - comment) # ^^^^^^^^^^^^^ source - (string & comment) # ^^^^^^^^^^^^^ string & source # ^ source.python string.quoted.double.block.python punctuation.definition.string.begin.python # ^ source & string & punctuation.definition.string.begin.python # ^ string & punctuation & source # ^ string punctuation & source # ^ source punctuation & string # ^ source string punctuation - (punctuation string) # ^ string - source comment - punctuation source # ^ string - source comment - comment # ^ source - python # ^ source - (source & python) # ^ source - (source python) # ^ source.python - source.python.string # ^ source.python.. ..string.. # ^ comment - string # ^ comment # ^ comment,string # ^^^^^^^^^^^^^^^^^^^ comment,string | source # ^ (punctuation | string) & source.python - comment # ^ (punctuation & string) & source.python - comment 请注意,由于scope selector specificity似乎忽略了一些更高级的结构,您可能会发现使用范围选择器创建的.tmTheme规则适用或不适用于您可能不期望的情况. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |