WebStorm,空代码块和花括号

exk*_*730 6 webstorm typescript

每次我"重新格式化代码"时,WebStorm都会在任何空的花括号之间放置一个新行.例如,如果我有这个代码:

export class Example {}

我重新格式化代码(Command + Option + L在mac上),我最终得到了这个:

export class Example { }

如何阻止编辑器插入新行?WebStorm版本是2016.2

Laz*_*One 9

使用这些设置它似乎工作 - IDE不会将这些代码分成多行,但将保持原样.

  1. Settings/Preferences | Editor | Code Style | TypeScript --> Wrapping and Braces
  2. Keep when reformatting | Simple block in one line - 检查
  3. Braces placement | In class declaration - "行结束"

在此输入图像描述

PhpStorm 2016.3的截图...但在2016.2应该是相同的.

  • 所以这段代码:`export class Example {}` 无论如何都会变成`export class Example {[NEW_LINE]}`。但是这段代码:`constructor() {}` 将保持原样,如果我打开 `Simple methods in one line`。这非常接近(因为无论如何我都不应该有太多的空类),所以我会接受这个作为答案。谢谢。 (2认同)