Common Templates
- 2 minutes to read
CodeRush includes powerful library of code templates. This library contains shortcuts for the most common code constructions. The tables below show most useful templates.
Types Creation
Template | Expansion | Context |
---|---|---|
c | Class with default constructor | Expands on an empty line, in a namespace, class, or struct. |
i | Interface | Expands in a namespace body. |
s | Struct declaration | Expands in namespace, class or struct. |
e | Public enum | Expands on an empty line, in a namespace, class, or struct. |
a | Abstract class | Expands on an empty line, in a namespace, class, or struct. |
d | Delegate | Expands on an empty line, in a namespace, class, or struct. |
x | Exception class descendant declaration. | Expands on an empty line, in a namespace, class, or struct. |
t | Test fixture | Expands outside a class. |
t | Test method | Expands in a class on an empty line. |
cc | Create constructor | Expands in a class on an empty line. |
Members and Variables
Template[1] | Expansion |
---|---|
V or v | Variable (parameter, local, and field) |
N or n | New Instance |
O or o | Read-only Fields |
M or m | Methods |
P or p | Properties |
R or r | Read-only properties |
W or w | Write-only properties |
A or a | Auto-implemented properties |
t | Type Reference |
q | Constants |
c | Class |
Note
You can find the detailed information on the member declaration templates in the Members Declaration article.
If/Else
Template | Expansion |
---|---|
if | if statement |
ifn | if not… |
l | Else |
lf | Else if… |
Try
Template | Expansion |
---|---|
tc | try/catch |
tf | try/finally |
tcf | try/catch/finally |
Flow
Template | Expansion |
---|---|
for | For loop |
fe | For Each |
w | While loop |
dw | Do While |
sw | Switch |
se | Select |
tne | Throw new exception |
u | Using statement |
b | Begin/end block |
Note
You can use the following tips:
- Shift+Space suppresses template expansion.
- t, f, and n for true, false and null.
- r, rt, rf, and rn return values.
The full list of templates is available in the code templates configuration options.
See Also