Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does anyone change the Visual Studio default bracing style? - Is there a standard?

Tags:

I find the default bracing style a bit wasteful on line count eg...

function foo() {     if (...)     {         ...     }     else     {         ...     } } 

would, if I was writing in JavaScript for example be written like...

function foo() {     if (...) {         ...     } else {         ...     } } 

...which I understand may also not be to peoples' tastes.

But the question(s) is/are do you turn off the VS formatting style and use your own rules? What is the opinion of this in the industry when many people are working on the same code-base? Is it better just to stick to the default just for simplicity/uniformity?

like image 816
El Ronnoco Avatar asked Jan 07 '11 09:01

El Ronnoco


People also ask

How to change Code Style in visual studio?

Code style preferences can be set for all of your C# and Visual Basic projects by opening the Options dialog box from the Tools menu. In the Options dialog box, select Text Editor > [C# or Basic] > Code Style > General.

Where is Visual Studio 2019 preferences?

On Windows/Linux - File > Preferences > Settings.

How do I clean up Visual Studio?

Microsoft documentation from August 2021 says: "For C# code files, Visual Studio 2019 has a Code Cleanup button at the bottom of the editor (keyboard: Ctrl+K, Ctrl+E) to apply code styles from an EditorConfig file or from the Code Style options page.


1 Answers

You need to have coding standards. There are no best standards. Standards such as having a brace on its own line or on the same line is a decision that one may take looking at comfort level of developers involved rather than on industry opinion (which will be typically divided).

But once standard is defined, you should adjust your tool to suit you. For example, you can change VS settings (Tools -> Option) as per your standards and then export those option groups as .vssettings file, keep it at central location/code repository and ask every dev to import it.

like image 107
VinayC Avatar answered Sep 21 '22 15:09

VinayC