Visual Studio 2015 - parentheses are not automatically formatted when you press shift + enter

Typically, to create a new block of brackets, I would type:

"{" then enter

This gives:

{ } 

however (I have seen this on two different machines so far, this may be the default setting), if I, like me, like to hold the shift or hold it accidentally, and instead press shift + enter, it creates a new line at the bottom .

 { } //current cursor position 

Leaving unformatted brackets behind!

This is very annoying since I almost always do it, and I need to play a bit to get the brackets back to where I want them. What can I do to change shift + enter behavior?

+6
source share
3 answers

We came across this topic, and it seemed to me that we could improve here Shift + Enter (SmartBreakLine).

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

 { | } 

instead

 { } | 

Thus, people who are accustomed to using shift + enter to end the line (in C # it adds a semicolon to the end of the line, if necessary, formats the line, adds a new line after the current line), you do not need to lose these functions by reassigning shortcut on BreakLine.

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

this should do it in the next update of Vs2015, and we hope you enjoy it.

+5
source

Go to Options> Environment> Keyboard.

  • Locate Edit.SmartBreakLine and remove the assigned shortcut (Shift + Enter)
  • Find Edit .BreakLine , press "Press Shortcuts:", press Shift + Enter and select Assign

If it does not work, try restarting Visual Studio.

Update: This problem was fixed in Visual Studio 2015 Update 1 - SmartBreakLine works as expected.

+12
source

This works well in my VS 2015. Try resetting all settings.

Tools> Import and Export Settings> Reset all settings> Next> Visual C #

You can reset for all other languages ​​like this.

Hope this helps!

0
source

All Articles