vscode-uncrustify is a formatter which uses Uncrustify to format C, C++, and
some other languages with C-like syntax.
Features
Exclude paths from formatting
Specify default .cfg file
Specify Uncrustify executable to use
Use different .cfg files for different file extensions
On-save formatting
Formatting support for C, C++, Objective-C, C#, D, Java, Vala, and Pawn
Requirements
An Uncrustify binary. Uncrustify is available through many package managers
and as a prebuilt Windows binary. More information
here.
Usage
Formatting
Files can be formatted through the built-in Format Document command in the
Command Palette.
vscode-uncrustify can be set as your default formatter in Settings
(Ctrl + ,).
On-save formatting can be turned on in Settings (Ctrl + ,).
Commands
Open Log: Open the log for the most recent vscode-uncrustify run. Will fail
if vscode-uncrustify has not yet run.
Settings
uncrustify.defaultConfigFile: Path to default Uncrustify .cfg file. If
empty, uncrustify will try to find a config file in your $PATH.
uncrustify.executablePath.<linux|windows|OSX>: Uncrustify executable path
for the given operating system.
uncrustify.excludePaths: Directory paths for which to disable formatting.
uncrustify.enableLogs: Logs uncrustify commands and results to an output
pane.
uncrustify.advanced.extension-SpecificConfigFiles: Object containing
key-value pairs of file extensions and paths to cfg files. If null (default),
default cfg file will be used for all file extensions. Takes precedence over
uncrustify.defaultConfigFile setting.
uncrustify.advanced.extension-SpecificLangOverrides: Extension to overridden
Uncrustify parse language.
NOTE: The string ${workspaceFolder} can be used as shorthand for the
workspace root directory in these settings.
Extension-Specific Config Files Setting
Should be written in JSON format mapping file extension strings to .cfg
filepath strings. For example: