Stop VS 2010 from automatically creating braces After the else keyword

I use VS 2010, and it annoys me constantly when I type “else,” and then automatically returns a string and adds curly braces. Sort of:

else { } 

I can not imagine that I am the only one who often puts single-line players after the other and prefers no braces. How to stop this?

+6
source share
4 answers

Well, finally it turned out that the hell does it. I have ReSharper installed on this computer, and apparently the keyword “else” is a ReSharper autocomplete keyword. So even after I turned off brace completion, ReSharper still kicked and added them. Fury. To stop this, you must disable ReSharper autofill.

+2
source

I also found this behavior very annoying.

My first attempt was to open the template explorer (ReSharper / Templates Explorer ...) by selecting C # and then unchecking the "else" checkbox. This got rid of the braces. Unfortunately, by pressing enter after "else", now just added space! I had to press twice. Not quite what I was hoping for.

But if you double-click on the else template, it will open an editor where you can specify what is happening. I found that simply removing the curly braces gave me the functionality that I wanted - by pressing the enter button after the other now put me in a new line, folded under the other - without braces.

To do this, you need to open the Resharper Templates Explorer, select the C # area, then double-click the else template and remove the curly braces. Your snippet should look like this (just two lines):

 else $END$ 

This works in Resharper 6.1 and Visual Studio 2008. I have no idea about other software versions.

+12
source

I don’t think there is a way to turn off the automatic brace filling for specific keywords. If you go to:

 Tools -> Options -> Text Editor -> C# -> Formatting 

You will find various formatting options. You can turn off automatic completion altogether or affect padding, etc., but I don’t see a way to turn off automatic completion of a comma for certain keywords.

0
source

Do you use productivity tools ? You can disable it in "Tools", "Options", "Power Tools Performance", "Automatic completion of fixation." (I know that I know)

0
source

Source: https://habr.com/ru/post/892573/


All Articles