?
Solved

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

Posted on 2012-03-10
4
Medium Priority
?
392 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
[X]
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
  • 2
4 Comments
 
LVL 75

Accepted Solution

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

800 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