I am facing this issue with vscode that whenever I am saving an HTML file it automatically adds the new lines. It is not because of any extension because I tested by starting vscode without extension. Below is what I am trying to say
This is how I want it to be:
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
And this is what vscode turns it into when I hit ctrl-s
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
I have turned word-wrap off as well and tried all kinds of settings but no luck yet. Anyone have any idea?
According to this issue on VSCode's GitHub, There is an option for that since 1.8:
"files.insertFinalNewline": true
And to be thorough, you can use all of these three settings to do most of basic formatting you usually need:
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
NOTE: I'm aware that this may not correspond to op's description, although this question is the first hit when searching for vscode append new line on save on DuckDuckGo. So I felt the need to add this answer.
I don't know if this is a bug or what but i toggled this setting "editor.formatOnSave": false
to "editor.formatOnSave": true
and then again back to "editor.formatOnSave": false
and it stopped formatting on save.
It is weird because i did not modify any single setting and now it is working as expected.
For me, disable "JS-CSS-HTML Formatter" extension fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With