Back to Devexpress

How to: Create a Template from Scratch

coderushforroslyn-402507-getting-started-examples-code-generation-how-to-create-a-template-from-scratch.md

latest1.4 KB
Original Source

How to: Create a Template from Scratch

  • May 30, 2022
  • 2 minutes to read
  1. Open the Editor | All Languages | Templates options page.

  2. Choose the template language from the combo box in the page’s top left.

  3. Click the New Category button to create a separate category for your templates.

  4. Enter the category name and enable the Make this a top-level folder option in the New Category dialog.

  5. To create a new template within a category, select the category and click New Template.

  6. Enter the template name and click OK in the New Template dialog.

  7. Focus the Template Editor. Fill the Comment field and the template expansion code. For example, type “New SQL Connection” in the Comment field, and copy and paste the following template expansion code:

  8. Specify the Context in the corresponding field to expand the template in certain conditions (optional).

  9. Configure the shortcut key that expands this template. Choose one of the following options in the Trigger this template with section:

  10. Click Apply and OK to apply the changes and close the Templates options page.

  11. Expand your new template. For example, type “nsq” and press Space in the code editor.