How to automatically collapse some comments in Visual Studio 2010?

My colleague uses the abomination text editor , which usually leaves comment blocks in the entire code. Needless to say, this is driving me crazy. Comment blocks are as follows:

/* EasyCODE ) */
/* EasyCODE ( 0 
WndProc */
/* EasyCODE F */

i.e. they all start with EasyCODE, and most of them span multiple lines. Fortunately, VS2010 can collapse comment blocks, so I don't need to see them all the time.

Is there a way to automate this? A way to automatically collapse all these terrible blocks EasyCODEwould be peppy!

+1
source share
2

, . EasyCode, , .

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a ' remove for VS2008
Imports EnvDTE100 ' remove for VS2008
Imports System.Diagnostics
Imports System.Collections.Generic

Public Module HideEasyCODEComments
    ''
    '' Collapse all EasyCODE comment blocks
    ''
    Sub ToggleSummaryCommentsOutlineExpansion()
        If (DTE.ActiveDocument Is Nothing) Then
            Exit Sub
        End If

        If (DTE.UndoContext.IsOpen) Then
            DTE.UndoContext.Close()
        End If

        DTE.SuppressUI = True

        Try
            DTE.UndoContext.Open("ToggleSummaryCommentsOutline")
        Catch
        End Try

        Dim objSelection As TextSelection = DTE.ActiveDocument.Selection
        Dim line As Integer = objSelection.CurrentLine
        objSelection.StartOfDocument()

        ' find all EasyCODE blocks
        While objSelection.FindText("^.*\/\* EasyCODE.*((\n.*\*\/)|(\n.*\/\*.*)|(\n\/\/.*))*", vsFindOptions.vsFindOptionsRegularExpression)
            DTE.ExecuteCommand("Edit.HideSelection")
        End While
        objSelection.StartOfDocument()
        objSelection.GotoLine(line)

        DTE.UndoContext.Close()
        DTE.SuppressUI = False
    End Sub

End Module

IDE (Tools- > Macros- > Macro IDE), , (Tools- > Options- > Environment- > Keyboard, ). , EasyCode .

!

+2

. "/ " (Ctrl + M Ctrl + H). .

.

0

Source: https://habr.com/ru/post/1765783/


All Articles