HTML 键盘快捷键中的匹配标签 [英] Matching tag in HTML keyboard shortcut

查看:35
本文介绍了HTML 键盘快捷键中的匹配标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio (2008) 中是否有快捷方式可以让我跳转到匹配的 HTML 标签...就像 CTRL+] 在代码视图中匹配大括号时所做的那样?

示例:

<前><表格><tr><td></td></tr></表|>

光标在关闭表格标签上,我想按 CTRL+] 之类的东西跳转到打开表格标签.

有什么想法吗?

解决方案

好的,这是我构建的宏的答案,它执行(切换)包括转到焦点:

这是演示:

这是代码,享受吧!

导入系统进口 EnvDTE进口 EnvDTE80进口 EnvDTE90进口 EnvDTE90a进口EnvDTE100导入系统.诊断导入 System.Windows.Forms公共模块 Module2子开始到结束()'将光标放在开始标签的某处,运行宏,从开始到结束标签进行选择DTE.ActiveDocument.Selection.SelectLine()Dim objSel As TextSelection = DTE.ActiveDocument.SelectionDim topPoint As TextPoint = objSel.TopPointDim lTopLine As Long = topPoint.LineobjSel.GotoLine(lTopLine, False)' DTE.ActiveDocument.Selection.StartOfLine()DTE.ActiveDocument.Selection.SelectLine()Dim line1 As String = DTE.ActiveDocument.Selection.Text()如果 InStr(line1, "</") 那么' 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")别的DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")DTE.ActiveDocument.Selection.EndOfLine(False)DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")万一DTE.ActiveDocument.Selection.SelectLine()Dim line2 As String = DTE.ActiveDocument.Selection.Text()Dim objSel3 As TextSelection = DTE.ActiveDocument.SelectionDim topPoint3 As TextPoint = objSel3.TopPointDim lTopLine3 As Long = topPoint3.LineobjSel.GotoLine(lTopLine3, False)DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, False)结束子终端模块

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

这篇关于HTML 键盘快捷键中的匹配标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆