崇高文字的缩进错误 [英] Indentation Error with Sublime Text

查看:102
本文介绍了崇高文字的缩进错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Sublime Text 3中的HTML自动缩进功能.我在html中有一些块注释,然后选择Edit> Line> Reindent起作用,直到遇到块注释为止.

I'm trying to use the auto-indentation feature in Sublime Text 3 for HTML. I've got some block comments in the html and selecting Edit>Line>Reindent works until it hits a block comment.

尝试在此处重新缩进示例:

Try to reindent the example here:

<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

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:

  1. 如果尚未安装 Package Control ,请安装
  2. 如果尚未安装 PackageResourceViewer ,请安装:
    • 打开命令面板
    • 选择Package Control: Install Package
    • 选择PackageResourceViewer
  1. Install Package Control if it is not already installed
  2. Install PackageResourceViewer if it is not already installed:
    • Open the Command Palette
    • Select Package Control: Install Package
    • Select PackageResourceViewer

重新缩进现在可以在注释中正常使用.

Reindentation will now work correctly with comments.

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

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>

将成为:

<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>

要这样做:

  1. 打开命令面板
  2. 键入PRV: O
  3. 选择PackageResourceViewer: Open Resource
  4. 选择HTML
  5. 选择Miscellaneous.tmPreferences
  6. 更改

  1. Open Command Palette
  2. Type PRV: O
  3. Select PackageResourceViewer: Open Resource
  4. Select HTML
  5. Select Miscellaneous.tmPreferences
  6. Change

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

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

|--&gt;

(?#|--&gt;)

(此注释掉了正则表达式正则表达式)

(this comments out the closing comment regex)


但是,当下一版本的ST3可用时,最好删除覆盖,以防其被正确修复.这样,您将继续获得这些文件的更新,否则您将被保存的版本所困扰.为此:


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:

  1. Preferences-> Browse Packages
  2. 删除HTML文件夹
  3. 进入Default文件夹并删除Indentation Rules - Comments.tmPreferences文件
  1. Preferences -> Browse Packages
  2. Delete the HTML folder
  3. 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.

这篇关于崇高文字的缩进错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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