Indentation is broken in Visual Studio .cshtml files

后端 未结 3 407
北恋
北恋 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:56

    I work with VS2017 (asp.net core 2.2), use Devextreme controls and have exactly the same problems.
    I have deactivated the automatic auto format after copy paste since a longer time now (as it don't work).
    As I have large views with > 100 DE controls (each with about 5 properties in average), I have to format the view (with "Format document" whereby "Format selection" don't work in my installation, b.t.w.) from time to time, to make the file structure "readable".

    If I do so, I have exactly the same problem (the lines are intended to the right until they are not visible as "out of monitor" and I have a large monitor...).
    To make the file "readable" again, I have to edit every single line manually (remove wrong space).

    I have wasted hours now with try-and error. The only (very ugly and bad) "workaround" I found is, to write the whole code on ONE line.
    Example: @(Html.DevExtreme().TextBox().ID("AngebotFirma").Value(@Model.PAB_Firma).MaxLength(45).Placeholder("Firma...").InputAttr("autocomplete", "company") )

    This way, the whole document (HTML, JQuery and also Devextreme (the one line) is formatted (intended) correct.

    So.. this is not a solution, but may be a workaround to save time. I change my code to "one line code" at least until I have finished and tested the views. After that, I - maybe - will change the code back to "multiline"...

提交回复
热议问题