Prevent VSCode auto format on save from removing final newline

Cyril Gandon picture Cyril Gandon · Oct 17, 2016 · Viewed 11k times · Source

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:

Answer

Cyril Gandon picture Cyril Gandon · Aug 21, 2017

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.