【问题标题】:How to move past the autocompleted tag in Visual Studio Code with HTML?如何使用 HTML 越过 Visual Studio Code 中的自动完成标记?
【发布时间】:2020-06-28 04:53:27
【问题描述】:

Look at the </title> tag in this image

在我在 Visual Studio Code 中编写 My Home Page 之后,有没有办法或任何组合键可以越过 </title> 标记? </title> 标签也会自己突出显示,所以一定有什么东西。我知道键盘上的end 键可以完成这项工作,但如果结束标记在下一行,则不会。

【问题讨论】:

    标签: javascript html visual-studio-code visual-studio-2015 tags


    【解决方案1】:

    您可以使用宏或此扩展名:Select By(也可以移动到由正则表达式确定的位置)。

    这进入你的 settings.json:

    "selectby.regexes": {
    
      "movePastTag": {
        "moveby": "</.*?>",
      }
    }
    

    然后是一个键绑定:

    {
      "key": "ctrl+alt+\\",               // whatever keybinding you want 
      "when": "editorTextFocus",
      "command": "moveby.regex",
      "args": [
        "movePastTag",                    // go past the next ending tag
        "moveby",
        "next",
        "end"
      ],
      "when": "editorTextFocus && editorLangId == html"  // to restrict it to html files
    },
    

    显然,对于格式不正确的 html,您可以击败我使用的简单正则表达式 &lt;/.*?&gt;"。同样使用嵌套标签,它只会跳转到任何类型的下一个结束标签,不一定是您所在标签的匹配结束标签。但只需按住 Ctrl+Alt kbd> 并继续点击 \ 以到达您想要的位置。

    有一个命令Go To Bracket 即使使用嵌套标签也会转到匹配的右括号,但它会转到标签的开头而不是您想要的结尾。还有一个 emmet 命令进入匹配的标签(但不是过去),你的光标必须在另一个标签中或旁边才能工作(而不是在你的例子中标签的 textContent 中)..

    【讨论】:

      【解决方案2】:

      按 Tab 是否完成了您要查找的内容?

      【讨论】:

        猜你喜欢
        • 2023-03-10
        • 2020-08-27
        • 1970-01-01
        • 2022-01-26
        • 2018-06-26
        • 2018-01-09
        • 2021-09-11
        • 1970-01-01
        • 2010-09-29
        相关资源
        最近更新 更多