views:

516

answers:

3

The HTML formatting in Visual Studio works great -- especially considering you can pick a selection and just format that. You can just select a tag or block, right click and do 'Format Selection'. You can also reformat the whole document.

However I like to use a lot of whitespace in my documents to keep things organized and the reformat HTML compresses (deletes!) this whitespace.

Are there any plugins, or external tools for formatting HTML that might make it possible to leave vertical space untouched?

Edit: Bonus points: If anybody has 2010 installed can they check if it already has this feature? If it DOESNT have this feature I'd like to submit a feature request. Fortunatly the new editor is much more extensible, but i dont know if that extends to customization of something liek this

A: 

Check the formatting options on Tools->Options->Text Editor->HTML.

Is there some sort of "preserve whitepace" setting? I do not see anything that would help him.
Andrew Hare
me either. what about in VS2010 ? anybody reading this got it installed
Simon_Weaver
+2  A: 

If the whitespace in your documents has some systematic logic to it,(such as, a Line break before and after each Table Tag) then you might be able to get the kind of behaviour you want when applying formatting.

Check out the options dialog from : Tools -> Options -> Text Editor -> HTML -> Format -> "Tag specific Options"

This pretty much allows you customize the formatting of each type of tag to a reasonably minute level. In your particular case, the "Line breaks" option might be useful or atleast relevant.

You might also like to try out a custom HTML formatter such as HTML Tidy. Many powerful editors like Notepad++ and UltraEdit have a built-in HTML Tidy module for formatting. Personally, though, I find the formatting capabilities of Visual Studio sufficient for most requirements.

Cerebrus
+1  A: 

The short answer is no, 2008 will always reformat it the way it has in its settings. You will have to configure the settings in Tag Specific Options to match how you like your HTML to display.

It can do up to two spaces before and after a tag, but unfortunately there's no way to maintain whitespace or formatting for comments (it only recognises start + end tags that are the same)

If you have problems with it matching your coding style, my question about this might help out

Chris S
keeping fingers crossed that VS 2010 will do it nicely
Simon_Weaver