bzlight
bzlight

Reputation: 1160

VS Code adds spaces between content when pasting

When I copy this, for example:

<AdmobComponent/>

It pastes as:

< AdmobComponent / >

Does anyone have any suggestions? I don't even know where to start to fix this.

Upvotes: 9

Views: 9201

Answers (2)

michaela112358
michaela112358

Reputation: 483

For anyone having a similar problem in Visual Studio 2019 it can be fixed as follows:

Go to Tools | Options | Text Editor | {language}

Now depending on the Language the options that need to be changed could be in a few different places or missing. But for C# and JavaScript go to Code Style | Formatting

Once there there are a few options. If "Automatically format on paste" is unticked it will completely remove any reformatting on paste.

Or for a more limited impact go into the "Spacing" section and change "Set spacing for operators" to "Ignore spaces around binary operators". By doing this some automatic reformatting is lost but I think it's worth it not to have all those spaces inserted into stuff like Kebab case variables.

Upvotes: 5

Darren Ruane
Darren Ruane

Reputation: 2505

From within the IDE:

Go to File | Preferences | Settings and then click Text Editor | Formatting. The top option should be FormatOnPaste, make sure this is unchecked.

If you are using the Prettier extension, then this is a known issue.

Upvotes: 18

Related Questions