JScript Open Braces on a New Line

Tips Search

If you like the tips then you'll love the book!

Order your copy today:
http://www.amazon.com/gp/product/0735649928

JScript Open Braces on a New Line

  • Comments 3

Menu:  Tools -> Options -> Text Editor -> JScript -> Formatting
Versions:  2008,2010
Published:  12/13/2010
Code:  vstipEdit0087

 

By default, Visual Studio will format JScript functions and control blocks with the open brace on the same line as the declaration:

image

 

 

Without getting into the big debate about whether this is good or bad, let's assume you prefer to have your braces inline vertically:

image

 

 

Just go to Tools -> Options -> Text Editor -> JScript -> Formatting and choose if you want the open brace on a new line for functions, control blocks, or both:

image

  • Any plans to bring the Javascript formatting options on par with C#? (spaces inside parentheses etc).  It'd be great if you could have some predefined formatting templates or something (maybe chosen when VS is used for the first time).  You could have a "Nice" option with spaces everywhere they should be, and a "Retarded" option for the "squigglies on the same line" and "no spacing" crowd ;)

  • Chris -- Not sure as my connection with the web team isn't as close as with the VS team (working on changing it).  Let me ping someone and find out.

  • Okay the Web Team responded pretty quick but I dropped the ball and this sucker has been sitting in my inbox for a while.  Here is the answer:

    "While we certainly don’t have the same level of options as the C# editor does today, we do tweaking of a number of settings that affect formatting, including the new line example for braces that the user mentions. JavaScript is something we will be doing a lot of work on in the next version of Visual Studio so I expect more options to come."

    Special thanks to Damian Edwards and the legendary Scott Guthrie for the help :)

    Z

Page 1 of 1 (3 items)
Leave a Comment
  • Please add 2 and 8 and type the answer here:
  • Post