Search code examples
phpstorm

Code Styling in phpStorm: from if(a==b){ to if (a == b) { on Enter, is it possible?


In phpStorm, when I type:

if(a==b){

(no spaces), and I push "Enter", is the any possibilities (settings/configurations) to phpStorm automatically reformat that code to:

if ( a == b ) {
    //cursor now here
    }
???

According to "Code Style" settings (rules) it SHOULD reformat, but it does not! (if I manually select the code and do "reformat code" - then it does! But I think it should be automatically done on Enter for just-typed string of code)

phpStorm v. 2.1


Solution

  • I didn't understand the question when replying the first time. Now I see the the problem is not about indent, but about spaces around the parenthesis.

    This behavior is by design, such spaces are not inserted on Enter, they are only inserted when you reformat code (or when you paste code and automatic reformat on paste is enabled).