我可以在 Visual Studio 中自动缩进对齐代码吗?

Bra*_*don 5 c# format visual-studio

我不知道它是否有一个名称,但我想自动缩进(/制表符?) - 对齐我的源代码以获取大型相关代码块。就像这样:

前:

this._strategies = new Dictionary< Type, IStrategy >
{
    {typeof( Station ), new StationStrategy(this)},
    {typeof( Turnout ), new TurnoutStrategy(this)},
    {typeof( EndOfLine ), new EndOfLineStrategy(this)},
    {typeof( Chainage_Equality ), new ChainageEqualityStrategy(this)},
    {typeof( Track_Connector ), new TrackConnectorStrategy(this)},
    {typeof( Multimeter ), new MultimeterStrategy(this)},
    {typeof( Power_Rail_Gap ), new PowerRailGapStrategy(this)},
    {typeof( EndOfWire ), new EndOfWireStrategy(this)},
    {typeof( Grounding_Point ), new GroundingPointStrategy(this)},
    {typeof( Busbar ), new BusbarStrategy(this)},
    {typeof( AARU ), new AutomaticAssuredReceptivityUnitStrategy(this)},
    {typeof( TPS ), new TractionPowerSubstationStrategy(this)},
    {typeof( AutoTransformer ), new AutotransformerStrategy(this)},
    {typeof( Energy_Storage ), new EnergyStorageStrategy(this)},
};
Run Code Online (Sandbox Code Playgroud)

后:

this._strategies = new Dictionary< Type, IStrategy >
{
    {typeof( Station ),             new StationStrategy(this)},
    {typeof( Turnout ),             new TurnoutStrategy(this)},
    {typeof( EndOfLine ),           new EndOfLineStrategy(this)},
    {typeof( Chainage_Equality ),   new ChainageEqualityStrategy(this)},
    {typeof( Track_Connector ),     new TrackConnectorStrategy(this)},
    {typeof( Multimeter ),          new MultimeterStrategy(this)},
    {typeof( Power_Rail_Gap ),      new PowerRailGapStrategy(this)},
    {typeof( EndOfWire ),           new EndOfWireStrategy(this)},
    {typeof( Grounding_Point ),     new GroundingPointStrategy(this)},
    {typeof( Busbar ),              new BusbarStrategy(this)},
    {typeof( AARU ),                new AutomaticAssuredReceptivityUnitStrategy(this)},
    {typeof( TPS ),                 new TractionPowerSubstationStrategy(this)},
    {typeof( AutoTransformer ),     new AutotransformerStrategy(this)},
    {typeof( Energy_Storage ),      new EnergyStorageStrategy(this)},
};
Run Code Online (Sandbox Code Playgroud)

我知道这里建议的Ctrl+ K, Ctrl+ ,并且我一直使用它,但这不是我正在寻找的。F

我尝试过手动切换代码,但我不想每次都这样做。

我正在寻找 Visual Studio 扩展。

361*_*615 4

我正在使用Code Alignment VisualStudio 扩展来实现此目的。

这是它能做什么(摘自官方网站

    person.FirstName = "Chris";                =>  person.FirstName  = "Chris"; 
    person.Surname = "McGrath";                =>  person.Surname    = "McGrath"; 
    person.Age = 24;                           =>  person.Age        = 24; 
    person.Occupation = "Software Developer";  =>  person.Occupation = "Software Developer"; 
    person.HomeTown = "Brisbane";              =>  person.HomeTown   = "Brisbane";
Run Code Online (Sandbox Code Playgroud)