Export and Import Templates
- 2 minutes to read
You can export your custom code templates to an xml file and share this file with other developers. CodeRush also allows you to import code templates created by other developers.
Important
Visual Studio IntelliSense has priority over CodeRush templates. For information on how to prioritize a CodeRush template over Visual Studio IntelliSense, refer to the following topic section: Expand a Template Instead of Visual Studio IntelliSense.
Export Code Templates
Open the Templates options page.
To open this page, choose the CodeRush | Code Templates… menu item in Visual Studio.
Note
In Visual Studio 2019, CodeRush menu is placed into a new location - in Visual Studio Extensions menu. You can reposition the CodeRush menu back to the top level of the Visual Studio menu bar in Visual Studio 2019 version 16.4 or later. See the following topic for more information: First Steps.
Choose the template language from the “Language” drop-down list.
Position templates you want to export in a folder.
For example, you can arrange your custom templates in a custom folder to separate them from other templates. See the following example for information on how to create a category for your templates: How to: Create a Template from Scratch.
Right-click the folder you want to export and choose the Export Folder… menu item.
In the “Save As” dialog, type the name of your export file, specify the file location, and click Save.
CodeRush suggests the file name based on the language of the template set and the folder that contains templates you want to export (for example, CSharp_Custom).
Import Code Templates
Open the Templates options page as described in the previous section.
Choose the template language from the “Language” drop-down list.
Right-click any folder in the templates tree and choose the Import Templates… menu item.
In the Open dialog, choose the xml file that contains templates you want to import, and click Open.
If the template category you want to import already exists in the templates tree, CodeRush shows the following dialog:
You can either replace templates in this folder or rename the import folder.
Choose the appropriate action in the Category Exists menu and click OK.
CodeRush adds the import category to the end of the templates tree.
Click Apply and OK in the Templates options page to save the templates and close the page.