Question

I have a question about debugging in Visual Studio. Is it possible to clear the Immediate Window in Visual Studio automatically before each startup of a debugged application? The >cls command and Context Menu->Clear All are useful, but they are not automatic and require personal attention each time I run the application. Again, System.Diagnostics.Debug.Print()|Write*() methods can only write messages to the Immediate Window, so >cls is not applicable. Is there any solution for the problem? (Currently I use VS 2008)

Thank you for suggestions.

Was it helpful?

Solution

Here is the macro that does it. In the Macros IDE Class View navigate to MyMacros - EnvironmentEvents. Open (double-click) EnvironmentEvents. Insert the following code inside module:

Private Sub BuildEvents_OnBuildDone( _
    ByVal Scope As EnvDTE.vsBuildScope, _
    ByVal Action As EnvDTE.vsBuildAction) _
    Handles BuildEvents.OnBuildDone

    Try
        Dim activeWin As Window = DTE.ActiveWindow
        Dim immedWin As Window = DTE.Windows.Item("{ECB7191A-597B-41F5-9843-03A4CF275DDE}")
        immedWin.Activate()
        DTE.ExecuteCommand("Edit.ClearAll")
        activeWin.Activate()
    Catch ex As Exception
    End Try
End Sub

Here you can see how it should look like: macro in EnvironmentEvents

See my quick tutorial how to create and execute VS macro.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top