visual studio可以自动缩进/格式化预处理指令吗?

Dav*_* S. 13 c# visual-studio-2010 visual-studio c-preprocessor

可能重复:
如何强制缩进C#条件指令?

假设我想在Visual Studio中键入:

    class Program
    {
        private const Byte NUM_THREADS =
        #if DEBUG
            1;
        #else
            8;
        #endif
    }
Run Code Online (Sandbox Code Playgroud)

如果我只是输入它(即不手动修复任何缩进),Visual Studio将像这样格式化:

    class Program
    {
        private const Byte NUM_THREADS =
#if DEBUG
 1;
#else
        8;
#endif
    }
Run Code Online (Sandbox Code Playgroud)

有什么我可以做的,所以它自动缩进所以它看起来像第一个例子?

小智 -3

转到Edit menu => Format DocumentOR 按快捷键Ctrl+ K, Ctrl+ D(简称Ctrl+ K+ D)此快捷键可以使用 .html、.aspx。.cs等...

  • 自动格式化“不适用于”预处理器命令。它适用于其他一切。 (3认同)
  • 您是否尝试过使用预处理器指令? (2认同)
  • 但由于某些恼人的原因,它*确实*可以在“#region”上工作,至少在 VS 2017 中是这样。 (2认同)