It's not as simple as JaredPar suggested, but I'm not a macro level expert either.
This works for (), {} and []
Sub DeleteMatchingBrace() Dim sel As TextSelection = DTE.ActiveDocument.Selection Dim ap As VirtualPoint = sel.ActivePoint If (sel.Text() <> "") Then Exit Sub ' reposition DTE.ExecuteCommand("Edit.GoToBrace") : DTE.ExecuteCommand("Edit.GoToBrace") If (ap.DisplayColumn <= ap.LineLength) Then sel.CharRight(True) Dim c As String = sel.Text Dim isRight As Boolean = False If (c <> "(" And c <> "[" And c <> "{") Then sel.CharLeft(True, 1 + IIf(c = "", 0, 1)) c = sel.Text sel.CharRight() If (c <> ")" And c <> "]" And c <> "}") Then Exit Sub isRight = True End If Dim line = ap.Line Dim pos = ap.DisplayColumn DTE.ExecuteCommand("Edit.GoToBrace") If (isRight) Then sel.CharRight(True) Else sel.CharLeft(True) sel.Text = "" If (isRight And line = ap.Line) Then pos = pos - 1 sel.MoveToDisplayColumn(line, pos) sel.CharLeft(True) sel.Text = "" End Sub
Then add a shortcut to this macro in VS.
source share