Sharing Live Templates
On this page:
- Configuration files with definitions of custom live templates
- Sharing live templates manually through configuration files
- Sharing live templates through export/import
- Sharing live templates among template groups
Configuration files with definitions of custom live templates
IntelliJ IDEA stores definitions of custom live template groups and templates added to predefined template groups in automatically generated configuration files <group_name>.xml
.
- For a custom group, the file contains definitions of all the templates the group includes.
- For a customized predefined group, the file contains definitions of the added templates only.
<group_name>.xml
files are stored at the following locations: - Windows:
<your_user_home_directory>\.IntelliJ IDEA<version_number>\config\templates
- Linux:
~IntelliJ IDEA<version>/config/templates
- macOS:
~/Library/Preferences/IntelliJ IDEA<version>/templates
Sharing live templates manually through configuration files
- Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or for macOS, and click Live Templates under Editor.
- Create the required custom template groups and update the relevant predefined groups as necessary and click OK. Based on these changes, IntelliJ IDEA generates the
<group_name>.xml
files, see Location of Custom Live Templates Definitions above. - Locate the generated
<group_name>.xml
files and do one of the following:- To share the templates among your teammates, send the relevant files to them with the instruction to save the files in the
templates
folder. - To use the templates in another IntelliJ IDEA installation on your computer, copy the relevant files to the
templates
folder under the relevantIntelliJ IDEA<version>
folder.
- To share the templates among your teammates, send the relevant files to them with the instruction to save the files in the
Sharing live templates through export/import
IntelliJ IDEA allows you to easily share live templates among your team members, numerous IntelliJ IDEA installations, and even different IDE by using the standard Export/Import functionality. You can share custom template groups and updates to predefined groups.
- Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or for macOS, and click Live Templates under Editor.
- Create the required custom template groups and update the relevant predefined groups as necessary and click OK. Based on these changes, IntelliJ IDEA generates the
<group_name>.xml
files, see Location of Custom Live Templates Definitions above. - On the main menu, choose .
- In the Export Settings dialog box that opens, select the Live Template check box and specify the name of the
.jar
file where the exported settings will be stored. When you click OK, IntelliJ IDEA generates a file with the specified named based on the.xml
configuration files stored in thetemplates
folder. - Do one of the following:
- To share the templates among your teammates, pass the generated
.jar
file to them with the following instructions:- Save the received
.jar
file on your computer. - Choose on the main menu and and specify the location of the received
.jar
file. - In the Select Components to Import dialog box that opens, select the Live Templates check box and click OK.
- Save the received
- To use the templates in another IntelliJ IDEA installation or in another IDE on your computer, open the required installation, choose on the main menu, and specify the location of the generated
.jar
file.
- To share the templates among your teammates, pass the generated
Example of sharing templates among different IDE
Be careful when sharing templates among different IDE. If you import custom templates (updates) from a group which is predefined in the source IDE but is not predefined in the target IDE, such group will be created but will contain only the custom templates. The example below shows what happens if we add a template to a predefined group in WebStorm and then reuse it in PhpStorm.
In WebStorm, the Dart template group is predefined. If we add the t (tag pair)
template to it, this update will be saved in the Dart.xml
file:
In PhpStorm, there is no predefined template group Dart. So when we export the live templates from WebStorm and them import them into PhpStorm, a Dart group is created but it contains only one template t (tag pair)
, which we added to the group in WebStorm before export:
Sharing live templates among template groups
You can copy and move templates from one group to another.
- Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or for macOS, and click Live Templates under Editor.
- Do one of the following: