Why do I keep getting mixed tabs and spaces in a Visual Studio 2010 C# code window?
Visual StudioVisual Studio-2010Visual Studio Problem Overview
I have just been working on a C# file (Global.asax.cs) in a web application for the last hour or so, and I have been shown the prompt to "tabify" or whatever about four times. Each time I choose to tabify and save the files, yet at some seemingly random point later on, I get prompted again.
I am using ReSharper, yet this doesn't happen when I code at home, also using ReSharper. Only at work.
Visual Studio Solutions
Solution 1 - Visual Studio
Are you using the Productivity Power Tools VS 2010 extension? If so, go to Tools
-> Options
-> and choose Productivity Power Tools
. Here you can turn off the option to Fix Mixed Tabs
. This will turn off this warning.
Power Tools for Visual Studio 2010
Power Tools for Visual Studio 2012
Solution 2 - Visual Studio
The mixed tabs and spaces might come from your visual studio text editor setting. You can decide if you want visual studio to insert spaces or tabs here:
Tools/Options/ -> Text Editor/All Languages/Tabs, select the "Keep Tabs" option.
Solution 3 - Visual Studio
Choose the "Untabify" option since VS defaults to spaces, not tabs. If you choose "Tabify" the next time you add a line, VS will use spaces and you'll see the prompt over and over.
Solution 4 - Visual Studio
Resharper
uses seperate tab/space settings to visual studio. In the Resharper
options, check "General Formatter Style -> How to align when tabs are used for indents". This setting is used when resharper
is formatting code (such as refactoring etc) and defaults to "User Spaces".
Also, in "Edit -> Advanced" menu, there is a "View Whitespace" option (Ctrl + E, S) which may be useful!