VS Code adds spaces between content when pasting
Asked Answered
C

2

9

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.

Cannular answered 20/3, 2019 at 17:38 Comment(0)
T
17

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.

Tortuous answered 20/3, 2019 at 18:23 Comment(0)
P
5

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.

Paradigm answered 30/7, 2020 at 11:29 Comment(1)
For those using R Tools for Visual Studio, it's in Tools > Options > Text Editor > R > Advanced > Format on paste (Off)Subtlety

© 2022 - 2024 — McMap. All rights reserved.