Alex Lomia
Alex Lomia

Reputation: 7225

Phpstorm doesn't indent new lines on enter

Code inside <?php ?> doesn't always get indented in 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?

Upvotes: 3

Views: 1647

Answers (2)

elixenide
elixenide

Reputation: 44823

By default, PHP code is only indented in a code block ({...} or an array definition, like array(...)). In other words, by default, PHPStorm formats code like this:

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

PHPStorm PHP Code Style configuration screenshot

You can see both the check box and the resulting formatting in the image above.

Upvotes: 5

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

I have some few updated code with PHPStorm.

Import this setting to yours. It has lot features associate with this.

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

Upvotes: 0

Related Questions