tvl
tvl

Reputation: 100

VSCode adds curly braces on autocomplete

Whenever VSCode does suggestions and I choose one of those suggestions, it adds "={}" behind any variable I auto-complete.

I recorded a little clip to demonstrate the problem: enter image description here

I want it to just autocomplete "album" in this case. Not "album={}".

Upvotes: 5

Views: 1355

Answers (1)

Nikitas IO
Nikitas IO

Reputation: 1171

How to fix this

  1. Open VS code.
  2. Go to File > Preference > Settings then
  3. type: run code in the settings search bar
  4. Select Edit in settings.json to open the settings.json file
  5. Add the "javascript.preferences.jsxAttributeCompletionStyle": "none" line to your settings.json file

Why we do this:

In the defaultSettings.json file there is this code snippet:

// Preferred style for JSX attribute completions.
//  - auto: Insert `={}` or `=""` after attribute names based on the prop type. 
//  - braces: Insert `={}` after attribute names.
//  - none: Only insert attribute names.
"javascript.preferences.jsxAttributeCompletionStyle": "auto",

therefore, the default setting for jsxAttributeCompletionStyle is auto and by setting it to "none" in your settings.json file you overwrite that default setting.

Upvotes: 8

Related Questions