Can Eclipse format comma-separated statements (var a = 1, b=2;) on different lines?

Go To StackoverFlow.com

9

I am using Eclipse JSDT and the default formatting settings change something like

var a = 1,
    b = 2;

to be on one ugly line.

The style before formatting is recommended by JSLint, so I am wondering can Eclipse be set to format it this way? The existing formatter settings does not offer controls over the comma statement it seems.

2012-04-05 14:44
by billc.cn
Filed a workaround with Eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=37911 - billc.cn 2012-05-11 12:28
Are you using Aptana or JSBeautifier - Scottux 2013-08-14 14:54
Seems incredible that it's still unresolved.. - Miquel 2015-05-25 15:03


1

Following JavaScript Beautifier plug-in is available for Eclipse.

https://github.com/atlanto/eclipse-javascript-formatter

It can be used to span single statement - multiple variable declarations into multiple lines.

More information about using the above plug-in is given in the README.md file.

2013-08-22 09:08
by Sasidhar Vanga
Link is not workin - Miquel 2015-05-25 15:42


-1

Its a little late I guess, but I do this:

var container = require('../core/container'),
/**/uuid = require('node-uuid'),
/**/validations = require('../util/validations');

Or I do this:

var container = require('../core/container'), //
uuid = require('node-uuid'), //
validations = require('../util/validations');

The second one shifts the variables to the beginning of the line, but that's a trade off you'll have to live with.

2014-10-07 07:41
by Varun Achar
Ads