ReSharper 2020.2 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:

Code completion

Show postfix templates Clear this checkbox if you want to disable postfix templates in the auto-completion lists.
Show source templates Clear this checkbox if you want to disable source templates in the auto-completion lists.

Other options

Put braces after statement templates If this checkbox 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 checkbox 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:
ReSharper: Replace multiple occurrences
Invoke parameter info from templates

List of postfix templates

ShortcutDescriptionExample
.argSurrounds expression with invocationMethod(expr)
.awaitAwaits expressions of 'Task' typeawait expr
.castSurrounds expression with cast((SomeType) expr)
.elseChecks boolean expression to be 'false'if (!expr)
.fieldIntroduces field for expression_field = expr;
.forIterates over collection with indexfor (var i = 0; i < xs.Length; i++)
.foreachIterates over enumerable collectionforeach (var x in expr)
.forrIterates over collection in reverse with indexfor (var i = xs.Length-1; i >= 0; i--)
.ifChecks boolean expression to be 'true'if (expr)
.lockSurrounds expression with lock blocklock (expr)
.newProduces instantiation expression for typenew SomeType()
.notNegates boolean expression!expr
.notnullChecks expression to be not-nullif (expr != null)
.nullChecks expression to be nullif (expr == null)
.parParenthesizes current expression(expr)
.parseParses string as value of some typeint.Parse(expr)
.propIntroduces property for expressionProperty = expr;
.returnReturns expression from current functionreturn expr;
.selSelects expression in editor|selected + expression|
.switchProduces switch statementswitch (expr)
.throwThrows expression of 'Exception' typethrow expr;
.toAssigns current expression to some variablelvalue = expr;
.tryparseParses string as value of some typeint.TryParse(expr, out value)
.typeofWraps type usage with typeof() expressiontypeof(TExpr)
.usingWraps resource with using statementusing (expr)
.varIntroduces variable for expressionvar x = expr;
.whileIterating while boolean statement is 'true'while (expr)
.yieldYields value from iterator methodyield return expr;
ShortcutDescriptionExample
.elseChecks boolean expression to be 'false'if (!expr)
.forofIterates over an iterable objectfor (let x of expr)
.ifChecks boolean expression to be 'true'if (expr)
.notnullChecks expression to be not-nullif (expr !== null)
.notundefinedChecks expression to be not-undefinedif (expr !== undefined)
.nullChecks expression to be nullif (expr === null)
.returnReturns expression from current functionreturn expr;
.undefinedChecks expression to be undefinedif (expr === undefined)
.varIntroduces variable for expressionvar x = expr;
ShortcutDescriptionExample
.elseChecks boolean expression to be 'false'if (!expr)
.forofIterates over an iterable objectfor (let x of expr)
.ifChecks boolean expression to be 'true'if (expr)
.instanceofChecks instance of expressionif (x instanceof Class)
.notnullChecks expression to be not-nullif (expr !== null)
.notundefinedChecks expression to be not-undefinedif (expr !== undefined)
.nullChecks expression to be nullif (expr === null)
.returnReturns expression from current functionreturn expr;
.typeofChecks type of expressionif (typeof x === 'string')
.undefinedChecks expression to be undefinedif (expr === undefined)
.varIntroduces variable for expressionlet x = expr;
ShortcutDescriptionExample
.beg..endProduces iterators from rangesort(range.begin(), range.end())
.cbeg..cendProduces iterators from rangeis_sorted(range.cbegin(), range.cend())
.const_castSurrounds expression with const_castconst_cast<SomeType &>(expr)
.doIterating until boolean expression becomes 'false'do { } while (expr);
.dynamic_castSurrounds expression with dynamic_castdynamic_cast<SomeType &>(expr)
.elseChecks boolean expression to be 'false'if (!expr)
.foreachIterates over rangeforeach (auto && x in range)
.forwardForwards function parameterstd::forward<Arg>(arg)
.ifChecks boolean expression to be 'true'if (expr)
.make_sharedConstructs an object and wraps it in a std::shared_ptrstd::make_shared<SomeType>()
.make_uniqueConstructs an object and wraps it in a std::unique_ptrstd::make_unique<SomeType>()
.newProduces instantiation expression for typenew SomeType()
.reinterpret_castSurrounds expression with reinterpret_castreinterpret_cast<SomeType &>(expr)
.returnReturns expression from current functionreturn expr;
.safe_castSurrounds expression with safe_cast (C++/CLI)safe_cast<SomeType>(expr)
.static_castSurrounds expression with static_caststatic_cast<SomeType>(expr)
.switchProduces switch over integral/enum typeswitch (expr)
.varIntroduces variable for expressionauto x = expr;
.whileIterating while boolean expression is 'true'while (expr)
Last modified: 08 May 2020