Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 584
bzlight Avatar asked Mar 20 '19 17:03

bzlight


2 Answers

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.

like image 97
Darren Ruane Avatar answered Sep 19 '22 07:09

Darren Ruane


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.

like image 34
michaela112358 Avatar answered Sep 19 '22 07:09

michaela112358