Visual Studio Code
already has uncrustify extension:
After installing it, you can modify the uncrustify
‘s configuration file path. On macOS
: Code
-> Preferences
-> Settings
-> Extensions
-> Uncrusify configuration
-> Configure Path: Osx
:
Then edit settings.json
:
{
......
"uncrustify.configPath.osx": "/Users/nanxiao/Documents/uncrustify.cfg",
}
Now you can format your code through “Option + shift + F
” command.(You should disable C/C++ extension
‘s formatting function, please refer troubleshooting . Update in 2023: for currentVisual Studio Code
, it will prompt you select uncrustify
or other extensions as the format tool)
BTW, you can enable formatting code when saving file function:
{
......
"editor.formatOnSave": true,
}