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
. |
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: ![]() |
Invoke parameter info from templates |
List of postfix templates
Shortcut | Description | Example |
---|---|---|
.arg | Surrounds expression with invocation |
|
.await | Awaits expressions of 'Task' type |
|
.cast | Surrounds expression with cast |
|
.else | Checks boolean expression to be 'false' |
|
.field | Introduces field for expression |
|
.for | Iterates over collection with index |
|
.foreach | Iterates over enumerable collection |
|
.forr | Iterates over collection in reverse with index |
|
.if | Checks boolean expression to be 'true' |
|
.lock | Surrounds expression with lock block |
|
.new | Produces instantiation expression for type |
|
.not | Negates boolean expression |
|
.notnull | Checks expression to be not-null |
|
.null | Checks expression to be null |
|
.par | Parenthesizes current expression |
|
.parse | Parses string as value of some type |
|
.prop | Introduces property for expression |
|
.return | Returns expression from current function |
|
.sel | Selects expression in editor |
|
.switch | Produces switch statement |
|
.throw | Throws expression of 'Exception' type |
|
.to | Assigns current expression to some variable |
|
.tryparse | Parses string as value of some type |
|
.typeof | Wraps type usage with typeof() expression |
|
.using | Wraps resource with using statement |
|
.var | Introduces variable for expression |
|
.while | Iterating while boolean statement is 'true' |
|
.yield | Yields value from iterator method |
|
note
ReSharper's settings are saved in settings layers, which allow you to have different settings for different solutions and to share your settings with your team.