Why doesn't Visual Studio code formatting work properly for Razor markup?

后端 未结 10 1620
醉梦人生
醉梦人生 2020-12-08 13:04

Or, should I rather ask, when will VS code formatting work properly for Razor markup? The formatting works for most structures, but it seems to choke on \'if\' blocks. The c

10条回答
  •  遥遥无期
    2020-12-08 13:13

    I found one "solution" that allows you to continue using tab indentation and have correct formatting. It's more of a pattern. The key is to use razor code blocks instead of inline code.

    So for example, replace the following:

    @if (true) { Hi }

    with:

    @{ if (true) { Hi } }

    The latter will format correctly, but the former won't.

    Keep in mind, the formatting isn't perfect, but it's better than before.

提交回复
热议问题