External tools
You can define third-party applications as external tools and run them from CLion.
CLion allows you to pass contextual information from your project to the external tool as command-line arguments (for example, the currently selected file or the project source path), view the output produced by the tool, configure to launch the tool before a run/debug configuration, and more.
There are two types of external tools that you can add:
Local tools are applications that run locally on your machine.
Remote tools are applications executed on a remote machine over SSH.
Add a local external tool
Press Ctrl+Alt+S to open the IDE settings and select Tools | External Tools.
Click and specify the following settings:
Name: The name of the tool that will be displayed in the CLion interface.
Group: The name of the group to which the tool belongs. You can select an existing group or type the name of a new group.
Description: A meaningful description of the tool.
Program: The path to the application executable file.
Arguments: The arguments passed to the executable file, as you would specify them on the command line.
Working directory: The path to the current working directory from which the tool is executed.
Click OK to add the tool and then apply the changes.
Run a local external tool
To run the added tool, do one of the following:
From the main menu, select
and choose from the list of the available tools.In the Settings/Preferences dialog (Ctrl+Alt+S) , select Keymap, find the tool under the External Tools node, right-click it and select Add Keyboard Shortcut. Assign a shortcut and use it to run the tool.
Set the tool as a Before launch step of a run/debug configuration: go to the , select the configuration, click in the Before launch area, and select Run External Tool.
Add a remote external tool
Remote SSH external tools are configured similarly to local external tools, but also define the remote server on which they are executed and require credentials for connecting to it via SSH.
This example demonstrates how to add date
as a remote SSH external tool that is executed on a remote server and returns the current date and time on it.
Press Ctrl+Alt+S to open the IDE settings and select Tools | Remote SSH External Tools.
Click and specify the following settings:
This dialog provides the same set of settings as when you add a local external tool, but selecting the remote server is also suggested.
This can be one of your configured SSH configurations or a Vagrant box.
By default, CLion will ask you for the host, port, and relevant SSH credentials every time you run the tool on the server.
Click OK to add the tool and then apply the changes.
Run the added tool on a remote server
From the main menu, select Tools | Remote tools | Date and time.
Similarly to the case of a local external tool, you can add a shortcut to quickly run the remote tool. Go to Remote External Tools node, right-click it and select Add Keyboard Shortcut. Assign a shortcut and use it to run the tool.
, find the tool under the
CLion will prompt you to select an SSH configuration or provide the credentials manually:
After that, CLion will connect to the server via SSH and run the date
command, returning the output to the Run tool window.
Export/import the External Tools settings
To export the External Tools settings, do the following:
Call File | Manage IDE Settings | Export Settings from the main menu.
In the dialog that opens, select the Tools checkbox:
Specify the path to the target ZIP archive and click Ok.
To import the saved settings, use File | Manage IDE Settings | Import Settings.
Example: Uncrustify as an external tool
Uncrustify is a popular code formatter that you can configure as an external tool to use in addition or as an alternative to the CLion's built-in formatter or the integrated ClangFormat.
Optionally, place the configuration file in the project directory (otherwise, you will need to provide the full path).
Navigate to
and click .In the dialog that opens, specify the following:
Name:
uncrustify
- just for example, let's name the configuration similarly to the executable.Program:
uncrustify
- provide the binary name (and include the full path if necessary).Arguments:
-c mystyle.cfg -f $FilePath$ -o $FilePath$
Style settings stored in mypath.cfg will be applied to the file currently opened in the editor (click to open the Macros dialog and insert the
$FileName$
macro). The result will be written in-place: the-o
flag redirects the Uncrustify output).Working directory:
$FileDir$
- this macro corresponds 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 Uncrustify external tool
Go to uncrustify in the list of External Tools.
and findClick 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 the
menu:Automatically run Uncrustify before launch
In the
dialog, choose the desired run/debug configuration.Click in the Before Launch section, and select Run External Tool:
Choose uncrustify from the list of the available external tools.
As a result, the uncrustify external tool will be called every time you choose to run or debug the selected configuration.
Web browsers
You can use a web browser to open any file from your project. By default, it is used to preview the output of an HTML file or run and debug web applications.
Open a file in a web browser
To open a file that is intended to be rendered by a web browser (HTML, XML, JSP, and so on), do one of the following:
Press Alt+F2.
Right-click a file and select Open in Browser.
From the main menu, select View | Open in Browser.
Use the browser popup in the top right part of the editor window. Click the browser button to open the web server file URL, or Shift+Click it to open the local file URL.
The Open in Browser action is not available for other file types. However, you can still execute it using Find ActionCtrl+Shift+A.
View and configure the list of browsers
In the Settings/Preferences dialog (Ctrl+Alt+S) , select Tools | Web Browsers.
If a browser was installed using a standard procedure, the alias in the Path field should point to the right location. If it does not, specify the path to the corresponding executable file.
Use custom profile and settings
You can configure custom profiles for Firefox and Chrome family browsers.
In the Settings/Preferences dialog (Ctrl+Alt+S) , select Tools | Web Browsers.
Select the browser in the list and click .
For Firefox, specify the path to the profiles.ini file and choose the profile to use. For more information, see Firefox browser profile.
For Chrome, select Use custom user data directory and specify the location of the user data directory.
You can also specify additional command-line options to use when running Chrome from CLion. For more information, open
chrome://flags
in the Chrome address bar.