Search code examples
c#indentationstylecop

Is there a way to enforce using tabs instead of spaces?


StyleCop offers to check for consistent use of spaces, but sadly lacks the opposite idea: Force source code to use tabs. Is there some way to add this functionality? It does not have to be StyleCop, other tools are welcome as well.


Solution

  • You can use StyleCop+ plugin to enforce usage of tabs.

    After downloading StyleCopPlus.dll place it in Custom Rules folder inside the main StyleCop folder C:\Program Files (x86)\StyleCop 4.7\Custom Rules or directly in the main folder.

    Now, when opening a Settings.StyleCop with StyleCopSettingsEditor you will be able to set rule SP2001: CheckAllowedIndentationCharacters.

    This rule can be found under the StyleCop+ tab, under the More Custom Rules subtab, under the Formatting heading:

    Rule Options