-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up Automatic Clang Formatting In VSCode
matt-bekkers edited this page Oct 28, 2023
·
7 revisions
- Locate the .clang-format file on your machine by typing "where clang-format" into the command line and copy its path.
- Install the "Clang-Format" extension in VSCode by Xaver.
- Open the VSCode settings.json file by navigating to file -> preferences -> settings or with the shortcut Ctrl + , . Select the file icon in the top right corner.
- Copy and paste the following code into the settings.json file, filling in the required fields:
"clang-format.executable": "path to clang-format copied above",
"clang-format.style": "path to .clang-format within the packager repo" ,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.formatOnSave": true,
"clang-format.language.c.enable": true,
"[c]":{
"editor.defaultFormatter": "xaver.clang-format",
"editor.wordBasedSuggestions": false,
"editor.suggest.insertMode": "replace",
"editor.semanticHighlighting.enabled": true,
}
- Save the settings.json file and finish.