When you run a macro that changes the selected text, the tags are automatically closed and the text is formatted. How can I prevent this?
For example, wrapping text in a tag:
DTE.ActiveDocument.Selection.Text = String.Format("<tag>{0}</tag>", DTE.ActiveDocument.Selection.Text)
Ends with two closing tags:
<tag>Text</tag></tag>
Even a stranger, a few lines fail:
<li>One</li>
<li>Two</li>
<li>Three</li>
An ends as
<ul> <li>One</li>
<li>Two</li>
<li>Three</li></li></ul>
How can I prevent this? As you can see from the last example, formatting is incorrect and there is additional</li>
SamWM source
share