我在这里记录了这个问题:https ://github.com/SublimeTextIssues/Core/issues/1271
这种行为的原因是因为默认情况下,Sublime Text 设置为保留注释的缩进。要禁用此功能:
- 如果尚未安装Package Control ,请安装
- 如果尚未
安装PackageResourceViewer ,请安装:
- 打开命令面板
- 选择
Package Control: Install Package
- 选择
PackageResourceViewer
- 打开命令面板
- 类型
PRV: O
- 选择
PackageResourceViewer: Open Resource
- 选择
Default
- 选择
Indentation Rules - Comments.tmPreferences
<true/>
将下更改<key>preserveIndent</key>
为<false/>
- 保存文件
重新缩进现在可以与注释一起正常工作。
我还建议编辑 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: Open Resource
- 选择
HTML
- 选择
Miscellaneous.tmPreferences
改变
<key>scope</key>
<string>text.html</string>
到
<key>scope</key>
<string>text.html - comment</string>
和
|-->
到
(?#|-->)
(这评论了结束评论正则表达式)
- 保存
但是,当 ST3 的下一个版本可用时,最好删除您的覆盖,以防它被正确修复。这样,您将继续获得这些文件的更新,否则您将被保存的版本卡住。去做这个:
Preferences
->Browse Packages
- 删除
HTML
文件夹
- 进入
Default
文件夹并删除Indentation Rules - Comments.tmPreferences
文件
如果问题在下一个版本中没有得到解决,您可以简单地重新创建这些更改。