在 HTML 中按 Enter 键扩展单行标签时自动缩进新行 [英] Auto-indent new line when hitting enter to expand one-line tag in HTML

查看:31
本文介绍了在 HTML 中按 Enter 键扩展单行标签时自动缩进新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让这个工作流程在 Sublime Text 2 中使用 HTML:

I would like to have this work flow working with HTML in Sublime Text 2:

  1. 创建 HTML 标签(例如 ctrl + shift + W)
  2. TAB(将光标放在内容区域)
  3. 进入

由此产生(单词HERE"表示光标所在的位置):

Resulting with this (the word "HERE" indicates where the cursor should be):

<p>
    HERE
</p>

但这就是我得到的(HERE"这个词仍然表示光标的位置):

But instead this is what I get (the word "HERE" still indicating the cursor's position):

<p>
HERE</p>

这要求你

  1. 输入(再次)
  2. 箭头 + TAB
  3. 箭头 + TAB(第二次)

推荐答案

尝试在您的用户键绑定中添加以下内容.

Try adding the following in your user key bindings.

{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
    [
        { "key": "setting.auto_indent", "operator": "equal", "operand": true },
        { "key": "selector", "operator": "equal", "operand": "meta.scope.between-tag-pair", "match_all": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
    ]
}

这篇关于在 HTML 中按 Enter 键扩展单行标签时自动缩进新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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