Working on a website in Visual Studio I found myself annoyed again by the extra spaces around <script /> tags when I type Ctrl+K+D (Format Code). It turns out however that this is easy to change. As with most Visual Studio customizations, the answer lies in Tools > Options.
Under Tools > Options > Text Editor > Html > Format, click the ‘Tag Specific Options…’ button. Under ‘Client HTML Tags’ find ‘script’. Finally, under ‘Line breaks’, change the default value from “2 Before opening, within, and 2 after closing” to “Before and After”, like the Rush song.
This isn’t specific to HTML though, most of the languages under Text Editor support formatting options. Another change I typically make is for CSS to use the Compact rules.
Happy Formatting!
