Visual Studio VB smart indent and crazy document format - how to fix or workaround?

I searched a bit here, and I am surprised that no one asked this question. Is Visual Studio 2010 VB smart indentation just awfully broken for multi-line statements? Or am I doing / installing something wrong? I set 4 character padding with keep tabs. Entering a multi-line operator in VB with natural returns gives the following (property names changed to protect the innocent).

Public Sub Sub1()
    Dim foo As New MyClassA With {.FileName = "test", 
                                  .Format = MyEnumForImageFormat.jpg,
                                            .IsReallySpecial = False,
                                                        .Name = "testN",
                                                                    .SourceId = Guid.NewGuid(),
                                                                    .VariantName = "TestV",
                                                                    .Width = 800,
                                                                    .Height = 600}
End Sub

How can someone format their code this way? I thought maybe I need to reformat (Ctrl + K Ctrl + D):

Public Sub Sub1()
    Dim foo As New ImageBase With {.FileName = "test",
              .Format = MyEnumForImageFormat.jpg,
                 .IsReallySpecial = False,
                    .Name = "testN",
                       .SourceId = Guid.NewGuid(),
                       .VariantName = "TestV",
                       .Width = 800,
                       .Height = 600}
End Sub

Reformat. , . , . , :

Public Sub Sub1()
    Dim foo As New ImageBase With {.FileName = "test",
     .Format = MyEnumForImageFormat.jpg,
     .IsReallySpecial = False,
     .Name = "testN",
     .SourceId = Guid.NewGuid(),
     .VariantName = "TestV",
     .Width = 800,
     .Height = 600}
End Sub

, , ? , , ? , - .

. ?

+5
2

, , , . , , .

Public Sub Sub1()
    Dim foo As New MyClassA With
        {.FileName = "test",
         .Format = MyEnumForImageFormat.jpg,
         .IsReallySpecial = False,
         .Name = "testN",
         .SourceId = Guid.NewGuid(),
         .VariantName = "TestV",
         .Width = 800,
         .Height = 600}
End Sub

, , . , , . , , , ( , , Enter.)

-, , . .

, :

Public Sub Sub1()
    Dim a As New Action(Sub()
                            Dim b As Double = 4.0
                            Dim c As Double = 5.0
                            Dim d As Double = b * c
                        End Sub)
End Sub

:

Public Sub Sub1()
    Dim a As New Action(
        Sub()
            Dim b As Double = 4.0
            Dim c As Double = 5.0
            Dim d As Double = b * c
        End Sub)
End Sub

, , .

+5

. Pretty Listing Vb.Net - : Visual Studio

-, , , .

: ; , "".

+1

All Articles