ReSharper 2017.3 Help

Postfix Templates

ReSharper | Options | Code Editing | Postfix Templates

This page of ReSharper options lets you configure postfix templates.

Use tabs to switch between postfix templates in specific languages and use check-boxes to enable or disable templates. Note that the same templates in different languages should be enabled/disabled individually.

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 statement 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;
ShortcutDescriptionExample
.else Checks boolean expression to be 'false' if (!expr)
.forof Iterates over an iterable object for (let x of expr)
.if Checks boolean expression to be 'true' if (expr)
.notnull Checks expression to be not-null if (expr !== null)
.notundefined Checks expression to be not-undefined if (expr !== undefined)
.null Checks expression to be null if (expr === null)
.return Returns expression from current function return expr;
.undefined Checks expression to be undefined if (expr === undefined)
.var Introduces variable for expression var x = expr;
ShortcutDescriptionExample
.else Checks boolean expression to be 'false' if (!expr)
.forof Iterates over an iterable object for (let x of expr)
.if Checks boolean expression to be 'true' if (expr)
.instanceof Checks instance of expression if (x instanceof Class)
.notnull Checks expression to be not-null if (expr !== null)
.notundefined Checks expression to be not-undefined if (expr !== undefined)
.null Checks expression to be null if (expr === null)
.return Returns expression from current function return expr;
.typeof Checks type of expression if (typeof x === 'string')
.undefined Checks expression to be undefined if (expr === undefined)
.var Introduces variable for expression let x = expr;
ShortcutDescriptionExample
.beg..end Produces iterators from range sort(range.begin(), range.end())
.cbeg..cend Produces iterators from range is_sorted(range.cbegin(), range.cend())
.const_cast Surrounds expression with const_cast const_cast<SomeType &>(expr)
.do Iterating until boolean expression becomes 'false' do { } while (expr);
.dynamic_cast Surrounds expression with dynamic_cast dynamic_cast<SomeType &>(expr)
.else Checks boolean expression to be 'false' if (!expr)
.foreach Iterates over range foreach (auto && x in range)
.if Checks boolean expression to be 'true' if (expr)
.make_shared Constructs an object and wraps it in a std::shared_ptr std::make_shared<SomeType>()
.make_unique Constructs an object and wraps it in a std::unique_ptr std::make_unique<SomeType>()
.new Produces instantiation expression for type new SomeType()
.reinterpret_cast Surrounds expression with reinterpret_cast reinterpret_cast<SomeType &>(expr)
.return Returns expression from current function return expr;
.static_cast Surrounds expression with static_cast static_cast<SomeType>(expr)
.switch Produces switch over integral/enum type switch (expr)
.var Introduces variable for expression auto x = expr;
.while Iterating while boolean expression is 'true' while (expr)
Last modified: 7 December 2017