1

I have a C# project with VS Code, having ms-dotnettools.csharp and editorconfig.editorconfig extensions (among others). As per this post I installed npm install -g editorconfig.

My .editorconfig file is as follow:

root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.cs]
indent_style = tab
indent_size = 3

As you can see in the image, editor show 3 spaces, but Format Document does nothing.

enter image description here

Hung P.T.
  • 101
  • 8

1 Answers1

1

After a while, I was able to make it work:

  • Remove "editor.defaultFormatter", "editor.insertSpaces" and other related to styling.
  • Restart OmniSharp each time I make change to .editorconfig.
  • Use official configs from official source.

My editorconfig is now:

root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.cs]
indent_style = space
indent_size = 4
csharp_new_line_before_open_brace = none
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_between_query_expression_clauses = false

Hung P.T.
  • 101
  • 8