Microsoft Edge

Try Microsoft Edge

A fast and secure browser that's designed for Windows 10 Get started

This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use. Learn more
Microsoft Microsoft
    • .NET
      • Apps
      • Internet of Things
      • Mixed Reality
      • Microsoft Edge
      • Hardware
      • IT Center
      • What is Azure
      • Products
      • Solutions
      • Pricing
      • Create a free account
      • Visual Studio
      • Visual Studio IDE
      • Visual Studio Team Services
      • Visual Studio Code
      • Xamarin
      • Visual Studio Dev Essentials
      • Subscriptions
      • Office Dev Center
      • Office 365 for IT pros
    • Microsoft Graph
      • Store
      • Cortana
      • Bing
      • Application Insights
      • .NET
      • Microsoft Azure
      • Microsoft Graph
      • Visual Studio
      • Visual Studio Team Services
      • Windows
      • Office
      • All Developer Centers
    • TechNet
    • Microsoft Developer Network
      • Windows IT Center
      • Office 365 for IT Pros
      • All IT TechCenters
      • Microsoft Download Center
      • Microsoft Azure
      • Visual Studio
      • SDKs
      • Windows
      • Office
      • Microsoft Graph
      • MSDN
      • Azure
      • Windows
    • PowerShell scripts
      • Microsoft Azure
      • Visual Studio
      • Visual Studio Team Services
      • Developer tools
      • Office Dev Blog
      • Server & management
      • Windows
      • Developers
      • TechNet
      • Microsoft Tech Community
      • Visual Studio (MSDN) subscriptions
      • Microsoft Cloud Essentials
      • Microsoft Virtual Academy
      • IT Pro Career Center
    • Microsoft Evaluation Center
    • Channel 9
    • No results
    Sign in
    Developer Community Status
    Visual Studio

    Developer Community

    Get help from our community supported forum
    Visual Studio Visual Studio for Mac .NET C++ VSTS TFS
    All Products
    • Visual Studio
    • Visual Studio for Mac
    • .NET
    • C++
    • VSTS
    • TFS
    Report a problem
    • for Visual Studio
    • for Visual Studio for Mac
    • for .NET
    • for C++
    • for VSTS
    • for TFS
    Report an issue in Visual Studio Installer or Visual Studio
    This allows diagnostic information about the program to be included in your report
    1. Installer or Visual Studio
    2. Report a Problem
    3. Type and Submit
    Available on Visual Studio 2017, Installer, and newer releases
    Would you like to know more?
    • Home /
    • Visual Studio /
    avatar image
    2

    can't set indent level to 4 spaces in vs 2017

    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...!

    thub.nodes.view.add-new-comment
    Add comment Show 9
    10 |10000 characters needed characters left characters exceeded
    ▼
    • Viewable by all users
    • Viewable by moderators
    • Viewable by moderators and the original poster
    • Advanced visibility
    Viewable by all users
    avatar image david m chinn · Apr 14, 2017 at 06:15 PM 0
    Share

    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.

    avatar image Visual Studio Team ♦♦ · Apr 14, 2017 at 08:45 PM 0
    Share

    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!

    avatar image Jordan Marr · Apr 19, 2017 at 10:05 PM 0
    Share

    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.

    avatar image david m chinn · Apr 20, 2017 at 04:43 PM 0
    Share

    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.

    avatar image Hemchander Sannidhanam [MSFT] · May 08, 2017 at 09:29 PM 0
    Share

    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.

    avatar image Simon Needham Hemchander Sannidhanam [MSFT] · May 09, 2017 at 01:29 PM 0
    Share

    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!

    avatar image Hemchander Sannidhanam [MSFT] Simon Needham · May 09, 2017 at 07:48 PM 0
    Share

    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!!

    avatar image garynicholas Hemchander Sannidhanam [MSFT] · Feb 10 at 10:13 PM 0
    Share

    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.

    avatar image Hemchander Sannidhanam [MSFT] · Feb 13 at 05:00 AM 0
    Share

    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.

    Solutions

    · Add your solution
    avatar image
    11
    Best Solution

    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
    

    thub.nodes.view.add-new-comment
    Add comment Show 4 · Share
    10 |10000 characters needed characters left characters exceeded
    ▼
    • Viewable by all users
    • Viewable by moderators
    • Viewable by moderators and the original poster
    • Advanced visibility
    Viewable by all users
    avatar image david m chinn · Apr 25, 2017 at 03:06 PM 0
    Share

    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!

    avatar image Jordan Marr david m chinn · Apr 25, 2017 at 08:27 PM 0
    Share

    That was indeed the problem! Thank you.

    avatar image Simon Needham david m chinn · Apr 26, 2017 at 07:05 AM 0
    Share

    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!).

    avatar image Joshua Morton · Sep 26, 2017 at 09:26 PM 0
    Share

    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.

    avatar image
    0

    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.

    thub.nodes.view.add-new-comment
    Add comment Show 2 · Share
    10 |10000 characters needed characters left characters exceeded
    ▼
    • Viewable by all users
    • Viewable by moderators
    • Viewable by moderators and the original poster
    • Advanced visibility
    Viewable by all users
    avatar image david m chinn · Apr 19, 2017 at 06:38 PM 0
    Share

    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.

    avatar image david m chinn · May 08, 2017 at 01:53 AM 0
    Share

    to be clear... this problem has been resolved by the note from simon needham

    Add a Solution

    Up to 2 attachments (including images) can be used with a maximum of 2.1 GB each and 2.1 GB total.

    Follow

    106 People are following this

    avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

    Related Problems

    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

    Popular
    • Windows Dev Center
    • Microsoft Azure
    • Microsoft Visual Studio
    • Office Dev Center
    • ASP.NET
    • IIS.NET
    Learning Resources
    • Channel 9
    • Windows development videos
    • Microsoft Virtual Academy
    Programs
    • Microsoft developer program
    • Windows Insider program
    • Microsoft Affiliate program
    • BizSpark (for startups)
    • Microsoft Imagine
    For IT Pros
    • Microsoft Power BI
    • Microsoft SQL Server
    • Internet of Things
    • Operations Management Suite
    English (United States)
    • Contact us
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • About our ads
    • © Microsoft 2018
    • Anonymous
    • Sign in
    • Spaces
    • Visual Studio
    • Visual Studio for Mac
    • .NET
    • C++
    • VSTS
    • TFS
    • Explore
    • Topics
    • Problems
    • Users
    • Badges