【问题标题】:How can I get Sublime to autocomplete the closing tag as I start typing it?当我开始输入结束标签时,如何让 Sublime 自动完成它?
【发布时间】:2015-02-16 19:56:25
【问题描述】:

假设我输入<div></。如何让 Sublime 自动填写其余部分(div>)?

【问题讨论】:

    标签: html sublimetext2 sublimetext sublimetext3


    【解决方案1】:

    你可以输入不带的div,然后按TAB,你会得到 <.div><.>

    或者,您可以使用 键入第一个 div,然后按 ALT+。用于窗口上的结束标记

    【讨论】:

      【解决方案2】:

      Emmet 插件很好地支持了这一点:https://github.com/sergeche/emmet-sublime

      【讨论】:

      • 在我拥有的另一台机器上,Sublime 本地执行此操作。我在那里查看了我的设置,但找不到。
      • 如果你输入标签然后按[tab],它有什么作用吗?
      • 它只是用制表符缩进当前行。
      【解决方案3】:

      默认情况下应该为 html 启用自动完成功能,如果没有,您可以在首选项/文件设置下进行设置

      sublime docs

      【讨论】:

      • auto_complete 只是在您键入时显示一个预测菜单,它不符合我的要求。
      【解决方案4】:

      我认为这里缺少键绑定。在您的用户密钥绑定中添加以下内容。
      Menu » Preferences » Key Bindings - User

      // HTML, XML close tag
      { "keys": ["/"], "command": "close_tag", "args": { "insert_slash": true }, "context":
          [
              { "key": "selector", "operator": "equal", "operand": "(text.html, text.xml) - string - comment", "match_all": true },
              { "key": "preceding_text", "operator": "regex_match", "operand": ".*<$", "match_all": true },
              { "key": "setting.auto_close_tags" }
          ]
      }
      

      【讨论】:

        猜你喜欢
        • 2012-05-21
        • 2011-11-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-08
        • 1970-01-01
        • 1970-01-01
        • 2019-02-11
        相关资源
        最近更新 更多