/ClangFormatIJ

clang-format for IntelliJ based IDEs

Primary LanguageJavaApache License 2.0Apache-2.0

clang-format for IntelliJ based IDEs

ClangFormatIJ hooks up clang-format into IntelliJ based IDEs, such as IntelliJ IDEA, WebStorm, or similar.

Installation

To use clang-format, please install it from the JetBrains Marketplace.

Next, you'll need to install clang-format itself. To do so, you could grab the binaries...

Once installed, go into your IntelliJ settings for clang-format (Settings > Tools > clang-format) and point the clang-format binary field to the executable (e.g. clang-format.exe on Windows).

The executable could be located in your PATH already, or you could explicitly use something like the following:

  • for npm/windows: C:\Users\<your username>\AppData\Roaming\npm.\node_modules\clang-format\bin\win32\clang-format.exe
  • for the llvm toolchain: [path/to/clang]/clang/bin/clang-format

Usage

To use the formatter, simply run the Reformat Code with clang-format action inside of your IDE.

You can also bind the action to a key inside of your settings (Settings > Keymap > Reformat Code with clang-format) and even create a Macro that automatically reformats your code upon saving it.