html – Sublime文本的缩进错误

我正在尝试在Sublime Text 3中使用 HTML中的自动缩进功能.我在html中有一些块注释并选择了Edit> Line> Reindent工作直到它命中块注释.

尝试在这里重新举例:

<html>
<head>
<title>Testing Indent</title>
</head>
<body>
<table>
<tr>
<td>
Cell 1
</td>
</tr>
<tr>
Cell 2
<!--Block Comment Here
And a Little More Here
-->
</tr>
</table>
</body>
</html>

结果是这样的:

<html>
<head>
    <title>Testing Indent</title>
</head>
<body>
    <table>
        <tr>
            <td>
                Cell 1
            </td>
        </tr>
        <tr>
            <td>
                Cell 2
<!--Block Comment Here
And a Little More Here
-->
</td>
</tr>
</table>
</body>
</html>

有什么想法吗?

解决方法

我在这里记录了这个问题: https://github.com/SublimeTextIssues/Core/issues/1271

出现此行为的原因是因为默认情况下,Sublime Text设置为保留注释的缩进.要禁用此功能:

>如果尚未安装,请安装Package Control
>安装PackageResourceViewer(如果尚未安装):

>打开命令调色板
>选择包控制:安装包
>选择PackageResourceViewer

>打开命令调色板
>输入PRV:O
>选择PackageResourceViewer:打开资源
>选择默认
>选择缩进规则 – Comments.tmPreferences
>更改< true />在< key> preserveIndent< / key>下到< false />
>保存文件

Reindentation现在可以正常使用评论.

我还建议编辑HTML缩进规则以忽略注释,以便它不会根据注释中的标记更改缩进.即不然

<html>
<head>
<title>Testing Indent</title>
</head>
<body>
<table>
<tr>
<td>
Cell 1
</td>
</tr>
<tr>
Cell 2
<!--
Block Comment Here
<td>
And a Little More Here
</td>
-->
</tr>
</table>
</body>
</html>

会成为:

<html>
<head>
    <title>Testing Indent</title>
</head>
<body>
    <table>
        <tr>
            <td>
                Cell 1
            </td>
        </tr>
        <tr>
            Cell 2
            <!--
            Block Comment Here
            <td>
                And a Little More Here
            </td>
        -->
    </tr>
</table>
</body>
</html>

去做这个:

>打开命令面板
>输入PRV:O
>选择PackageResourceViewer:打开资源
>选择HTML
>选择Miscellaneous.tmPreferences
>改变

<key>scope</key>
<string>text.html</string>

<key>scope</key>
<string>text.html - comment</string>

|--&gt;

(?#|--&gt;)

(这评论结束评论正则表达式)
>保存

但是,当ST3的下一个版本可用时,如果它被正确修复,最好删除你的覆盖.这样,您将继续获得这些文件的更新,否则您将无法使用已保存的版本.去做这个:

>偏好 – >浏览包裹
>删除HTML文件夹
>进入默认文件夹并删除缩进规则 – Comments.tmPreferences文件

如果问题未在下一个版本中修复,则可以简单地重新创建这些更改.

相关文章

html5中section的用法
span标签和p标签的区别
jsp文件和html文件的区别是什么
span标签和div的区别
html颜色代码表大全
span标签的作用是什么