Is there a way to make the format option of Visual Studio use unix line endings?

818 Views Asked by At

It is possible to set the line endings for a file. This converts existing line endings, and works when adding a manual line break. However, it does not seem to insert the correct line endings when formatting a document or when auto-formatting is triggered (for example when adding a closing brace }).

I have tried the .editorconfig file, which works for things like spaces vs. tabs, but doesn't solve the formatting line ending issue either.

Did anyone succeed at this? Or is the only way to use a Visual Studio extension?

Related questions:

1

There are 1 best solutions below

3
sommmen On

Like the comments saids its dependant on the language. Just a suggestion but VS supports editorconfig;

https://editorconfig.org/

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

And end_of_line is actually supported by vs, check this doc: https://learn.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2022

Supported settings The editor in Visual Studio supports the core set of EditorConfig properties:

indent_style

indent_size

tab_width

end_of_line

charset

trim_trailing_whitespace

insert_final_newline

root

All Visual Studio-supported languages except for XML support EditorConfig editor settings. Also, EditorConfig supports code style conventions including language, formatting, and naming conventions for C# and Visual Basic.