How to format JavaScript Code?
Hi to all,
I just move to IntelliJ Ultimate 11.1 from VS2010(Visual Studio 2010).
I'm a JavaScript developer and what I'm really mising in IntelliJ or at least I dodn't found how to do it is:
In VS2010 when you write the following code:
function a(a){var a=1; if(a===1){a=2;}else {a=3}return a;}
and you close every a block of code with '}'
it will reformat the piece of code automatically with indents and you will get:
function a(a) {
var a=1;
if(a===1) {
a=2;
} else {
a=3;
}
return a;
}
If there is a plug-in or a way of do it this in IntelliJ?
Thanks in advanced
请先登录再写评论。
Hi Omer,
You can select the target text and run 'Reformat' action. It will change the text according to your code style settings.
Denis
Hi, thanks for your response,
this is what I'm currently doing, I was guessing if this can be done automatically like in VS2010, that is done every time I close a block, and not to mark the part of the code or all the file and run the 'Reformat' action.
Thanks
No, the IDE doens't offer such an ability.
But why do you code in a single line? You can just type <enter> whenever necessary on typing, the IDE will automatically position caret with the right indent on a new line.
Denis