【发布时间】:2013-08-11 20:26:52
【问题描述】:
最近,我发现了一个帖子,其中包含一个出色的脚本,用于继续在 CSS 的崇高文本中进行块评论,Here。并将其添加到特定于环境的键绑定文件就像一个魅力。但是,当我尝试将其更改为与乳胶 cmets 一起使用时(即,将 * 替换为 %)它不起作用。
原代码:
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n * "},
"context":
[
{"key": "selection_empty", "operator": "equal", "operand": true},
{"key": "preceding_text", "operator": "regex_contains",
"operand": "\\/\\*\\*$", "match_all": true}
]
},
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n* "},
"context":
[
//{"key": "selection_empty", "operator": "equal", "operand": true},
{"key": "preceding_text", "operator": "regex_contains",
"operand": "^[\t ]*\\*[^\\/]", "match_all": true}
]
},
我的代码:
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n % "},
"context":
[
{"key": "selection_empty", "operator": "equal", "operand": true},
{"key": "preceding_text", "operator": "regex_contains",
"operand": "\\/\\%\\%$", "match_all": true}
]
},
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n % "},
"context":
[
//{"key": "selection_empty", "operator": "equal", "operand": true},
{"key": "preceding_text", "operator": "regex_contains",
"operand": "^[\t ]%\\%[^\\/]", "match_all": true}
]
},
【问题讨论】:
-
定义
does not work。另请注意,*是量词,表示match the preceding token zero or more times。它也很模糊,我的意思是这个脚本应该做什么。你能提供两种情况的一些输入吗? -
它应该在块注释部分的每个新行中添加 %,即检查是否有注释字符(css 中的 *,latex 中的 %)。不起作用,我的意思是它什么也没增加。但是第一个添加了 *.
-
latex 中的评论是什么?是
/% this is a comment %/吗? -
你换了一个
*,太多了:^[\t ]*\\%[^\\/],或者只是^[\t ]*%[^\\/](因为,正如HamZa所说,第一个*是一个量词)。但是,LaTeX 没有块注释之类的东西,是这样的(除非您自己定义)。目前,sn-p 仍然希望块注释以/%%开头,这并没有真正的帮助。
标签: regex comments latex sublimetext2 code-snippets