Search code examples
javascriptvisual-studio-codesyntax-highlightingvscode-extensionstmlanguage

Comment Line in tmLanguage starts with .* TextMate Grammar Syntax Highlight


I am working on my own Syntax Highlighting extension for VS code and I have comment lines that start with ".*" which I want to highlight.

For code I have:

"comment": {
    "patterns": [{
        "name": "comment.line.as",
        "match":  "(\.\*).*$\n?",
        "captures": {
            '1': {
                "name": "punctuation.definition.comment.as"
            }
        }
    }]
}

But this does not seems to add the correct comment scope to my lines that begin with .*.

Thank you for your help.


Solution

  • Simple mistake, since this is in a .json file and the regex is in between quotes I have to escape the escape characters. . become \. * become \* etc...