basickarl
basickarl

Reputation: 40561

VSCODE inserting spaces via format on save

VSCODE seems to be inserting spaces everywhere in my html code. I checked the settings and it's the following which is causing it: "editor.formatOnSave": true

Example:

enter image description here

How do I configure this to stop inserting spaces?

Upvotes: 10

Views: 35833

Answers (6)

ekchom
ekchom

Reputation: 148

Now vscode has option
"editor.formatOnSaveMode": "modificationsIfAvailable"

It will not reformat whole file on save, modified content will be formatted (given source control is present)

Upvotes: 1

Harsh Phoujdar
Harsh Phoujdar

Reputation: 847

What was the case with me is that I had the option Editor: Format on save mode to be set to file, this in combination with format on save would mean VS Code will try to format the entire file, resulting in spaces as defined in the formatter. Change this to be modifictions, and VS Code will only save the lines you have made changes in.

Upvotes: 0

george
george

Reputation: 586

I disabled the option of HTML formatting and no more space when saving files.

Settings > Extensions > HTML > Format: Enable

Enable/disable default HTML formatter.

Upvotes: 1

Micheal N.D
Micheal N.D

Reputation: 460

Mine was caused by an extension JS/ CSS formatter, after i uninstalled and restart vscode works great. After spending hours wondering why my django static links are broken smh

Upvotes: 14

Jose Balcazar
Jose Balcazar

Reputation: 31

When saving, Visual Studio inserted a lot of spaces. This happened after an update of Visual Studio. This problem was because of an extension called Bracket Pair Colorizer. What I did was, uninstall and reinstall, and that solved the problem. I suggest to check all your extensions. It could be one of them.

Upvotes: 3

Abhilash D K
Abhilash D K

Reputation: 1309

I have the following set :

"editor.formatOnSave": false,
"editor.insertSpaces": false

Now it is not inserting spaces. Hope it helps

Upvotes: 15

Related Questions