25

When I use autoformat function in VS Code editor it insert spaces before curly brackets like this:

From:

<Button onClick={this.callMyFunc.bind(this, screenSet.index)}>Add</Button>

To:

<Button onClick={this.callMyFunc.bind(this, screenSet.index) }>Add</Button>

From:

))}

To:

)) }

I can't find option what settings this... Can anyone help me, please?

David Slavík
  • 1,132
  • 1
  • 14
  • 23

6 Answers6

17

In 2020, the properties are called this way:

"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false
human
  • 686
  • 3
  • 9
  • 24
  • ...and since October 2020 there are [formatting options for empty curly braces as well](https://code.visualstudio.com/updates/v1_51#_empty-brace-formatting-option-for-javascript-and-typescript) – Frank N Nov 25 '20 at 16:18
13

Try putting this to your user settings:

"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,

and maybe this too

"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
user2933157
  • 333
  • 2
  • 12
9

In preferences, you should set these to true

"javascript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": true
Vahid PG
  • 428
  • 6
  • 11
4

It seems that despite those config settings, it is not yet supported in VSCode. :(

Community
  • 1
  • 1
Kutyel
  • 8,575
  • 3
  • 30
  • 61
2

If you have a .prettierrc file, you can set bracket spacing property to true

module.exports = {
  bracketSpacing: true
};
1

in settings.json

"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false
Jon Portella
  • 1,068
  • 9
  • 8