The Site Doctor Blog

Footprints in the snow of a warped mind

< Back to Blog

Fix Visual Studio's crappy HTML formatting and automatic addition of id when pasting

Today I discovered two settings in Visual Studio that are about to transform my life (yes I realise that by just writing that I need to get out more.).

Anyway, the first stops Visual Studio formatting you code like this:

ScreenClip [4]

And transforms it into this:

ScreenClip [5]

To sort: Open Visual Studio, go to "Tools" -> "Options" -> "Text Editor" -> HTML -> "Formatting" and look for the button "Tag Specific Options" (in the bottom right). Click this button and you should get a window that looks like this:

ScreenClip [2]

Expand out "Default Settings" and then click "Client tag supports contents" and change "Line breaks" from "Before, after opening and after closing" to "Before and after" on "Client tag supports contents" and "Server tag supports contents".

This second one is another of those annoying bug bears of mine which is where Visual Studio insists on adding an id to every control you paste in -not something I really want in most cases. Anyway, sticking in the "Text Editor" -> "HTML" settings area, go to "Miscellaneous" and you'll see one there "Auto ID elements on paste in Source view" -uncheck that and click "OK" to save and apply your settings.


Looks like Visual Studio will become a decent HTML editor after all.

Author: Tim on

Liked this post? Got a suggestion? Leave a comment