Visual Studio - blank line at the end of each new file

Viewed 6154

Why does VS add a blank line at the end of each new file I create? I use VS to create .NET projects (not C++ or something).

Is there any special reason? Historical compatibility with compilers and parsers?

Can I disable this??

2 Answers

For those who want to get rid of the new line at the end of a file:

I had a similar issue and the solution provided by 9paradox in this post solved my problem.

When I was saving my code (Python, JSON, JS, etc...) I got always a new line inserted at the end of the file.

Solution: if, e.g. on Mac, you are editing any file in your project, then go to the root directory of your project, let's say /Users/<username>/git/<project> then search for .editorconfig in that folder, then open that file with any text editor like vi or TextEdit and make insert_final_newline = false. VS Code takes over the settings changes immediately. No restart needed.

Related