Resharper: auto-insert culry brackets after loops

486 Views Asked by At

How can I set auto inserting curly brackets after loop/IF + [ENTER] in C# ReSharper 8.2.3?

Example:

if (statement) //+[ENTER]

should gives me:

if (statement)
{
    //CURSOR HERE
}
2

There are 2 best solutions below

1
On BEST ANSWER

I don't know if it will insert both braces for you, however, there is an option to complete your brace. I.e., if you type:

if(statement) // + {

it will auto add and format your braces to be on the next line as follows

if(statement)
{
    // Cursor here
}

From the IDE, the option is in TOOLS -> Options -> ReSharper, "Options...". then under Environment -> Editor -> Editor Behavior Check the 'Auto-insert closing brace and choose the first option.

0
On

You can use ReSharper's Complete Statement command to auto-insert the braces for you. This is Ctrl+Shift+Enter. It's useful all over the place, automatically inserting semi-colons and closing brackets and so on.