开发者

Converting tabs in leading whitespaces to double spaces in Visual Studio macro

开发者 https://www.devze.com 2023-04-12 21:05 出处:网络
I\'m trying to modify a VS macro I found on this site; the macro performs a transformation to a document when it is saved. I need the macro to transform the leading whitespaces such that each tab char

I'm trying to modify a VS macro I found on this site; the macro performs a transformation to a document when it is saved. I need the macro to transform the leading whitespaces such that each tab characters are replaced with two spaces but leave all the existing spaces intact. I tried the code below but it is not working the way I would like it to. May I get some help with it?

    If vsFindResult.vsFindResultReplaced = _
        DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, _
                         "^{ }*\t", _
                         vsFindOptions.vsFindOptionsRegularExpression, _
        开发者_运维问答                 "\1  ", _
                         vsFindTarget.vsFindTargetCurrentDocument, , , _
                         vsFindResultsLocation.vsFindResultsNone) Then
        document.Save()
    End If


Try the "Productivity Power Tools" from Microsoft. Between many other tools there is a tool called "Fix Mixed Tabs" which is doing exactly what you're searching for.

Link to description and download Productivity Power Tools in Visual Studio Gallery

0

精彩评论

暂无评论...
验证码 换一张
取 消