I have logged the issue here: https://github.com/SublimeTextIssues/Core/issues/1271
The reason for this behavior is because Sublime Text, by default, is set to preserve the indentation of comments. To disable this:
- Install Package Control if it is not already installed
- Install PackageResourceViewer if it is not already installed:
- Open the Command Palette
- Select
Package Control: Install Package
- Select
PackageResourceViewer
- Open the Command Palette
- Type
PRV: O
- Select
PackageResourceViewer: Open Resource
- Select
Default
- Select
Indentation Rules - Comments.tmPreferences
- Change the
<true/>
under <key>preserveIndent</key>
to <false/>
- Save the file
Reindentation will now work correctly with comments.
I would also recommend to edit the HTML indentation rules to ignore comments, so that it doesn't change indentation based on tags in comments. i.e. otherwise
<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>
would become:
<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>
To do this:
- Open Command Palette
- Type
PRV: O
- Select
PackageResourceViewer: Open Resource
- Select
HTML
- Select
Miscellaneous.tmPreferences
Change
<key>scope</key>
<string>text.html</string>
to
<key>scope</key>
<string>text.html - comment</string>
and
|-->
to
(?#|-->)
(this comments out the closing comment regex)
- Save it
However, when the next release of ST3 is available, it might be a good idea to then delete your overrides, in case it is fixed properly. This way, you will continue to get updates to these files, otherwise you will be stuck with the versions you have saved. To do this:
Preferences
-> Browse Packages
- Delete the
HTML
folder
- Go into the
Default
folder and delete the Indentation Rules - Comments.tmPreferences
file
If the problem wasn't fixed in the next build, you can simply recreate these changes.