ReSharper 8.0 Web Help

Complete Statement is a feature that inserts necessary syntax elements (braces, semicolons etc.) and gets you in position to start the next statement.

To invoke complete statement
  1. Place the caret at an applicable position (see scenarios below for detials).
  2. On the main menu, choose ReSharper | Edit | Complete Statement or press Ctrl+Shift+Enter.

Complete Statement (also known as Smart Enter) is helpful in numerous scenarios, including auto-closing parentheses, adding semicolons, completing if, while and for statements, and so on.

For example, whenever you declare a new method, Complete Statement comes handy after specifying method parameters:
Coding_Assistance__Complete_Statement__method_declaration__01
At this point, to start writing the method body, you normally have to:

  • Insert a missing parenthesis.
  • Press Enter.
  • Insert an opening brace.
  • Press Enter once again.
With Complete Statement, instead of this tricky procedure, you only have to press Ctrl+Shift+Enter, and ReSharper will automatically insert a closing parenthesis, as well as both braces, and put the caret right where you can proceed with writing the method body:
Coding_Assistance__Complete_Statement__method_declaration__02

In similar ways, Complete Statement is known to work with the following language constructs:

  • Type members: class, interface, struct, enum, delegate, field, event, and method declarations.
  • Statements: if, while, do, switch, using, lock, continue, break, and return statements; case and default clauses; conversion of single-line statements to block statements.
  • Expressions: invocation, element access, string/char literals; object, member, and collection item initializers; expressions that create anonymous types and implicitly typed arrays.

Below are a number of specific examples of the assistance that Complete Statement provides in specific contexts.

Use case Before Complete Statement After Complete Statement

Class declaration

Coding_Assistance__Complete_Statement__class_declaration__01

Coding_Assistance__Complete_Statement__class_declaration__02

Delegate declaration

Coding_Assistance__Complete_Statement__delegate_declaration__01

Coding_Assistance__Complete_Statement__delegate_declaration__02

Method declaration

Coding_Assistance__Complete_Statement__method_declaration__01

Coding_Assistance__Complete_Statement__method_declaration__02

Nested method invocation

Coding_Assistance__Complete_Statement__nested_invocation__01

Coding_Assistance__Complete_Statement__nested_invocation__02

if statement

Coding_Assistance__Complete_Statement__if_statement__01

Coding_Assistance__Complete_Statement__if_statement__02

case clause

Coding_Assistance__Complete_Statement__case_clause__01

Coding_Assistance__Complete_Statement__case_clause__02

Conversion of a single-line statement into block (case A)

Coding_Assistance__Complete_Statement__single-line_to_block__case_1__01

Coding_Assistance__Complete_Statement__single-line_to_block__case_1__02

Conversion of a single-line statement into block (case B)

Coding_Assistance__Complete_Statement__single-line_to_block__case_2__01

Coding_Assistance__Complete_Statement__single-line_to_block__case_2__02

Element access expression

Coding_Assistance__Complete_Statement__element_access__01

Coding_Assistance__Complete_Statement__element_access__02


This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available

Tip

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.