175

Any time I paste code into my .cs file, I get the dreaded "You have mixed tabs and spaces. Fix this?" message. It has three options:

Tabify
Untabify
Don't show again

I first tried "Tabify" a few times, until I was finally fed up and selected "Don't show again"; but that was a psyche - I still get it. I even tried "Untabify" but to no avail. Is there some setting I can tweak to prevent this re[o]curring problem?

VisualStudio2013 tabify untabify

5
  • Did you edit your file between the time you selected "Don't show again" and the time the message occurred again? Is it possible that you created a new "mixed tabs and spaces" situation due to your edits?
    – David K
    Jun 2, 2014 at 19:21
  • It's possible, but I'm not doing anything different than I always have, and I only get that msg with this project/environment (VS 2013). Jun 2, 2014 at 20:24
  • 1
    I suspect this really is just a VS2013 thing, because I've frequently encountered files with mixed tabs and spaces and the versions of Visual Studio I have used (several of them, all prior to 2013) have never complained about it.
    – David K
    Jun 2, 2014 at 21:21
  • 2
    Encountered exact same issue in VS2012
    – taz
    Apr 23, 2015 at 16:43
  • 1
    I am not sure what the "Don't show again" button does but it does not seem to work for me either on Visual Studio 2019. I am going to disable this annoying plugin. It's prompting me several times a day.
    – drescherjm
    May 5, 2022 at 18:36

4 Answers 4

281

Sounds like you have the Visual Studio Productivity Power Tools 2013 installed. Go into its settings and turn off "Fix Mixed Tabs"...

Tools -> Options -> Productivity Power Tools -> Turn Extensions On/Off

If you have the default VS settings, tabs in the editor are converted to spaces. So (in theory) if you clicked Untabify when the message comes up, it should convert all tabs to spaces and the errors should not appear next time. Are you working with other developers who have different tab settings in their IDE?

UPDATE: In Visual Studio 2017 and onward, this is a stand-alone extension named "Fix Mixed Tabs" that can be disabled or uninstalled from "Extensions and Updates" window (Tools > Extensions and Updates).

enter image description here

6
  • No, I'm the only one working on this project; it is not in source-control (I just use an add-in that allows me to "Backup Project" whenever I want, and it saves it to a .zip file) Jun 2, 2014 at 22:32
  • 1
    LOL... For what it's worth, I just enabled the setting, put a bunch of tabs into my file using Notepad, and then got the prompt. Clicking untabify turned all the tabs into spaces, and I don't get the message again for that file. Jun 2, 2014 at 22:37
  • After this "productivity tool" cost me a couple hours of debugging, it's getting switched off. It "fixed" a space between classes, changing it to a tab, which because of the way things laid out looked just like a space. Of course, selecting that class? Impossible, as it was "classA[tab]classB". Feb 9, 2016 at 16:57
  • 9
    This needs to be updated for VS2017 now. As it turns out, this is its own extension that can be disabled now Mar 7, 2017 at 16:53
  • @JoePhillips did you find out anything about this for VS2017? I even deinstalled the extension, but still got that annoying message. (btw: the settings for the extension still keep showing up in the vs settings window after deinstallation and restarting).
    – René Vogt
    May 8, 2017 at 15:09
93

Update for Visual Studio 2017. If you want to disable the "You have mixed tabs and spaces. Fix this?" message, you should go to

Tools → Extensions and Updates…

In windows which popped up, locate Fix Mixed Tabs (image below) and either click on Disable or Uninstall based on what you want.

Disabling Mixed tabs

4
  • 4
    I wish it would just do it automatically. I have the text editor set to use tabs instead of spaces, but when I go to a new line, the indent is set as spaces.
    – Sinjai
    Sep 21, 2017 at 1:28
  • 1
    Works for Visual Studio 2019 as well.
    – userom
    Nov 26, 2019 at 21:25
  • 7
    For VS 2019 it is "Extensions → Manage Extensions".
    – Uwe Keim
    Dec 18, 2019 at 12:50
  • 5
    Works for Visual Studio 2022.
    – Kozbara
    Nov 12, 2021 at 16:32
15

Related: If you do want Productivity Power Tools to notify you of tabs/spaces, but you keep getting the message right after you clicked Fix this then look in Tools > Options > Text Editor > [language] > Tabs.

Set this to Keep tabs

If you have it set to Insert spaces and you click Keep tabs on the Power Tools notification then VS will re-insert spaces after save, causing the notification to immediately pop up again...aaand now you're stuck in a loop.

1
  • This answer helped me to disable unwanted spacing, after saving the file, after having tabified its content. Useful. Thanks.
    – carloswm85
    Apr 28, 2023 at 16:27
2

Edit file with vim run :retab and save the file and it is done !.

vim file 
:retab
:wq

with :retab you can convert all tabs in spaces , if you set expandtab (:set expandtab ) it means that expand all tabs in spaces or vice-versa (:set noexpandtab) and all tabs made with space will be converted to tabs.

1
  • or just autoformat in visual studio and it does the same thing Nov 29, 2017 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.