Search code examples
javascriptsublimetext3js-beautify

avoid line breaks in sublime text3 in short functions with js beautifier


I'm using Sublime Text 3 with the JavaScript Beautify Package.

The code after beautifying looks like that:

var jobDimension = ndx.dimension(function(d) {
    return d.status;
});

But I want that it looks like that:

var jobDimension = ndx.dimension(function(d) { return d.status; });

That are the available settings:

{
    "indent_size": 4,
    "indent_char": " ",
    "indent_level": 0,
    "indent_with_tabs": false,
    "preserve_newlines": true,
    "max_preserve_newlines": 10,
    "jslint_happy": false,
    "space_after_anon_function": false,
    "brace_style": "collapse",
    "keep_array_indentation": false,
    "keep_function_indentation": false,
    "space_before_conditional": true,
    "break_chained_methods": false,
    "eval_code": false,
    "unescape_strings": false,
    "wrap_line_length": 0
}

I tried different settings without success. Maybe you know how to achieve it with this package or an alternative.


Solution

  • A recent version for the beautifier added preserve-inline as an option for brace-style. This will keep inline (all on the same line) brace blocks unchanged. It works as a modifier for the base setting:

    "brace_style": "collapse,preserve-inline",