Common Templates

CodeRush is shipped with powerful library of code templates. This library contains shortcuts for the most common code constructions. The most useful templates are presented below.

Single-key Templates

Template Expansion Context
. /* */ Expands outside comments or strings.
~ Destructor Expands in a class body only.
a Abstract class Expands on an empty line, in a namespace, class, or struct.
b { } Expands outside comments or strings
c Class with default constructor Expands on an empty line, in a namespace, class, or struct.
c case block Expands on an empty line, in a switch block.
d Delegate Expands on an empty line, in a namespace, class, or struct.
d Default block Expands on an empty line, in a switch block.
e Public enum Expands on an empty line, in a namespace, class, or struct.
f false Expands in code blocks only.
f Field declaration Expands inside a class or struct.
f for loop Expands on an empty line inside a method or property accessor body.
g Property get accessor Expands in property body only.
i Interface Expands in a namespace body only.
l else Expands in code blocks only.
m Void method or Sub Expands in classes, interfaces, and structs, but not inside methods or properties.
n null Expands in code blocks only.
o Initialized read-only field declaration Expands in classes, interfaces, and structs, but not inside methods or properties.
o Initialized variable declaration Expands in methods or property accessors.
p Property declaration Expands in classes, interfaces, and structs, but not inside methods or properties.
q Initialized read-only field declaration Expands in classes, interfaces, and structs, but not inside methods or properties.
q Initialized variable declaration Expands in methods or property accessors.
r Smart Return Expands in code blocks only.
s Property set accessor Expands in property body only.
s Struct declaration Expands in namespace, class or struct.
t true Expands in code blocks only.
t Test method Expands in a class on an empty line, provided that project has a reference to a supported testing framework.
u using statement Expands outside of a class.
u using block Expands in code blocks only.
v virtual Expands in a method or property declaration.
w while block Expands on an empty line inside a method or property accessor body
x Exception class descendant declaration. Expands on an empty line, in a namespace, class, or struct.

Members

Template Expansion
m Method
mb Boolean Method
mo Object Method
p Property
pi Integer Property
pd Double Property
f Field
fs String Field
Note

Detailed information on using the member declaration templates is presented in the Members Declaration article.

Member Kinds

Template Expansion
c Class with default constructor
i Interface
s Struct
e Enum
a Abstract Class
d Delegate
x Exception

Flow Control

Template Expansion
b Code block
br break keyword
ca case block
co continue keyword
do do/while loop
fe foreach loop
for for loop
r Smart Return
r" return ""
rf return false
rn return null
rt return true
sw switch block
tn throw and new keywords
tne throw new Exception() statement
wh while block
yb yield break statement
yr yield return statement

Conditionals

Template Expansion
cod Assigns a new instance of the appropriate type to an identifier from the clipboard if it's value is null.
if if statement
ifb if block
lb else block
lf else if statement
ll else keyword
lr Smart Return in the else block
lr" return "" in the else block
lrf return false in the else block
lrn return null in the else block
lrt return true in the else block

Exceptions Handling

Template Expansion
tc try/catch block
tcf try/catch/finally block
tf try/finally block
Note

The template shortcuts can be atomic (e.g., "br" for break) or complex (e.g., "lr" for Smart Return in the else block). Complex shortcuts consist of constant and variable parts. Refer to the Members Declaration article to learn more about templates with complex shortcuts.

The full list of templates is available in the code templates configuration options.

See Also