简体   繁体   English

使用js beautifier在短函数中避免sublime text3中出现换行

[英]avoid line breaks in sublime text3 in short functions with js beautifier

I'm using Sublime Text 3 with the JavaScript Beautify Package. 我将Sublime Text 3与JavaScript Beautify包一起使用。

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. 也许您知道如何使用此软件包或替代方法来实现它。

You can change 你可以改变

"brace_style": "collapse", “ brace_style”:“崩溃”,

to

"brace_style": "none", “ brace_style”:“无”,

Altough this completely disables cutting the line, so you have to do that yourself now. 虽然这完全会影响切割线,所以您现在必须自己做。

A recent version for the beautifier added preserve-inline as an option for brace-style . 美化工具的最新版本添加了preserve-inline作为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", “ brace_style”:“崩溃,保留内联”,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM