Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 - Insert Final NewLine

Is there a feature / extension for Visual Studio 2017 to automatically end files with a newline?

I'm looking for a similar option as with VS Code's "Insert Final NewLine"

Thanks!

like image 474
Jan Paolo Go Avatar asked Oct 19 '18 14:10

Jan Paolo Go


1 Answers

There is a feature called "EditorConfig" that allows placing a file in specific locations that allow to set various configurations about how to format files. In particular, one of them is to end files with a new line. To activate it, create a file named .editorconfig in the root of your solution and add this content:

root = true

[*]
insert_final_newline = true

To apply a trailing newline to every single file in the solution.
Look at the full documentation of the feature for details and other options.

Note that such formating actually happens when you format the whole document, not on its own as you write.

For previous versions of Visual Studio, there is an extension that does the very same thing. It's bundled begining with VS2017.

like image 56
Alejandro Avatar answered Oct 06 '22 18:10

Alejandro