所以目标 block 是这样的:
/* some comments
more
end */
/*
和 */
之间的任何内容都被视为注释。我当前的规则仅捕获单行注释:
match: \/\*(\w|\s|\W|\n|\r\n)*\*\/
我知道 Sublime Text 使用 Oniguruma但我不知道如何匹配多行。
最佳答案
我在 ST3 上遇到了同样的问题,但使用的是 .sublime-syntax
文件。不同之处在于,在我的语言中, block 注释由 !*
和 *!
界定。内联注释以 !
开头。
这是我使用的解决方案:
contexts:
# The prototype context is prepended to all contexts but those setting
# meta_include_prototype: false.
prototype:
- include: comments
comments:
# Block comments begin with !* and ends with *!
- match: '!\*'
scope: punctuation.definition.comment.c
push:
- meta_scope: comment.block.c
- match: '\*!'
pop: true
# Inline comments begin with a '!' and finish at the end of the line.
- match: '![^\*]'
scope: punctuation.definition.comment.c
push:
# This is an anonymous context push for brevity.
- meta_scope: comment.line.double-slash.c
- match: $\n?
pop: true
关于regex - Sublime Text 3语法定义: how to capture a multiline C-style block comment?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29316457/