简体   繁体   English

在PhpStorm中按Enter键后的缩进

[英]Indents after pushing Enter button in PhpStorm

I've been using PhpStorm for a long time and I haven't had this problem before. 我已经使用PhpStorm很久了,以前没有遇到过这个问题。 The problem is that when I type some pare tag, for example, <div></div> (there is indent from the beginning of the line) and the cursor is in the middle of this tag and after I push Enter button the closing tag just goes to the beginning of the line. 问题是当我键入一些pare标记时,例如<div></div> (从行首开始有缩进),并且光标在该标记的中间,然后按Enter键后,关闭标签只是到行的开头。

The interesting fact that in .php file everything is OK. 有趣的事实是,在.php文件中,一切正常。 The problem only with .html extension. .html扩展名存在问题。 I just don't know what I could do to make IDE acts like this. 我只是不知道该怎么做才能使IDE像这样。

I have already checked all the adjusting in the Preferences -> Code style -> HTML. 我已经在“ Preferences -> Code style -> HTML.检查了所有调整Preferences -> Code style -> HTML. Everything is the same as in PHP (and I've pushed the button "Restore Defaults"). 一切都与PHP中的相同(并且我按下了“恢复默认值”按钮)。

It works like that (after pushing Enter button): 它的工作原理如下(按“ Enter”按钮后):

      <div>

</div>

And I want it be like that: 我希望这样:

     <div>

     </div>

From your other post: 在您的其他帖子中:

I put first some indent to the tag and than push "Enter button". 我先在标签上缩进一些,然后按“ Enter”按钮。 So the first part of the tag stays where it was, but the other goes to the beginning of the line 因此,标记的第一部分保留在原处,而另一部分移至行的开头

So, you have your code formatted manually so that the indentation differs from the one you'd get when performing Code > Reformat Code . 因此,您已手动设置了代码格式,以使缩进不同于执行Code> Reformat Code时所得到的缩进。 'Smart indent' (indenting code on Enter - Settings | Editor | General | Smart Keys , Enter section) doesn't care about your manual indentation, created indents are based on code style settings rather than your manually created indents. “智能缩进”Enter上的缩进代码- “设置” |“编辑器” |“常规” |“智能键” ,“ Enter”部分)并不关心您的手动缩进,创建的缩进基于代码样式设置而不是您手动创建的缩进。 You can turn it off - the next line will always be indented to the same level as previous in this case. 您可以将其关闭-在这种情况下,下一行将始终缩进与上一行相同的级别。

If reformatting the code with Code > Reformat Code doesn't help, it must be the issue with either the code formatting preferences or file associations... Do you have any custom plugins installed? 如果使用代码”>“重新格式化代码”来重新格式化代码无济于事,那么这可能是代码格式化首选项或文件关联的问题。是否安装了任何自定义插件? Svelte plugin, for example, registers .html files as Svelte Html Components ( https://github.com/dschulten/sveltejs-idea-plugin/issues/2 , https://github.com/dschulten/sveltejs-idea-plugin/issues/6 ), causing similar issues. 苗条插件,例如,寄存器.html文件作为苗条HTML组件https://github.com/dschulten/sveltejs-idea-plugin/issues/2https://github.com/dschulten/sveltejs-idea-plugin / issues / 6 ),从而导致类似的问题。

Please also check if Keep white spaces option is enabled in Settings | 另请检查在“设置” |“设置”中是否启用了 保留空白”选项 Editor | 编辑器 Code Style | 代码样式| HTML | HTML | Other - when it's ON, existing indents don't change on reformatting 其他 -启用后,现有缩进格式不会改变

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM