Solved

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

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

Suggested Solutions

Title # Comments Views Activity
Adjust the codes 3 63
Windows Universal App 22 58
SQL State HYT00. Timeout expired proplem 8 42
Javascript function 3 15
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

732 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