I have just opened an old project here at work. Someone appears to have changed the indentation. Its set to 2 spaces instead of four space tabbing.
What I have tried:
_ReSharper.Caches
directory and a new one is just created no change to the indentation.When those didn't work i have started comparing settings in my visual studio with two different solutions.
Resharper settings spear to be identical ad are the settings in visual studio.
Re-sharper settings
Visual studio settings
Which makes me think this must be in one of the project files or something? If its not an issue with the settings in my visual studio whats overriding the tabbing?
Of note when the project loads i swear it loads with proper indentation and then its reformatted in the last second. Not sure it matters but the projects are .net core 1.0 there are three projects in the solution all three appear to be affected.
Hope someone has a fix for this its really hard to read it like this.
1. Indentation: tabs vs spaces. Java: 4 spaces, tabs must be set at 8 spaces. Both are acceptable.
Visual Studio may be using an .editorconfig file in the project's directory (or in any parent directory) which allows for a consistent code style within a codebase regardless of user settings.
Visual Studio should indicate this in the lower left-hand area of the IDE window.
If this is the case, you'll need to modify .editorconfig
and define a new style in order to change the configuration for the automatic formatting tools.
As people says in answers and comments this is probably a .editorconfig
. In our case a developer started using VS Code and when upgrading to VS 2017 Visual Studio also accepts these files.
This was the value in the file that was automatically added:
[*]
end_of_line = crlf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
By adding this we could use C# normally and the developer who wanted to use VS Code could continue to do that:
[*.cs]
indent_style = space
indent_size = 4
https://developercommunity.visualstudio.com/content/problem/44231/cant-set-indent-level-to-4-spaces-in-vs-2017.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With