Visual Studio IDE Macro

Posted on 2006-04-28
Last Modified: 2010-04-24
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
Question by:dave4dl
    LVL 48

    Accepted Solution

    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.
    LVL 15

    Author Comment

    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).


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now