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??
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??
It is recommended to have a blank line at the end of each file for navigability purposes. Think what happens if someone opens your code with vim for example and uses a keymap to jump from empty line to empty line. Or, if he decides to add another portion of code at the end of file he can quickly do a GO and enter it instead of having to scroll until the end of file.
Also, source control tools will report more changes if you don't have a trailing blank line when you try to insert code at the end of file.
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.