Mik*_*rcy 7 html indentation auto-indent text-indent sublimetext3
我正在尝试在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>
Run Code Online (Sandbox Code Playgroud)
它结果是这样的:
<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>
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
Kei*_*all 19
我在这里记录了这个问题:https://github.com/SublimeTextIssues/Core/issues/1271
出现此行为的原因是因为默认情况下,Sublime Text设置为保留注释的缩进.要禁用此功能:
Package Control: Install PackagePackageResourceViewerPRV: OPackageResourceViewer: Open ResourceDefaultIndentation Rules - 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>
Run Code Online (Sandbox Code Playgroud)
会成为:
<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>
Run Code Online (Sandbox Code Playgroud)
去做这个:
PRV: OPackageResourceViewer: Open ResourceHTMLMiscellaneous.tmPreferences更改
<key>scope</key>
<string>text.html</string>
Run Code Online (Sandbox Code Playgroud)
至
<key>scope</key>
<string>text.html - comment</string>
Run Code Online (Sandbox Code Playgroud)
和
|-->
Run Code Online (Sandbox Code Playgroud)
至
(?#|-->)
Run Code Online (Sandbox Code Playgroud)
(这评论结束评论正则表达式)
但是,当ST3的下一个版本可用时,如果它被正确修复,那么最好删除你的覆盖.这样,您将继续获得这些文件的更新,否则您将无法使用已保存的版本.去做这个:
Preferences - > Browse PackagesHTML文件夹Default文件夹并删除该Indentation Rules - Comments.tmPreferences文件如果在下一个版本中没有修复问题,您只需重新创建这些更改即可.