change auto-indent style

Hello, I'm trying out webstorm and I would like to change the style of the auto-indent.

Right now, when I start writing a function for example, it indents automatically.

function a()
{
     var b;
}

but I would like to be:

function a()
{
var b;
}


Also with ifs.

if ( something )
{
     var b;
}

and would prefer:

if ( something )
     {
     var b;
     }

How do you change it?

4 comments
Comment actions Permalink

There doesn't appear to be an easy way to get both the behaviours you are after, however, you can get close:

  1. In File > Settings > Code Style > PHP
  2. go to the Wrapping and Braces tab
  3. Under Braces Placement, set both 'In Function Declaration' and 'Other' to 'Next line shifted'.


This results in functions/ifs/loops/etc that have their code in-line with their surrounding braces, though as stated, the functions have their braces indented, which is slightly different from what you wanted.

0
Comment actions Permalink

Thanks for the suggestion, but for whatever reason, I don't get the code like in the settings example:

function a()
     {
     return 0;
     }

but:

function a()
     {
          return 0;
     }

yea, isn't really this :(

0
Comment actions Permalink

Were you able to resolve this issue? I can't seem to find a solution, it still automatically indents after you open your curly brace.

0
Comment actions Permalink

Setting Code Style/javaScript/Wrapping and Braces, 'In Function Declaration' and 'Other' to 'Next line shifted' affects auto-formatter (the code is reformatted accordingly on Ctrl+Alt+L), but doesn't affect 'Smart Indent' behavior. Logged as http://youtrack.jetbrains.com/issue/WEB-11401, please follow it for updates

0

Please sign in to leave a comment.