vscode: bizarre spaces during formatting
See original GitHub issueIs 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:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here’s the relevant issue for prettier-plugin-svelte - https://github.com/sveltejs/prettier-plugin-svelte/issues/24 (it’s labelled as a bug)
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 becomesTest ( 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 aEDIT: Actually it looks like this already works.<!-- prettier-ignore -->
option is a nice workaround for now.