11

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?

2
  • 2
    Hi Even I am having the same problem. Did you find a resolution for it. For me it is inserting space after and before angle brackets too. Commented May 17, 2017 at 12:13
  • is it possible that you have any supernumerary " in your code? In my case thats was the problem. Commented Aug 4, 2023 at 17:33

6 Answers 6

15

I have the following set :

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

Now it is not inserting spaces. Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

14

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

3 Comments

Solved my issue!
Solved the issue for me as well. In my case was the "Prettier - Code formatter" extension.
solved my issue too, it was the same extension of Alejandro that was giving me headaches
3

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.

Comments

1

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

Settings > Extensions > HTML > Format: Enable

Enable/disable default HTML formatter.

Comments

1

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)

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.