简体   繁体   English

Phpstorm不会在输入时缩进新行

[英]Phpstorm doesn't indent new lines on enter

Code inside <?php ?> doesn't always get indented in PhpStorm. <?php ?>中的代码并不总是在PhpStorm中缩进。 It acts like this: 它的行为如下:

<?php
  echo 's';//PRESS ENTER
//caret jumps here

  if($boolean){//PRESS ENTER
    //caret jumps here(as expected)
  }
?>

How to fix this? 如何解决这个问题?

By default, PHP code is only indented in a code block ( {...} or an array definition, like array(...) ). 默认情况下,PHP代码仅在代码块( {...}或数组定义(如array(...) )中缩进。 In other words, by default, PHPStorm formats code like this: 换句话说,默认情况下,PHPStorm格式化代码如下:

<?php
echo 's';//PRESS ENTER
//caret jumps here

if($boolean){//PRESS ENTER
    //caret jumps here(as expected)
}
?>

To make it indent inside the <?php ... ?> tags, go to Preferences > Editor > Code Style > PHP > Other and check "Indent code in PHP tags", like this: 要在<?php ... ?>标记内缩进,请转到“首选项”>“编辑器”>“代码样式”>“PHP”>“其他”,然后选中“在PHP标记中缩进代码”,如下所示:

PHPStorm PHP Code Style配置截图

You can see both the check box and the resulting formatting in the image above. 您可以在上图中看到复选框和结果格式。

I have some few updated code with PHPStorm . 我用PHPStorm有一些更新的代码。

Import this setting to yours. 将此设置导入您的设置。 It has lot features associate with this. 它有很多与此相关的功能。

  1. Php
  2. SQL SQL
  3. CSS CSS
  4. JS JS

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

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