There are two easy ways to get Visual Studio code to insert a new line at the end of files:
Method I
Open Visual Studio Code and go to " File" ("Code when using a Mac") β "Settings" β "Settings" ; You should now view the settings page.
Type " insert last line" into the search bar
Check the box under the heading β Files: insert last line β on the βWorkspace Settings β and / or β User Settings β tabs , as required

Method II
Open Visual Studio Code and go to " File" ("Code when using a Mac") β "Settings" β "Settings" ; You should now view the settings page.
Open the JSON settings page by clicking the {} icon in the upper right corner of the page.
Type ' files.insertFinalNewline ' into the search bar on the JSON settings page.
Or
- Click on the white βedit knobβ on the left side of the line containing the JSON key
files.insertFinalNewline and select True
or
- Copy the line containing
files.insertFinalNewline JSON files.insertFinalNewline , paste it into the right JSON file on files.insertFinalNewline "User Settings" and / or "Workspace Settings" and set it to true

Final result
In the JSON file of user settings or workspace settings, there should be the line "files.insertFinalNewline": true , in the provided curly brackets ({}). In addition, a checkbox under the heading " Files: insert the last line " will be checked on the settings page.
Visual Studio Code now adds an empty line to the end of the file when saving, if it does not already exist.
source share