在Visual Studio中运行宏直到文件末尾

nik*_*3ro 6 c# macros visual-studio-2008 visual-studio

Visual Studio 2008是否有一些AddIn或扩展,允许我运行宏直到文件结束?我真的很讨厌按住CTRL + SHIFT + P并等到文件结束.

小智 5

您可以录制宏,然后打开宏IDE(Alt + F11)并将预先录制的宏放在如下的循环中:

Sub TemporaryMacro()
    selection = DTE.ActiveDocument.Selection()
    anchorPoint = selection.AnchorPoint.CreateEditPoint
    selection.EndOfDocument(True)
    endPoint = selection.BottomPoint.CreateEditPoint()
    selection.MoveToPoint(anchorPoint)

    Do While True
        isEOF = DTE.ActiveDocument.Selection.TopPoint.CreateEditPoint().Line = endPoint.Line
        If (isEOF) Then
            Exit Do
        End If

        ' Prerecorded macro
        DTE.ActiveDocument.Selection.Text = " "
        DTE.ActiveDocument.Selection.LineDown()
        DTE.ActiveDocument.Selection.CharLeft()
        ' End of prerecorder macro

    Loop
End Sub
Run Code Online (Sandbox Code Playgroud)