Break line on each tag attribute and keep them aligned in Visual Studio HTML code editor


  • Hello,

    Recently I asked this same question at StackOverflow:

    I'm interested in developing a really simple extension for VS that will fire when doing a Ctrl + K and then Ctrl + F (Format Selection for example). I couldn't find a good article on the matter. Something that goes straight to the point. It seems that material on this area is scarce and scaring! :D Just try a Google search...

    I saw this on this forum:

    I was able to download the VS 2012 SDK and test the code. It works perfectly. Now I think it's just a matter of knowing where to look after and reuse that code... :)

    Each HTML tag can have many attributes which are marked in red. So I think it's perfectly possible to recreate that tag placing a line break after each attribute and align them.

    What do you think about my question? Is a VS extension for the HTML editor something feasible in this case? Can you point me in the right direction? What classes should I be looking at to manipulate the tag and its attributes?

    Just to note: this functionality is already built in in the VS XAML editor. It's just not included in the HTML editor... Do you happen to know why?

    Thanks for any advice,

    Leniel Macaferi

    Thursday, February 14, 2013 2:49 PM


  • Creating a custom editor is not required, he simply needs to calculate the offset, insert a line break and N number of padding spaces after the linebreak.

    As for why it is available in one place and not the other, because different teams own the editors. One is written in native code iirc, the other managed, so sharing functionality between the two requires a bit of work, and if none of their customers have asked for it it is hard to justify doing that work over doing other work.

    Monday, February 18, 2013 3:37 AM

All replies