Eric Whale
Eric Whale

Reputation: 137

VSCode is adding space and slash in ending tag of html code, how can I disable it?

In html file, if I save file with

<br>

it turns into...

<br />

I just want first one without slash and space, how can I do it? (I use Prettier if that's the reason)

Upvotes: 8

Views: 9190

Answers (3)

SquareCodes
SquareCodes

Reputation: 1

For an easier solution(in my opinion).

  1. click on settings,
  2. Search "format"(without the quotes),
  3. locate "Editor On Save Mode" under Workspace
  4. change from "file(default) to modifications".

And there you go!

Upvotes: 0

dgruending
dgruending

Reputation: 1133

The desired functionality seems no longer to be supported by the "Prettier" plugin for VS Code. To use VS Code formatting for html on saving a file, add

"editor.formatOnSave": true,
"[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
}

to your settings.json. For a more detailed discussion see here.

Upvotes: 6

Eric Whale
Eric Whale

Reputation: 137

Found the solution, Prettier was the problem. What I wanted is to
get rid of unnecessary slashes in HTML files, but leave auto formatting on other files like js, python...

What I did was...

  1. Go to setting (cmd + ,)
  2. search prettier
  3. on Disable Languages section add "html" (without double quote)

problem solved!

Upvotes: 2

Related Questions