문제

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];
도움이 되었습니까?

해결책

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';
    }

    //
    ];

다른 팁

try this,

var dataset = [1,//
               2,//
               3,//
               4];

Aptana doesnt put it in one line, if its followed by a comment.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top