Reputation: 1245
I am facing an irritating problem that no new line is being saved for HTML and JavaScript despite explicitly setting that they should be done. Can someone please guide me what I am doing wrong?
Visual Studio Code version details:
Version 1.23.0
Commit 7c7da59c2333a1306c41e6e7b68d7f0caa7b3d45
Date 2018-05-03T15:23:19.356Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
VS Code Settings:
Upvotes: 13
Views: 15051
Reputation: 37248
That's because of a default setting in 🆚CODE
// When enabled, insert a final new line at the end of the file when saving it.
"files.insertFinalNewline": false,
Turn that to true and you'll be able to persist a new line. I'd also recommend that your turn on the trimmer for more than one new lines at the end.
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
⚡ Here's a GIF Demo — Save a file to add a line or trim extra lines
Upvotes: 28
Reputation: 61
Go to the extensions in vs code and delete the extension called save on typing and delete it and everything will be good to go
Upvotes: 0
Reputation: 1245
The problem was not in the settings but in the extensions. As pointed out in a comment in the question by VictorS., running the editor in code --disable-extensions
I validated that without extensions it does work. Then I started uninstalling extensions until it works and finally zero'd down to this plugin and uninstalling it made things work as I was expecting.
Upvotes: 8
Reputation: 66
You've set files.eol
to be \r\n
. I'm no expert, but since you're on Linux, you might want to try the Linux-specific EOL-marker \n
. Source
Upvotes: 0
Reputation: 47222
It's the wrong setting.
The correct setting is
"files.insertFinalNewline": false,
setting this to true
will enable a new line to be added when saving the file.
There is an even more explicit setting "html.format.endWithNewline": false,
but I've never used that so I am unsure how it works.
Upvotes: 3