Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2012-03-10
4
387 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 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 37705541
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
ID: 37705546
try Tools|Options|Text Editor
C#
- Formatting
-- New Lines
--- Place open brace on same line for control blocks
0
 

Author Comment

by:Eindoofus
ID: 37705551
Thanks :)
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37705559
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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