让VS 2008停止强制命名空间缩进的方法?

Ear*_*rlz 15 c# coding-style namespaces indentation visual-studio

我从来没有真正成为大多数编辑器处理命名空间的忠实粉丝.它们总是迫使你添加一个毫无意义的缩进级别.

例如,我在页面中有很多代码,我更愿意将其格式化为

namespace mycode{

class myclass{
  void function(){
    foo();
  }
  void foo(){
    bar();
  }
  void bar(){
    //code..
  }

}

}
Run Code Online (Sandbox Code Playgroud)

而不是像

namespace mycode{

  class myclass{
    void function(){
      foo();
    }
    void foo(){
      bar();
    }
    void bar(){
      //code..
    }

  }

}
Run Code Online (Sandbox Code Playgroud)

老实说,我甚至不喜欢大部分时间缩进类的东西,因为我通常每个文件只有1个类.它看起来并不那么糟糕这里,但是当你一吨的范围的代码很多,你可以轻松拥有压痕,迫使你关闭屏幕,再加上这里我只用2 - 空间标签,而不是4空间正如我们所使用的那样.

无论如何,有没有办法让Visual Studio停止尝试为我缩进名称空间?

Mar*_*som 5

这是一个黑客,但这里是:

namespace mycode{ 
#if 0
}
#endif

class myclass{
    ...
Run Code Online (Sandbox Code Playgroud)

  • 我应该在我的问题中添加"没有非常糟糕的黑客":) (8认同)