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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
billc.cn
  • 7,187
  • 3
  • 39
  • 79

2 Answers2

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.

Sasidhar Vanga
  • 3,384
  • 2
  • 26
  • 47
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.

Varun Achar
  • 14,781
  • 7
  • 57
  • 74