Visual Studio 2008 SP1 Adds JavaScript Formatting
Just a "two thumbs up" for the addition of JavaScript™/JScript® formatting in Visual Studio 2008 Service Pack 1. I don't like leaving messy-looking code - especially since JavaScript makes the trip all the way to the client.
My formatting preference is to show opening and closing braces on a new line, so here's what you need to do in VS 2008:
- From the Tools menu, click Options.
- In the Options dialogue box, check Show All Settings in the bottom left corner. (BTW, it makes no sense for Microsoft to hide so many excellent tools.)
- Expand the Text Editor node, expand JScript and select Formatting.
- In the New Lines group box, check both Place Open Brace On New Line For Functions and Place Open Brace On New Line For Control Blocks.
- Click OK to close the Options dialogue box.
- In a .js page, press Ctrl+K, Ctrl+D (or, From the Edit menu, click Format Document).
This is one of those productivity improvements that makes the IDE indispensable.
Ken