I created a language extension for visual studio code and I would like to change the comment block characters but I couldn't find a way to do so..
Has anyone already done or know how to do it?
OK, I finally figured out what was the problem. There are two ways you can change the comment blocks:
1 - CONFIG FILE
I dont know why it's not in the docs (or at least I couldn't find it) but there is a optional property you pass to the object inside the contributes.languages
array in the package.json
named configuration.
The description found on the vs code source code:
A relative path to a file containing configuration options for the language.
On that files you can create an object like this one and it's gonna overwrite the default comment characters
{
"comments": {
"lineComment": "//",
"blockComment": [ "<!--", "-->" ]
}
}
You can see this properties on the API references: https://code.visualstudio.com/Docs/extensionAPI/vscode-api#CommentRule
Note: That comment block command is triggered with a different shortcut. You can overwrite it though (in a general or even for a specific language using the property when
on the key binding object).
⇧⌥A - Toggle Block Comment - editor.action.blockComment https://code.visualstudio.com/Docs/customization/keybindings
2 - "SYNTAX" FILE .tmLanguage
Yes, you can do it from there too and you can make it even better. You can see an example here https://github.com/andrejunges/vscode-handlebars/blob/master/syntaxes/handlebars.tmLanguage#L68