Log In
[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]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
  System Requirements
 [Expand]Features by Language
 [Expand]Getting Started
 [Collapse]Coding Assistance
   Auto Completion (IntelliRush)
   Clipboard Tools
   Selection Tools
  [Expand]Code Providers
   Declare Menu
  [Collapse]Code Templates
    Common Templates
    Members Declaration
    Interactive Templates
    Templates for Unit Tests
    XPO and XAF Templates
    Templates Configuration
   Typing Helpers
   Naming Assistant
 [Expand]Navigation and Search Tools
 [Expand]Static Code Analysis
  Visualization Tools
 [Expand]Code Style Assistance
  Building Assistance
  Debugging Assistance
 [Expand]Refactoring Assistance
 [Expand]Unit Testing Assistance
 [Expand]Decompiling Tools
 [Expand]Configuration Options
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Code Templates

Code templates are blocks of code that expand from short abbreviations typed into the code editor. Code templates provide you with the ability not to type the entire code manually, but insert stereotype code sections with only a few keystrokes.

CodeRush is shipped with a powerful library of code templates. To expand a template, type in the template shortcut and press Space. For instance, to create a simple class, type in "c" and press Space. This will create a new class and prompt you to name it (the constructor will be named automatically). If you prefer expanding templates with the Tab key, bind the "TemplateExpand" command to it using the Setup Wizard or Shortcuts... items of the CodeRush menu.


By default, the CodeRush is configured not to interfere Visual Studio features (such as IntelliSense). This prevents the Space and Tab keys from expanding templates, because this key confirms the IntelliSense suggestion by default. The default configuration allows you to expand a template only if you close the IntelliSense suggestions window preliminary by hitting Esc before the Space key. If this is not convenient for you, force the templates to expand in the IDE | IntelliSense options page.

Code templates are context-aware, which means a single shortcut expands different templates depending on the context. For instance, the "mb" template declares a Boolean method inside a class, or generates a call to MessageBox.Show() inside a method.

Code templates are combinable, for example, you can combine the "r" (for return) template with the "t" (for true) templates and use the "rt" template to insert the return true statement. The same principle is used to declare typed members and variables: you can add type mnemonic to each member or variable template and it will expand with the correct type.

To learn how to configure the existing templates and define the new ones, refer to the Templates Configuration article.

Expanded See Also

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