Indentation is broken in Visual Studio .cshtml files

后端 未结 3 406
北恋
北恋 2021-01-17 12:12

It\'s the most infuriating thing and after 45 minutes of Googling and testing I caved to the forum gods... I simply cannot live without automatic indentation, even if it\'s

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-17 12:57

    Since 3 weeks (since Update to Visual Studio 2015 SP 2 after VS 2013) I had the problem, that copy/paste and comment in cshtml files destroy my format of my file. Interestingly the tab indent was at column 7. I don't understand why.

    After Update to VS 2015 SP 3, the problem was not banned.

    Then I found out, that in my cshtml files a "@" sign destroyed my copy/paste/comments:

    @model MAWGridModel
    
    @if (Model != null)
    {
        @Html.DevExpress().GridView(settings =>
        {
            settings.Name = "MAWAktionenErgebnisGrid";
        ...
        }).Bind(Model).GetHtml();
    }
    

    The "@"before "Html.DevEpress()..." destroyed all. Here the code snippet which works for me. (I hope it will really do.)

    @model MAWGridModel
    
    @if (Model != null)
    {
        Html.DevExpress().GridView(settings =>
        {
            settings.Name = "MAWAktionenErgebnisGrid";
            // ...
        }).Bind(Model).Render();
    }
    

    Hopefully it helps you.

提交回复
热议问题