Visual Studio - How to disable autoformat/correct while running macro?

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2009-07-27T15:57:05Z Indexed on 2010/03/20 2:41 UTC
Read the original article Hit count: 518

Filed under:
|
|

When running a macro that changes the selected text, tags are automatically closed and the text formatted. How can I prevent that from happening?

For example, wrapping text in a tag:

DTE.ActiveDocument.Selection.Text = String.Format("<tag>{0}</tag>", DTE.ActiveDocument.Selection.Text)

Ends up with two closing tags:

<tag>Text</tag></tag>

Even stranger, multiple lines fails:

<li>One</li>
<li>Two</li>
<li>Three</li>

An ends up as

<ul>            <li>One</li>
            <li>Two</li>
                        <li>Three</li></li></ul>

How can I prevent that? As can be seen by the last example, the formatting is wrong and there is an extra </li>

© Stack Overflow or respective owner

Related posts about visual-studio

Related posts about autocorrect