以下两行代码似乎打破了TCL中的语法着色。
regsub -all {/} $original {\\\\} target # The last } is being escaped
set grep_keyword [string trim $grep_keyword {"}] # The " character is starting a new quote
当我打开文件时,这段代码就像这样。有办法解决这个问题吗?
答案 0 :(得分:1)
虽然问题在技术上是使用Sublime Text 2(在你发现的某些极端情况下Tcl不是很容易正确突出),但更容易将Tcl代码改为语义等价的东西。
regsub -all {/} $original "\\\\\\\\" target
set grep_keyword [string trim $grep_keyword "\""]
当然,您可以考虑使用string map
作为第一个:
set target [string map {"/" "\\\\"} $original]
# or this:
# set target [string map {/ {\\}} $original]
# but I'm not sure if the editor will like that...
答案 1 :(得分:1)
所以,我回到这里并付出了一些努力来解决我的问题。我为TCL更改了tmLangauge文件。 }字符被识别为结束括号。我刚刚添加了\}到这个定义。
<key>braces</key>
<dict>
<key>begin</key>
<string>(?:^|(?<=\s))\{</string>
<key>comment</key>
<string>matches a single brace-enclosed word</string>
<key>end</key>
<string>\}([^\s\]]*)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>invalid.illegal.tcl</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\[{}\n]</string>
<key>name</key>
<string>constant.character.escape.tcl</string>
</dict>
<dict>
<key>include</key>
<string>#inner-braces</string>
</dict>
</array>
</dict>
在上文中,我对RegEx进行了修改,看起来像这样:
<string>\}([^\s\]]*)|\\}\s</string>