This question came up on the forums the other day. Basically somebody wanted to change the auto formatting features of Visual Studio so that their curly braces didnt get pushed down on to their own lines every time they wrote the next line.
An example of how visual studio will auto-format your methods out of the box:
public bool IsEnabled() { return true; }
However the user wanted to keep the first curly brace on the same line as the method signature like:
public bool IsEnabled() { return true; }
It's a matter of personal style. Personally I think it is less readable because it reduces the scanability of the code - you have to schwip your eyes over to the end of the method signature (which can be a variable length) to check where the start of the curly braces are.
Anyway I appreciate everyone has their preferences so this is how you set it up if you are excited about this same-line curly brace option:
- Click Tools | Options…
- Scroll down to the Text Editor node
- Expand the C# node
- Expand the Formatting node
- Click on the New Lines node
- You will see a list of options like in the image below which give you full control over when Visual Studio should put your open brace on a new line
Visual Web Developer 2008 Users
You might be wondering if this option is available to you, or you might have tried to follow the tutorial above and found out you cant find the nodes I described?
Well it is possible to configure this in VWD 2008 - the only difference is that after step 1 you need to tick the little checkbox that says "Show all settings".
3 comments :
Ah, this was exactly what I was looking for... curse that crafty "show all settings" button. Thank you, kind sir!
It's not a matter of personal choice, we don't put curly braces on a new line due to semi-colon insertion:
http://robertnyman.com/2008/10/16/beware-of-javascript-semicolon-insertion/
Thanks - exactly what I was looking for. Was searching to edit templates !!
Post a Comment