[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

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

        textSelect.SelectAll()
        documentText = textSelect.Text

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

        textSelect.Text = documentText
    End Sub

---------------------------------------
and for output i get:
blah1
        blah2
                blah3

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
0
dave4dl
Asked:
dave4dl
1 Solution
 
AlexFMCommented:
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.
0
 
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).

see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxmscdteobjectpropertiesmethodsevents.asp
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now