为什么正确的剃刀标记不Visual Studio的code格式的工作? [英] Why doesn't Visual Studio code formatting work properly for Razor markup?

查看:193
本文介绍了为什么正确的剃刀标记不Visual Studio的code格式的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

或者,我应该先问一下,什么时候才能VS code格式正常工作的剃刀标记?该格式适用于大多数的结构,但它似乎呛如果块。的$ C $下面c是因为它是由VS.格式化这是很容易解决这个问题的情况下,多一个缩进,但我很好地接受了格式化的日常使用,喜欢经常使用它的大部分我code,所以我宁愿尽可能避免手动格式化。现在,我只是把它作为VS格式化它。

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 code below is as it is formatted by VS. It is very easy to fix this case, with one more indent, but I nicely accepted the formatting in everyday use, and like to use it often for the bulk of my code, so I'd rather avoid manual formatting if possible. Right now I just leave it as VS formats it.

@{ 
    if (User.Identity.IsAuthenticated)
    {
    <text>Hello </text>
    @Html.Display("@ViewBag.UserName") <text> - </text>
    @Html.ActionLink("Sign Out", "LogOff", "Account", null, new { style = "font-weight: bold;" })
    }
 }

我认为这是可读性的,例如重要在上面,if块的身体缩进,除了刚才看更好。

I think it's important for readability that, e.g. in the above, the body of the if block is indented, besides just looking nicer.

推荐答案

一定要设置为使用空格字符,而不是选项卡中的编辑器。编辑似乎完全失去了主意使用标签时。这是一种耻辱,因为所有的空格字符,在实际的HTML输出结束了,大大提高了数据传输的大小。
我要做的就是手动补充自动格式化为I型。不理想,但希望微软都会有这个想通了,下一个服务包。

Be sure to set the editor to use space characters and not tabs. The editor seems to completely lose its mind when tabs are used. This is a shame because all those space characters end up in the actual HTML output, greatly increasing the data transfer size. What I do is manually supplement the automatic formatting as I type. Not ideal, but hopefully Microsoft will have this figured out for the next service pack.

这篇关于为什么正确的剃刀标记不Visual Studio的code格式的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆