Sub FMS_CommentCSTyle() Const cmntStart As String = "/*" Const cmntEnd As String = "*/" Dim usrSel As TextSelection = Nothing Dim buffer As String   Try    ' open undo buffer         DTE.UndoContext.Open("FMS Comments C style") ' store user selection usrSel = DTE.ActiveDocument.Selection ' store selected text for later buffer = DTE.ActiveDocument.Selection.Text ' single line in consideration ' with nothing highlighted : comment entire line ' similar to single line comment // If usrSel.TopPoint.EqualTo(usrSel.BottomPoint) Then ' move to beginning of line usrSel.MoveToLineAndOffset(usrSel.TopPoint.Line, 0) ' select to end of line usrSel.EndOfLine(True) ' get the newly selected line usrSel = DTE.ActiveDocument.Selection buffer = usrSel.Text End If ' end single line chk usrSel.Delete() usrSel.Insert(String.Concat(cmntStart, buffer, cmntEnd)) Catch e As System.Exception ' the macro failed        ' reasons could be : No editor open DTE.StatusBar.Text = "FMS Comments C Style macro failed.." DTE.StatusBar.Highlight(True) Finally ' close undo buffer DTE.UndoContext.Close() End Try End Sub Sub FMS_UncommentCStyle() Const cmntStart As String = "/*" Const cmntEnd As String = "*/" Dim usrSel As TextSelection = Nothing Dim buffer As String, newBuffer As String   Try ' open undo buffer DTE.UndoContext.Open("FMS Comments C style") ' store user selection usrSel = DTE.ActiveDocument.Selection ' store selected text for later buffer = DTE.ActiveDocument.Selection.Text ' single line in consideration ' with nothing highlighted : comment entire line ' similar to single line comment // If usrSel.TopPoint.EqualTo(usrSel.BottomPoint) Then ' move to beginning of line usrSel.MoveToLineAndOffset(usrSel.TopPoint.Line, 0) ' select to end of line usrSel.EndOfLine(True) ' get the newly selected line usrSel = DTE.ActiveDocument.Selection buffer = usrSel.Text End If ' end single line chk ' replace start & end of comment buffer = buffer.Replace(cmntStart, String.Empty) buffer = buffer.Replace(cmntEnd, String.Empty)      usrSel.Delete() usrSel.Insert(buffer) Catch e As System.Exception ' the macro failed ' reasons could be : no editor open DTE.StatusBar.Text = "FMS Comments C Style macro failed.." DTE.StatusBar.Highlight(True) Finally ' close undo buffer DTE.UndoContext.Close() End Try End Sub