Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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??

like image 738
Andrei Rînea Avatar asked Jul 14 '11 09:07

Andrei Rînea


People also ask

How do I insert a blank line in Visual Studio?

Pressing Ctrl-Enter inserts a line above the current position. Unlike when pressing Enter, if the text cursor is in the middle of the text, the current line is not broken into two. If you press Ctrl-Shift-Enter, a blank line is inserted below the current line.

What is blank line code?

Blank lines improve readability by setting off sections of code that are logically related. Two blank lines should always be used in the following circumstances: Between sections of a source file. Between class and interface definitions.


1 Answers

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.

like image 143
Mihai Maruseac Avatar answered Oct 20 '22 06:10

Mihai Maruseac