我希望有文字TODO:作为任何语言的评论中的不同颜色。我在包TODOreview和SublimeLinter-annotations中使用了关键字TODO:,将TODO:这个词与其他注释区分开来会很好。
我已经为C++.tmLanguage尝试了以下正则表达式,但没有成功。在tmTheme中使用comment.todo确定正则表达式的作用域
/\/\/.*?(TODO:)/
(TODO:)
(?:\#|\/\/)[^\n\r]TODO:(?<![\?>])
/TODO:(?<![\?>])/完整示例:
C++.tmLanguage
<dict>
<key>match</key>
<string>(\/\/.)*?(TODO:)</string>
<key>name</key>
<string>comment.todo</string>
</dict>
theme.tmTheme
<dict>
<key>name</key>
<string>Comment Todo</string>
<key>scope</key>
<string>comment.todo</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#9B859D</string>
</dict>
</dict>发布于 2015-09-28 18:04:20
这不是语法定义在SublimeText和Textmate中的工作方式。您不能在所有不同的语法中为像"TODO“这样的特定字符串提供作用域。但别担心,总会有办法的。
TODO并给它一个作用域。现在,打开所有其他语法文件,找到它们的注释规则定义,并包含这个外部语法定义。TODO单词动态添加一个作用域,在注释中选择TODO短语时要小心。查看add_regions(key, [regions], <scope>, <icon>, <flags>) 和SublimeLinter (可能需要一些配置)
https://stackoverflow.com/questions/32800180
复制相似问题