Skip to content
Code format using uncrustify
Branch: master
Clone or download
markus456 and LaurentTreguier Add Troubleshooting section
The C/C++ extension's formatting must be disabled in order for the uncrustify one to work.
Latest commit 7d8ee68 Mar 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode Switch to tasks 2.0.0 Sep 8, 2017
editor Fix #29 Feb 19, 2018
images Update README and CHANGELOG May 1, 2017
src
.gitignore
.vscodeignore
CHANGELOG.md Update dependencies and CHANGELOG Mar 8, 2019
README.md
package-lock.json 2.14.2 Mar 8, 2019
package.json 2.14.2 Mar 8, 2019
tsconfig.json

README.md

VSCode uncrustify

Features

Formats your code using uncrustify. Supported languages are :

  • C
  • C++
  • C#
  • D
  • Java
  • Objective-C
  • Pawn
  • Vala

Apex, while not officially supported by uncrustify, is also supported by the extension and will be formatted as if it was Java.

Installing uncrustify

On most Linux distributions, macOS (if brew is installed) and Windows, uncrustify can be installed by the extension automatically.

If you want or have to install it yourself :

  • Linux : Uncrustify is available in most distributions as a package in the official repositories (sudo apt/yum install uncrustify or equivalent)
  • macOS : Uncrustify is available through Homebrew (brew install uncrustify or see http://macappstore.org/uncrustify)
  • Windows : Prebuilt binaries are available on sourceforge. You will need to put the executable in your PATH variable and you will have to update it manually

If the executable is not in the PATH environment variable, you must set its path in the settings explicitly.

Uncrustify configuration

A default config file can automatically be created (see the commands below).

Starting with version 2.0.0, opening the configured config file (or a file named uncrustify.cfg at the root of your workspace if it's not configured) will display a graphical editor to easily tweak the configuration file.

configuration image

The graphical editor can be disabled in the extension settings. Uncrustify's default config file keeps its version at the top of the file; if that version differs from the version of the uncrustify executable then a button will be available to upgrade the config file to the newer version. New items will be marked as such when using the graphical editor.

configuration upgrade image configuration new items image

Extension commands

  • Uncrustify: Create default config file (uncrustify.create): Creates a default uncrustify.cfg file and puts it at the root of the current workspace.
  • Uncrustify: Open config file (uncrustify.open): Opens the configuration file that is currently set in the extension settings.

Extension settings

  • uncrustify.executablePath (string): Path to the uncrustify executable if it's not already in the PATH environment variable.
  • uncrustify.configPath (string): Path to the uncrustify configuration file. Environment variables can be used with either a Windows or a bash syntax (examples: %SOME_PATH%/dev/uncrustify.cfg, $SOME_PATH/dev/uncrustify.cfg). A relative path will be automatically prefixed with the current workspace path.
  • uncrustify.graphicalConfig (boolean): Toggles the graphical config editor when opening an uncrustify config file.
  • uncrustify.debug (boolean): Activates logs for debugging the extension. Logs should appear in the uncrustify output channel.
  • uncrustify.langOverrides (object): Overrides the language used by uncrustify.

Changelog

See CHANGELOG.md

Troubleshooting

  • Format Document doesn't use Uncrustify when C/C++ extension is installed
    • In Settings > Extensions > C/C++, change C_Cpp: Formatting from Default to Disabled.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.