question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vscode: bizarre spaces during formatting

See original GitHub issue

Is there a way to not add spaces in the below html during formatting?

I need this code to stay like this:

<div>
  Test (<span class="color">one</span>)
</div>

It becomes this instead:

<div>
  Test (
  <span class="color">one</span>
  )
</div>

From https://github.com/UnwrittenFun/svelte-vscode/issues/50.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
ryanatkncommented, May 7, 2020

Here’s the relevant issue for prettier-plugin-svelte - https://github.com/sveltejs/prettier-plugin-svelte/issues/24 (it’s labelled as a bug)

1reaction
dimfeldcommented, May 8, 2020

Yeah, the problem is that adding newlines here alters the rendered output by inserting spaces into the output. The first snippet at the top renders in the browser as Test (one) but after adding the newlines it becomes Test ( one )

Standard Prettier HTML formatting does have an HTML whitespace setting to determine how it treats whitespace in HTML, but the Svelte Prettier plugin does not appear to honor that. From my limited exploration, it reimplements a lot of HTML formatting functionality in order to also support Svelte template syntax.

IMO updating so we get a <!-- prettier-ignore --> option is a nice workaround for now. EDIT: Actually it looks like this already works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code Strange Formatting on save - Stack Overflow
This is likely happening because you're not meant to have trailing spaces at the end of your lines of code. So, VSCode will...
Read more >
Weird VS Code formatting when refactoring - Ask - GameDev.tv
This is a question about VS code (v1.55.2 on windows)- Whenever I use “extract method” or “generate method” I end up with really...
Read more >
Weird paragraph formatting : r/vscode - Reddit
I'm currently working on a school project where I'm creating an HTML page with a lot of text in it. Did some automated...
Read more >
Basic Editing in Visual Studio Code
Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting.
Read more >
Forcing C# indentation in Visual Studio Code using Omnisharp
For years, I was lucky enough to standardise on projects that used two spaces for indentation, or hard tabs that I set to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found