Search code examples
visual-studio-2008ms-wordweb-configautoformatting

Auto formatting a web.config in Visual Studio 2008


I am currently in the process of creating API documentation using Microsoft Word 2007 and I need the user to cut and paste a section from the document into their web.config.

I formatted the section in the Microsoft Word document for easy readability and when I paste the formatted section into the web.config it maintains the style from the Microsoft Word document.

Is there a way for the user to auto format the section to their preferred web.config layout?

Edit

The documentation is formatted like so in Microsoft Word:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicEndPoint">
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>

When the user adds the section from the word document to their web.config, I want it to match their preferred formatting style. No line breaks, different indentation, etc.

Edit 1:

I removed all the page breaks from the configuration section and used Ctrl+K, Ctrl+D to format the entire document. I updated the code sample to reflect what is looks like in the Word document.


Solution

  • You could always recommend that your user just hits Ctrl+K, Ctrl+D which will reformat their web.config after pasting. (From the menu, Edit/Advanced/Format Document)

    Visual Studio does a pretty good job at keeping XML files formatted nicely.