Configuring Third-Party Tools
In CLion, you can specify third-party standalone applications and run them as External Tools. You can pass contextual information to these tools (like the currently selected file or your project source path), view the output within the IDE, configure the tool's launch as a step of your run/debug configuration, and more.
Tools defined in the External Tools dialog appear as commands in the menu and various context menus. Like most other actions, external tools can be assigned keyboard shortcuts for quick access.
Ways to call an external tool:
- From the list of available tools in Tools | External Tools on the main menu
- Via a keyboard shortcut assigned to the tool in
- As the Before launch step of a run/debug configuration
See the next chapter for an example of how to configure and use an external tool.
Example: ClangFormat as an external tool
ClangFormat is a widely-used code formatter. It supports two ways of providing code style options: you can either define them in a YAML file (named .clang-format or _clang-format) or specify the style options directly as command line parameters.
For code style settings given as a list of command line arguments or in a simple clang-format file, you will most likely be able to replicate the same configuration in CLion's Code Style settings. Otherwise, if your clang-format file can't be easily mapped to CLion's formatter settings, consider configuring ClangFormat as an external tool:
- Place your .clang-format file in the project directory.
- Navigate to and click .
- In the dialog that opens, specify the following:
clang-format- just for example, let's name the configuration similarly to the executable.
clang-format- use the name of your executable.
-i $FileName$- settings from the clang-format file will be applied inplace (
-i), to the file currently opened in the editor (the
- Working directory:
$FileDir$- this macro represents the current file directory.
- Click Ok to save the configuration.
- Now you can go to and run the tool with the above settings. The changes of code formatting will be introduced right away.
Assign a shortcut to the clang-format external tool:
- Go to clang-format in the list of External Tools. and find
- Click and choose Add Keyboard Shortcut.
- Press the keys to be used as shortcuts and click Ok.
Now the assigned shortcut is available, and you can see it next to the tool's name in themenu:
Automatically run clang-format before launch:
- In the dialog, choose the desired run/debug configuration.
- Click in the Before Launch section, and select Run External Tool:
- Choose clang-format from the list of the available external tools.
As a result, the clang-format external tool will be called every time you choose to run or debug the selected configuration.