Visual Studio IDE Macro

I am trying to write out a bit of code in Visual Studio .NET through a macro and it (the macro) insists on adding tabs at the beginning of most lines of code

Macro code:

    Sub moveXMLData(ByVal curDoc As EnvDTE.Document)
        Dim textDoc As TextDocument = DirectCast(curDoc.Object("TextDocument"), EnvDTE.TextDocument)
        Dim textSelect As TextSelection = textDoc.Selection
        Dim documentText As String

        documentText = textSelect.Text

        documentText = "blah1" & vbcrlf & "blah2" & vbCrLf & "blah3"

        textSelect.Text = documentText
    End Sub

and for output i get:

How can i stop this behavior (preferably from the code).  I am not too interested in a solution along the lines of documentText = documentText.replace(vbtab,"").

I want to know the correct way to write out text so that the tabs are not added.

Thank you
LVL 15
Who is Participating?
This is not solution, just direction: you need to find the way to turn off auto-formatting. Open source file and type:
blah1 <Enter>
blah2 <Enter>
blah3 <Enter>

You will get the same result. BTW, if Tabs are off, you will get spaces according to editor settings (indentation). Try to turn off this feature im macro, if it is possible.
dave4dlAuthor Commented:
Thanks for the post Alex.

As a stop-gap solution I had turned off this (auto tab) feature as well as the other code validation/auto code stuff (using the IDE menus) and that seems to be working for now but i will have to remember to go turn it all back on.  I am sure there is a way to do this through an envDTE but for now i dont have the time to look it up.

If someone wants some of the points for this question they could look up how to turn those off and on.  HTML/XML specific settings are the most important for what i am doing but a list of all auto code setting to turn off would be good).

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.