Solved

Is there a way to change the bracket setting in MS Visual Studio?

Posted on 2012-03-10
4
385 Views
Last Modified: 2012-03-10
Is there a way to change the bracket setting in MS Visual Studio? I'm using VS 2010 but I would imagine it's the same with older version. Currently Visual Studio is encouraging me to position my brackets to be like this:
if (_product == null)
{
    _product = new Product(ProductId);
}

Open in new window

But I would prefer for it to default to this:
if (_product == null) {
    _product = new Product(ProductId);
}

Open in new window

Is it possible to change the VS 2010 settings to do it my way? And if so, how?

Also, is my way considered bad practice? Or do good majority out there typically type my way as well in C#?
0
Comment
Question by:Eindoofus
  • 2
4 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
Go to Tools->Options->Text Editor->C#->Formatting->New Lines. You can uncheck the appropriate boxes. You should be able to see a preview of the options behavior in the pane below the checkboxes.

e.g.

Screenshot
As far as "practice" goes, it's more of preference AFAIK. The syntax you prefer is the C/Java style, I believe. MS advocates brace on a new line.
0
 
LVL 12

Expert Comment

by:mwochnick
Comment Utility
try Tools|Options|Text Editor
C#
- Formatting
-- New Lines
--- Place open brace on same line for control blocks
0
 

Author Comment

by:Eindoofus
Comment Utility
Thanks :)
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
I think I'm the only one in my department that even cares about indentation!! If it came down to it, you could certainly flip the appropriate switches to code in your style, and then when it came time to check-in or submit the code, you could flip them back and reformat the document in the desired format. VS does a pretty good job of indenting where expected (assuming you set your options correctly). I very much appreciate the auto-format you can enable that will indent your code as you type a closing brace (probably gives me a leg up on formatting as compared to my peers!).
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now