visual-studio-codeautoformatting

Prevent VSCode auto format on save from removing final newline


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:


Solution

  • 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.