Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 - brackets not automatically formatting when pressing shift + enter

Normally, to create a new bracket block I would type:

"{" then enter

This produces:

{

}

however, (I have seen this on two different machines so far, it might be the default setting) if like me, you like to keep shift held down, or accidentally keep it down and instead press shift + enter, it creates a new line underneath.

{ }
//current cursor position

Leaving the un-formatted brackets behind!

This is really annoying as I nearly always do this, and have to fiddle around for a little second to get the brackets back to where I want them. What can I do to change the behavior of shift + enter?

like image 837
Sam Walls Avatar asked Aug 27 '15 20:08

Sam Walls


2 Answers

Go to Options > Environment > Keyboard

  • Search for Edit.SmartBreakLine and remove the assigned shortcut (Shift + Enter)
  • Search for Edit.BreakLine, click on "Press shortcut keys:" textbox, press Shift + Enter and click Assign

If it doesn't work try restarting Visual Studio.

Update: This issue is fixed in Visual Studio 2015 Update 1 - SmartBreakLine works as expected.

like image 88
Nikola Nikolov Avatar answered Nov 06 '22 06:11

Nikola Nikolov


We stumbled on this thread and it felt like we could make a nice improvement here to Shift+Enter (SmartBreakLine).

So, in cases where a block was opened { } and if shift was held down intentionally or unintentionally, we now do this:

{
    |
}

instead of

{ }
|

this way people who are used to using shift+enter to complete the line (in C#, it adds a semicolon to the end of line if needed, formats the line, adds a new line after current line) do not have to lose those functionalities by remapping the shortcut to BreakLine.

See: https://github.com/dotnet/roslyn/pull/5790

this should make it in the next update of Vs2015 and we hope you like it.

like image 5
balajikris Avatar answered Nov 06 '22 06:11

balajikris