PyCharm 2024.3 Help

Share live templates

PyCharm stores definitions of custom live template groups and templates added to predefined template groups in automatically generated XML configuration files.

  • For a custom group, the file contains definitions of all the templates the group includes.

  • For a modified predefined group, the file contains definitions of the added (or modified) live templates only.

Live template group configuration files are stored in the templates directory of the IDE configuration directory. By copying the relevant files in the templates directory, you can share live templates among team members and multiple PyCharm installations. Moreover, you can share live templates across all IDEs based on the IntelliJ platform.

Share live templates using Settings Sync

If you want to synchronize live templates across your IDEs (rather than sharing them with your teammates), you can use Settings Sync. Settings Sync uses the JetBrains server to synchronize IDE settings across the IDEs where you sign in using your JetBrains account.

  1. Press Ctrl+Alt+S to open Settings, go to Backup and Sync.

  2. If Settings Sync is not yet enabled, click Enable Backup and Sync.

  3. To share live templates, make sure the Code settings checkbox is selected under Configure what to sync. Select this checkbox on other IDEs where you want your code settings (including live templates) to be shared.

The quick way: copy and paste

If you want to share one or a couple of templates and do not need to synchronize them regularly, you can simply copy and paste them from one IDE to another. The XML representation of the template (including its name, description, and variables) will be put into the clipboard.

  1. Press Ctrl+Alt+S to open settings and then select Editor | Live Templates.

  2. Expand a template group, select one or more templates, and press Ctrl+C (or right-click the template and select Copy).

  3. In the target IDE, press Ctrl+Alt+S to open the IDE settings, navigate to a live template group, and press Ctrl+V.

Export and import live templates manually

PyCharm also lets you export and import all live templates, which may be more convenient than copying individual templates manually.

Export live templates manually

  1. Choose File | Manage IDE Settings | Export Settings from the menu.

  2. In the Export Settings dialog, make sure that the Live templates (schemes) checkbox is selected and specify the path and name of the archive, where the exported settings will be saved.

    Note that the Live templates checkbox appears in the Export Settings dialog if you have at least one custom live template in your project.

  3. Click OK to generate the file based on the exported settings. You can share this file with your team members, or import it on another PyCharm installation.

Import live templates

  1. Select File | Manage IDE Settings | Import Settings from the menu.

  2. Specify the path to the archive with the exported live templates.

  3. In the Select Components to Import dialog, select the Live templates checkbox and click OK.

After restarting PyCharm, you will see the imported live templates on the Editor | Live templates page of settings  Ctrl+Alt+S.

Last modified: 08 October 2024