How to customize comment block characters in visual studio code?
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
Related videos on Youtube
André Junges
I've been crafting some code for more than 8 years, mostly with web technologies. Lately focusing on react, python, and node.
Updated on September 28, 2022Comments
-
André Junges over 1 year
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?
-
Mehrdad Mirreza about 4 yearsWhere ist this 'package.json' stored?
-
Samuel Segal about 4 yearsFor me, the file was located (mac OS): /Users/USERNAME/.vscode/extensions/EXTENSION_NAME/language-configuration.json
-
Meryan about 3 yearsHow to get rid of the auto inserted asterisk in block comments? I don't want any asterisks just /** .... */ Thank you.
-
Adrian Gonzalez over 2 yearsWhat's the extension name for typescript?
-
oxwilder over 2 years@Meryan This is a good question, did you start a separate thread on it?
-
Meryan over 2 years@oxwilder I believe I captured my frustration with these asterisks here Please pitch in your vote and insgihts stackoverflow.com/questions/70309428/…
-
Kay almost 2 yearsFor windows, the file is located at:
C:\Users\USERNAME\.vscode\extensions\EXT_NAME
It might also be at:C:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions