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

2

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.

Elver answered 5/4, 2012 at 14:44 Comment(3)
Filed a workaround with Eclipse: bugs.eclipse.org/bugs/show_bug.cgi?id=379114Elver
Are you using Aptana or JSBeautifier?Legislator
Seems incredible that it's still unresolved...Bemba
S
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.

Springs answered 22/8, 2013 at 9:8 Comment(0)
M
0

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.

Michaelmas answered 7/10, 2014 at 7:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.