I am using the last feature of VSCode called formatOnSave, which is super cool.
I have one tiny problem, the formatter tends to delete the new line at the end of json
files like packages.json
for example.
My linter want those new lines at the end of the file, and me too.
Is there a setting or a method that allows me to tell the formatter to keep new lines at the end of files?
Related issue:
Enable/Disable Format On Save Open up VSCode Command Palette by pressing Ctrl + Shift + P. Search and select Open Settings (UI). Just start typing and it will auto-fill. Once there's a match, you can hit enter immediately, or manually click on the right option.
You have configured prettier to format as per the default settings. If you don't see the code formatted automatically on file save then it might be because you have multiple formatters installed in VS Code.
The solution was to go to 'Tools > Options > Text Editor > Basic > VB Specific' and turn 'Pretty Listing' OFF.
Click the (...) button and then select Undo Last Commit to undo the previous commit. The changes are added to the Staged Changes section.
This option has been added since the release 1.8 of November 2016:
New editor settings
files.insertFinalNewline
- automatically add a newline at the end of files when saving.
If you wish to preserve the last line in package.json and not affect other file types, add below lines to your vs code configuration.
"[json]": {
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
}
This basically tells VS code to
json
filesIf 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