Reputation: 260
Is it possible to configure VS Code to use C-style comments (/**/) instead of C++ style ones (//) for C code only? My Gooogle-fu might be weak, but I haven't found any useful solution to it so far.
Upvotes: 3
Views: 5516
Reputation: 31
You can actually redefine it entirely to your liking, but it will require some fiddling with the package.json of the C/C++ extension. This file will probably be located (at least on my Ubuntu it is) in ~/.vscode/extensions/ms-vscode.cpptools-YOUR_VERSION_NUMBER. So open it
code ~/.vscode/extensions/ms-vscode.cpptools-YOUR_VERSION_NUMBER/package.json
in terminal. In this file you need to locate an object named "contributes". Within this object you'll need to create an array called "languages" and add a language object:
"languages": [
{
"id": "c",
"extensions": [
".c", ".h"
],
"configuration": "./my-c-configuration.json"
}
]
now the path in the configuration property needs to point to another .json file in which you will add the new definition for the comment command: (in the "my-c-configuration.json" file, created in the same directory)
{
"comments": {
"lineComment": [ "/*", "*/" ],
"blockComment": [ "/*", "*/" ]
}
}
Save both files, reopen the VSCode, and that's all.
Upvotes: 3
Reputation: 185
It's July, 2020 and latest vs code stable version is Version 1.47.
Toggle block comment shortcut is : Shift+Alt+A.
Official Source : VS-Code Keyboard Shortcuts
Upvotes: 2