[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Collapse]CodeRush
  System Requirements
  Improve Performance
 [Expand]Features by Language
 [Expand]Getting Started
 [Expand]How To
 [Expand]Coding Assistance
 [Expand]Navigation and Search Tools
 [Expand]Static Code Analysis
 [Expand]Visualization Tools
 [Expand]Code Style Assistance
  Building Assistance
  Debugging Assistance
 [Expand]Refactoring Assistance
 [Expand]Unit Testing Assistance
 [Expand]Decompiling Tools
 [Expand]Configuration Options
 [Collapse]Extensibility
   Adding a Dictionary for the Spell Checker
  [Collapse]Custom Templates Creation
    Adding a Template
    Using Text Commands
    Referencing Namespaces
    Linking Identifiers
    Providing Input Fields
    Using Variables
    Iterating Through Elements
    Template Name Variables
    Alternative Template Expansions
    Text Commands
    String Providers
  [Expand]Context Providers
   Specify a Default Filter for the Jump to Symbol Window
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Adding a Template

There are two ways to create a new template in the Editor | All Languages | Templates options page:

Expanded Create a Template From Scratch

Open the Editor | All Languages | Templates options page and follow the steps below:

  1. Choose the required language at the bottom left of the Options window.

  2. Create a separate category for your templates using the New Category button.

    After clicking the New Category button, enter the category name, set the Make this a top-level folder option and click OK to create a category.

  3. To create a new template within a category, select the required category and use the New Template button.

    Enter the template name and click OK.

    Important

    The template name corresponds to its mnemonics. Type it in your code to expand the template.

  4. In Template Editor, fill the Comment field and the template expansion code, and then click Apply (or OK to apply changes and close the window).

  5. Optionally, specify the Context in the corresponding field to expand this template only in certain conditions.
  6. Optionally, configure the key which expands this template. Choose one of the following options in the Trigger this template with section:

    • Primary key — expands the template with the shortcut configured for the TemplateExpand command. This command is bound to the Space or Tab key (depending on your selection in the Setup Wizard) by default.
    • Secondary key — expands the template with the shortcut configured for the TemplateSecondaryExpand command (Shift+Space by default).
    • Either key — expands the template both with Primary key and Secondary key.
  7. After this, you can test your new template. Type the template shortcut in the code editor and expand your template.

Expanded New Template Based on Another

Open the Editor | All Languages | Templates options page and follow the steps below:

  1. Choose the required language at the bottom left of the Options window.

  2. Find the template to base your new template on and right-click it.

  3. Select Create alias or Create duplicate in the menu. The Create alias item creates a template which expands the selected one. The Create duplicate item creates the same template with another name.
  4. Enter the template name and click OK.

    Important

    The template name corresponds to its shortcut, which causes the template expansion being typed in code.

  5. Edit the new template according to your needs. Refer to steps 4-onwards in the Create a template from scratch section to learn more.

Is this topic helpful?​​​​​​​