- Home /
- Visual Studio /
Reported by david m chinn Apr 13, 2017 at 11:20 PM windows 10.0Visual Studio 2017 version 15.1
i have much code written previously in 2015. all of it is tabbed to 4 spaces.
with the new ide i have tried to set 'tools\options\Text Editor\All languages' to tab and indent size to 4, and set 'insert spaces' radio button.
however, the autoindent insists on using 2 spaces for each tab.
This shows up whenever i hit a carriage return, and also when formatting an entire file by deleting and re entering the last '}'
please help...!
i stumbled onto another clue.
formatting always formats to two spaces in my environment, for any file **included* in the project. No matter what values i enter into .... Tools -> options -> editor -> All Languages -> Tabs
If i exclude a c# file from the project, and then reformat (by removing/readding the last '}'), the autoindent is applied correctly, as specified in Tools -> options -> editor -> All Languages -> Tabs
Likewise, if i create a new c# file, it starts out with 2 spaces indent, and ignores the tabs setting as long as it is included in the project. But when the file is excluded from the project, and then re opened, it can be reformatted correctly.
as a lark, i checked the tab spacing under every language... basic, c#, c++... etc, etc, etc; everything set to 4.
it seems like something in the environment is over riding the tab settings?
thanks for your continued attention.
Thank you for your feedback! For us to investigate this further, could you please tell us if the Tool-> Options setting turns back to 2 or if it stays at 4? We're trying to understand if the setting is reverting or if it's being ignored. We look forward to hearing from you!
I am now having the same problem (VS2017 Professional). But it is only happening in my ASP.NET Core Web project. I also have a domain class project that is unaffected.
the entered settings do not change.
another datapoint: if the file is included in the project, i can set indents to an arbitrary value (6, 8, 12, etc), and the environment continues to indent at 2.
excluding the file from the project, and the autoindent will use the set value.
Thank you for your feedback! We have determined that this issue is not a bug given you are experiencing this issue due to an .editorconfig file in the code base. Since VS 2017, Visual Studio started respecting .editorconfig settings and that explains the behavior that you are seeing.
This is a bug in the Options dialog. You can't continue with the current behaviour of respecting a .editorconfig file but still allowing a user to configure/change tab settings in an Options box that will be ignored!
If tab settings in the Options dialog are ignored/superseded they need to show as disabled in the Options dialog.
For me this issue was extremely confusing issue as VS 2017 had found a .editorconfig file in a parent directory - higher up than my solution folder!
Simon,
We have thought about solving the problem that you have encountered. We will consider addressing that in a future release.
Thank you for your feedback!!
In general I find it very frustrating/annoying that you guys always try to dismiss/downplay legitimate issues like this one - "...this issue is not a bug" really? It most certainly is as Simon pointed out - how stupid do you think everyone is? What do you accomplish by denying the obvious issue - only pissing off your end users.
We appreciate you taking the time to report this problem. We are currently prioritizing problems that are impacting a broad set of our customers, so we may not be able to investigate this one immediately. We know this problem is important to you, so we will continue to monitor it.
Added a solution by Simon Needham · Apr 25, 2017 at 07:46 AM
You may have an (auto-generated) .editorconfig file in your code solution that is over-ruling your Visual Studio settings.
This happened to me when I created a new Angular project with the Angular CLI. It created a .editorconfig file in the root of the project source code. I then added an ASP.NET Core Web Api project in a child folder. Even though you can't see the .editorconfig file in the parent folder when working on the WebApi project it was pulling in the config from that file and overriding my VS tab-is-4-spaces setting.
I got the clue from this issue (https://developercommunity.visualstudio.com/content/problem/44816/tab-inserts-2-spaces-instead-of-4.html)
For me I fixed the issue by adding a specific *.cs setting with an ident_size of 4. My JS/TypeScript/HTML Code in VS Code remains the same and sanity is restored within my C# Web API project.
[*.cs] indent_style = space indent_size = 4
thanks so much!
one comment: i did a search through the entire solution, but could not find a .editorconfig file anywhere.
but i added the file (with simon needham's content) in the same folder as the .sln file and things were fixed.
Thanks again!
That was indeed the problem! Thank you.
Hey cool, glad it helped.
NB that rogue .editorconfig file could be in any of the parent directories of your solution or... you've found another way that Visual Studio tab settings can be secretly over-ruled.
I definitely think the VS config dialog box could do better. If the tab settings are being over-ruled then they should be disabled in the dialog box along with a message explaining why (and displaying the path to the over-ruling config file would be perfect!).
I found a .editorconfig file in the root of my c drive (c:.editorconfig). When I deleted this file, this issue went away for me.
Added a solution by david m chinn · Apr 15, 2017 at 03:33 PM
the entered settings do not change.
another datapoint: if the file is included in the project, i can set indents to an arbitrary value (6, 8, 12, etc), and the environment continues to indent at 2.
excluding the file from the project, and the autoindent will use the set value.
any further clues? or, is anything more information required?
can y'all at least repro the problem?
in fact, i've uninstalled and reinstalled vs 2017 and the problem persists.
to be clear... this problem has been resolved by the note from simon needham
VS2017 15.3 Breaks my solution with no way back
0
Solution
Cannot run any program in VS 2017
2
Solution
Errors when adding a view via scaffolding
2
Solution
fatal error LNK1104: cannot open file 'uuid.lib'
1
Solution
Error message when using rename refactoring
0
Solution
TagHelpers Intellisense not working
1
Solution
Graphics.FillPie - Documentation (IntelliSense) error
0
Solution
System.Runtime.InteropServices.COMException Exception from HRESULT: 0xD00000F3
1
Solution
LightWeight Solution Load Causes Unhelpful Messages on Build Failures
1
Solution
xaml editor throws exception
0
Solution