これを行うマクロを次に示します。キャッチされない奇妙な 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 で新しいマクロを作成し ([ツール] -> [マクロ] -> [マクロ IDE])、上記のコードを貼り付け、それにキーボード ショートカットを割り当てます ([ツール] -> [オプション] -> [環境] -> [キーボード]、リストボックス)。キーボード ショートカットを押すと、すべての EasyCode コメントが消えます。
楽しむ!