Prevent VSCode auto format on save from removing final newline
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
- Apply settings only to
json
files - Insert final lines at end of the file
- Remove extra lines at the end of the file (i.e. only keep 1 empty line)
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.