Posts VS.NET Macro - Region Marker
Post
Cancel

VS.NET Macro - Region Marker

This is a pretty useful macro to add to the IDE.  It allows you to mark a region of your code, activate this macro and it will enclose the marked area in a #region block.

Sub OutlineSelection()

  Dim objTextDoc As TextDocument
  Dim title As String = InputBox("Enter the title for the #Region", "#Region code")
  objTextDoc = DTE.ActiveDocument.Object("TextDocument")
  objTextDoc.Selection.Insert("#Region """ & title & "" & vbNewLine, vsInsertFlags.vsInsertFlagsInsertAtStart)
  o
bjTextDoc.Selection.Insert(vbNewLine & "#End Region ", vsInsertFlags.vsInsertFlagsInsertAtEnd)
 
objTextDoc.Selection.SmartFormat()

End Sub

Thanks to Jason Tucker for pointing this out.

This post is licensed under CC BY 4.0 by the author.