Complete Statement
Code | Code Completion | Complete Current Statement
CtrlShiftEnter
This command inserts necessary syntax elements (parentheses, braces, semicolons and so on) and gets you in position where you can start typing the next statement.
tip
You can use this command even if your caret is anywhere within a statement that is already complete. In this case, JetBrains Rider will add a new line after that statement and place the caret in the position to start typing the next one.
Type the core of a statement (see scenarios below for examples).
Press CtrlShiftEnter.
The command is helpful in numerous scenarios, including auto-closing parentheses, adding semicolons, completing if
, while
and for
statements, and more.
For example, whenever you declare a new method, complete statement comes handy after specifying method parameters:
public void Foo(string input
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 JetBrains Rider, you only have to press CtrlShiftEnter, and it will automatically insert a closing parenthesis, as well as both braces, and place the caret right where you can proceed with writing the method body:
public void Foo(string input)
{
// the caret is here
}
In similar ways, Complete Statement works with the following language constructs:
Types and type members: class, interface, struct, enum, delegate, field, event, and method declarations.
Statements:
if
,while
,do
,switch
,using
,lock
,continue
,break
, andreturn
statements;case
anddefault
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, you can find a number of examples of applying the complete statement command in different contexts.
Use case | Before Complete Statement | After Complete Statement |
---|---|---|
Class declaration |
|
|
Delegate declaration |
|
|
Nested method invocation |
|
|
|
|
|
|
|
|
Conversion of a single-line statement into block (case A) |
|
|
Conversion of a single-line statement into block (case B) |
|
|
Element access expression |
|
|