Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Immediate Window automatic cleaning in Visual Studio

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.

like image 636
Lyubomyr Shaydariv Avatar asked Feb 25 '10 12:02

Lyubomyr Shaydariv


1 Answers

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.

like image 72
Peter Macej Avatar answered Nov 16 '22 02:11

Peter Macej