有没有办法指示visual studio在类的底部而不是顶部自动添加字段?

时间:2013-03-27 18:37:47

标签: c# visual-studio formatting styles

namespace Guilds
{
  public class Wizard
  {
    public void Wear(IClothing clothing)
    {
      Console.WriteLine("Puts on the {Robe} and {WizardHat}".Fmt(clothing));
    }

    IClothing _clothes;
    IWeapon   _weapon; // <== I want my fields added at the bottom of the class!
  }
}

我知道如果你把你的字段放在底部,它会开始将后续的字段添加到类的底部。我很乐意将此作为默认行为,即使对于第一个字段也是如此。

按Ctrl +时通常会触发此行为。在未申报的领域之上。

1 个答案:

答案 0 :(得分:4)

使用Regionerate并创建自己的格式模板。它是与visual studio一起使用的免费工具。

编辑:您也可以使用CodeMaid,因为看起来Regionerate和VS2012不能一起工作(我根本没有测试过那个组合。我有VS2010)

修改在我之前的回复中添加更多内容。 CodeMaid非常酷,您可以在配置中指定布局。同样在配置中,您可以指定该文件应在保存时格式化。这样就可以根据需要编写代码,并在按Ctrl + S时对其进行格式化!我是CodeMaid的一个快乐用户。我也在使用Visual Studio 2013。