ReSharper 10.0 Help

Postfix Templates

ReSharper | Options | Environment | Postfix Templates

This page of ReSharper options lists available postfix templates and allows configuring them.

In the list of postfix templates , use check-boxes to enable or disable individual templates.

On the bottom of the page, you can find the following configuration options:

ItemDescription
Code completion
Show postfix templates Clear this check box if you want to disable postfix templates in the auto-completion lists.
Show source templates Clear this check box if you want to disable source templates in the auto-completion lists.
Other options
Put braces after statement templates If this check box is selected, ReSharper adds braces after statement templates. For example, ReSharper will add braces after the template .if applied to myBool:
if(myBool) { }
.
Search for occurrences in .var template If this check box is selected, ReSharper checks whether the expression, which you are introducing a variable for, has more occurrences in the current scope. If multiple occurrences, ReSharper can help you replace all of them with usages of the newly introduced variable:
postfix_templates_var
Invoke parameter info from templates

List of postfix templates

ShortcutDescriptionExample
.arg Surrounds expression with invocation Method(expr)
.await Awaits expressions of 'Task' type await expr
.cast Surrounds expression with cast ((SomeType) expr)
.else Checks boolean expression to be 'false' if (!expr)
.field Introduces field for expression _field = expr;
.for Iterates over collection with index for (var i = 0; i < xs.Length; i++)
.foreach Iterates over enumerable collection foreach (var x in expr)
.forr Iterates over collection in reverse with index for (var i = xs.Length-1; i >= 0; i--)
.if Checks boolean expression to be 'true' if (expr)
.lock Surrounds expression with lock block lock (expr)
.new Produces instantiation expression for type new SomeType()
.not Negates boolean expression !expr
.notnull Checks expression to be not-null if (expr != null)
.null Checks expression to be null if (expr == null)
.par Parenthesizes current expression (expr)
.parse Parses string as value of some type int.Parse(expr)
.prop Introduces property for expression Property = expr;
.return Returns expression from current function return expr;
.sel Selects expression in editor |selected + expression|
.switch Produces switch over integral/string type switch (expr)
.throw Throws expression of 'Exception' type throw expr;
.to Assigns current expression to some variable lvalue = expr;
.tryparse Parses string as value of some type int.TryParse(expr, out value)
.typeof Wraps type usage with typeof() expression typeof(TExpr)
.using Wraps resource with using statement using (expr)
.var Introduces variable for expression var x = expr;
.while Iterating while boolean statement is 'true' while (expr)
.yield Yields value from iterator method yield return expr;
Last modified: 8 January 2016