In visual studio, when I paste an html snippet into the source window of an aspx/ascx file the IDE re-indents the contents. For instance, if I paste this ...
<div><ul><li><a href="#">Item 1</a></li><li>
<a href="#">Item 2</a></li><li><a href="#">Item 3</a></li></ul>/div>
.. the ide will reformat the text to ....
<div>
<ul>
<li><a href="#">Item 1</a></li><li><a href="#">Item 2</a></li><li><a
href="#">Item 3</a></li></ul>
</div>
But really, I want the html formatted like this ...
<div>
<ul>
<li>
<a href="#">Item 1</a>
</li>
<li>
<a href="#">Item 2</a>
</li>
<li>
<a href="#">Item 3</a>
</li>
</ul>
</div>
How do I change the way VS indents html to the above?
You can change this by introducing custom formatting for the text (HTML) editor, got to:
Options -> Text Editor -> HTML -> Formatting -> Tag Specific Options (Button)
-> Client HTML Tags -> a -> Set Line breaks dropdown to Before and after
Do this for all the tags you want formatted differently.
Ctrl+K then Ctrl+D, will format the current document.
Ctrl+K then Ctrl+F, will format the selected text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With