Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 html indenting

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?

like image 201
user1226830 Avatar asked Feb 21 '23 04:02

user1226830


2 Answers

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.

like image 88
ntziolis Avatar answered Mar 11 '23 15:03

ntziolis


Ctrl+K then Ctrl+D, will format the current document.

Ctrl+K then Ctrl+F, will format the selected text.

like image 34
Jhankar Mahbub Avatar answered Mar 11 '23 15:03

Jhankar Mahbub