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

爷,独闯天下 提交于 2019-12-21 12:45:09

问题


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?


回答1:


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.




回答2:


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.




回答3:


It works well in my VS 2015. Try resetting all the settings.

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

You can reset for all other languages similar like this.

Hope this helps!



来源:https://stackoverflow.com/questions/32259287/visual-studio-2015-brackets-not-automatically-formatting-when-pressing-shift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!