In software development it’s generally considered good practice (and sometimes necessary) to add a blank line at the end of a code file. In VS Code we can configure the IDE to force a newline at the end of a file every time we save. There are several ways to set this up, as discussed below.
Global Settings
To apply a newline at file end for any file saved in the IDE, open VS Code and:
Navigate to File (‘Code’ on Mac) > Preferences > Settings.
In the search bar, type Insert Final Newline. You should see a single setting appear, where you can check the box to activate this functionality.
![](https://i0.wp.com/neilsonwebdesign.com/wp-content/uploads/2023/06/Screen-Shot-2023-06-30-at-9.43.02-AM.png?resize=640%2C174&ssl=1)
Project Settings
If your project is using a dedicated settings file at .vscode/settings.json, you can add the line “files.insertFinalNewline”: true within the settings JSON object in this file. Adding this line should apply a newline to the end of any file in the project when saving.
![](https://i0.wp.com/neilsonwebdesign.com/wp-content/uploads/2023/06/Screen-Shot-2023-06-30-at-11.22.33-AM.png?resize=348%2C143&ssl=1)