Search code examples
visual-studiovisual-studio-2010

Tool/trick to replace tabs in all files of an entire VS solution


My solution (30+ project) is a bit of a mess when it comes to mixing tabs and spaces, and I want to fix this with one easy step.

Does anybody know a trick/tool to do this in one step for the entire solution?

EDIT: Not exactly what I meant. I want the documents to be nicely formatted. Just find/replace wont do.. documents will still be a mess. I want something like the Format -> Advanced -> Format Document command


Solution

  • In case if your files contains spaces as tabs of equal width all along the solution (i.e. 4 spaces per tab), then you should use plain VS's Quick replace tool. In order to follow StyleCop's formatting rules, you should use spaces instead of tabs, so go to Quick replace (CTRL-h), select Use wildcard and then in Find what field you can use \t symbol, replacing it with 4 spaces for all solution (Look in field).

    But if your solution files contains tabs made of spaces of different width, or you want to apply single-style formatting, then you definitely should use Resharper's feature to reformat code. This feature is called Code Cleanup. To apply code cleanup to whole solution or selected project, go to the solution explorer and select Cleanup code in context menu. But before launching reformatting on whole solution try and tweak it on one file, there's a lot of options in Resharper's settings.