主题 – 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.

it’s possible to AND,OR,and subtract scope selectors,e.g.: (a | b) & c - d would select the scope which is not matched by d,and matched by both c,and a or b.

在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)')

更多信息:

可以使用以下运算符:

> – :没有,范围内的任何地方(要清楚,这是一个由空格包围的短划线,因为短划线可以出现在范围名称的中间)
>&amp ;: with,范围内的任何地方(在.tmTheme文件中,为XML,&应该转义为& amp;,除非在CDATA节点内.)
>(空格):必须在前面的范围之后(即右边)
> |和,或者,范围内的任何地方
>(…)可用于将选择器组合在一起

笔记:

>范围应该只包含字母数字字符和点(.),因此永远不会发生与运算符的冲突.
>范围由单个空格分隔.
>操作符周围的空白区域不是必需的. (在评估之前修剪/剥离空白).即字符串|注释与字符串|注释相同.
>在评估范围选择器之前,前导点和尾随点也会被剥离
>连续的空格被视为单个空格.
>所有范围从一开始就匹配.范围选择器中没有通配符运算符.因此,您无法使用.python或* .python等匹配范围source.python.
>完全空的选择器匹配所有内容.但是当运算符跟着时却没有.即|它本身就会失败,因为它将会失败.源|然而,工作. – 和来源 – 将失败.
>如果您不确定运算符优先级,请将表达式的部分括在括号中,以使其清晰.但是,在分组后,您似乎需要使用除空格之外的运算符,否则将忽略分组后直接的范围.

例:

在下面的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规则适用或不适用于您可能不期望的情况.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


html5中section的用法
span标签和p标签的区别
jsp文件和html文件的区别是什么
span标签和div的区别
html颜色代码表大全
span标签的作用是什么
dhtml的主要组成部分包括什么
html编辑器哪个软件好用
span标签属于什么样式标签
html文件乱码怎么办
html怎么读取json文件
html文件打开乱码怎么恢复原状
html怎么链接外部css
html文件怎么保存到本地
html怎么链接css文件
html和css怎么连接
html和css怎么关联
html文件怎么保存到一个站点
html文件怎么写
html出现乱码怎么解决