Matching tag in HTML keyboard shortcut

Is there a shortcut in Visual Studio (2008) that will allow me to jump to matching HTML tag... as CTRL+] does for matching braces when you are in code view?

Example:

<table>
  <tr>
    <td>
    </td>
  </tr>
</table|>

Cursor is on closing table tag and I would like to press something like CTRL+] to jump to opening table tag.

Any ideas?


Ok here is the answer as macro which i've built which does it (toggle ) including go to focus :

Here is the demo :

在这里输入图像描述

And here is the code , enjoy !

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Windows.Forms

Public Module Module2
    Sub beginToEnd()

        'Place cursor somewhere in beginning tag, run macro, to select from beginning to End Tag

        DTE.ActiveDocument.Selection.SelectLine()
        Dim objSel As TextSelection = DTE.ActiveDocument.Selection
        Dim topPoint As TextPoint = objSel.TopPoint
        Dim lTopLine As Long = topPoint.Line
        objSel.GotoLine(lTopLine, False)
        '  DTE.ActiveDocument.Selection.StartOfLine()
        DTE.ActiveDocument.Selection.SelectLine()
        Dim line1 As String = DTE.ActiveDocument.Selection.Text()
        If InStr(line1, "</") Then

            ' MsgBox(line1)
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
            DTE.ActiveDocument.Selection.EndOfLine()
            DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, True)
            objSel.GotoLine(lTopLine, False)
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")


        Else

            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
            DTE.ActiveDocument.Selection.EndOfLine(False)
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")

        End If
        DTE.ActiveDocument.Selection.SelectLine()
        Dim line2 As String = DTE.ActiveDocument.Selection.Text()
        Dim objSel3 As TextSelection = DTE.ActiveDocument.Selection
        Dim topPoint3 As TextPoint = objSel3.TopPoint
        Dim lTopLine3 As Long = topPoint3.Line
        objSel.GotoLine(lTopLine3, False)
        DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, False)


    End Sub



End Module

I search and couldn't found direct short cut. But you can use..

If you want to go starting matching HTML tag, then follow below steps.

  • Place cursor at ending matching HTML tag.
  • Press Ctrl+M+M [To Collapse entire tag]
  • Press Home Key [To place cursor at before starting tag]
  • Press Ctrl+M+M [To Expand entire tag]
  • If you want to go ending matching HTML tag, then follow below steps.

  • Place cursor at starting matching HTML tag.
  • Press Ctrl+M+M [To Collapse entire tag]
  • Press End Key [To place cursor next to ending tag]
  • Press Ctrl+M+M [To Expand entire tag]

  • In Visual Studio 2015 , this is now supported with the usual bracket matching keystrokes;

  • ctrl+] jumps from the start tag to the end tag.
  • ctrl+shift+] selects everything between the start tag and the end tag.
  • It seems pretty sensitive, though, and to select an entire tag and its contents you need to start right on the < that opens the tag.

    链接地址: http://www.djcxy.com/p/95318.html

    上一篇: 在“If / End If”之间跳转的键盘快捷键

    下一篇: 在HTML键盘快捷键中匹配标签