How to configure Uncrustify in VSCode and example uncrustify.cfg file for APEX.
- Go to Uncrustify homepage and download latest version.
- It is non installable ZIP file. Extract its content to
C:\cli_tools\Uncrustify
or any other folder where you keep your cli tools. - Add this location to path. Right click on start menu icon -> System -> Advanced system settings -> Environment Variables -> System variables -> Path -> Edit -> New -> and paste there
C:\cli_tools\Uncrustify
-> OK -> OK -> OK - Open Windows Terminal or cmd.exe and type
uncrustify --version
you should see Uncrustify-0.75.1_f or any newer version that you have installed.
In case it is not working, check if you correctly added path variable and restart computer.
Install VSCode Uncrustify plugin
Press Ctrl + Shift + P and type Uncrustify: Create default config file
which will create uncrustify.cfg
file in root of your project.
Download uncrustify.cfg
from this project and compare it with WinMerge or any other tool and import rules that you want to use.
Rules that were modified are marked with comment # Modified for SF Apex
that you can see easily what was modified compared to standard.
If this it too hard for you then just overwrite your file with mine. In this repo history you can check which rules I have modified.