Visual Studio 2010 Code Formatting in .CSHTML - Improper Indentation
Asked Answered
T

1

15

Pretty simple problem to explain: In Visual Studio 2010 SP1, I'm seeing weird indentation issues with braces when using Razor.

Here's how it looks:

<div>
    <div>
        <div>
            <div>
                @if (true)
        {
                    <b>Hi</b> 
       }
            </div>
        </div>
    </div>
</div>

That's what comes out after I do a CTRL + K, D to format it. Anyone else have this issue? What's the deal?

Theresita answered 7/6, 2011 at 14:55 Comment(1)
I don't have a solution, but I can confirm the problem. We're calling the key combination "control-kill-death" currently...Limonene
R
16

This is a known bug in the editor.

To fix it, select Insert Spaces rather than Keep Tabs in Options, Text Editor, HTML.

Rentfree answered 7/6, 2011 at 15:14 Comment(8)
Horray for fix, boo to spaces.Ophthalmoscope
Seriously? Was that it? Nice, but too bad with spaces. I guess I can learn to live with it, but I shouldn't have to conform to the tool, it should be the other way around :(Kistner
By the way, here's the Connect issue on this: connect.microsoft.com/VisualStudio/feedback/details/637445/…Kistner
Argh, I hate using spaces. Hope they fix this soon, so I can go back to using tabs again.Jacobjacoba
that Connect link is marked Closed as duplicate. Here's the original - though it is marked closed as deferred :( connect.microsoft.com/VisualStudio/feedback/details/650455Holstein
@Valamas: What fix? :) This is just a workaround that shouldn't be tolerated for too long. An actual fix should be implemented.Disrobe
@Robert Koritnik: Yes, not a fix. And yes, should have been fixed as hot fix quickly. I think they vs2010 is abandoned as they are working on vs2011(or could be vs2012 by now). Could be time to have a play of that.Ophthalmoscope
This had been annoying me for quite some time. Thanks for the solution.Detach

© 2022 - 2024 — McMap. All rights reserved.