Auto-formatting Javascript arrays into new lines in Aptana Studio 3
-
27-06-2021 - |
Question
It seems that Aptana Studio 3 only has the option for auto-formatting Javascript arrays into one line. I was wondering if there is a way to make Aptana Studio 3 auto-format Javascript arrays into a new line for each array element (similar to the option for auto-formatting php arrays - "Insert new line between array creation elements").
For example, I want
var dataset = [1, 2, 3, 4];
to become
var dataset = [1,
2,
3,
4];
Solution
What I usually do in Aptana is this:
var dataset = [
//
1,
//
2,
//
3,
//
4
//
];
And Aptana is dumb enough to be smart about not trying to interpolate with line comments.
Then you can even have:
var dataset = [
//
[1, 3, 5, 7, 9],
//
[2, 4, 6, 8, 0],
//
'Some string here',
//
function( ) {
return 'even a function';
}
//
];
OTHER TIPS
try this,
var dataset = [1,//
2,//
3,//
4];
Aptana doesnt put it in one line, if its followed by a comment.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow