问题描述
这是推动我拐弯。我是一个很长一段时间VB.NET开发的形式,相当新的ASP.NET和完全新的MVC。我创建使用VB.NET剃刀语法vbhtml页,我似乎反对正试图缩进不正确我的code UI中不断拼搏。看看下面的例子,基于模板的页面上一个新的Razor视图:
This is driving me round the bend. I'm a long time VB.NET forms developer, quite new to ASP.NET and completely new to MVC. I'm creating vbhtml pages that use the VB.NET razor syntax, and I seem to be constantly fighting against the UI which is trying to indent my code incorrectly. Take the following example, based on the template page for a new Razor view:
@Code
Layout = Nothing
End Code
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div>
@If True Then
@<ul>
@For x = 1 To 2
Next
</ul>
End If '<-- Randomly indented too far
</div>
</body>
</html>
在上面的例子中,只要我打后,下一步回报,结束如果下面两行随机跳两个选项卡,从那里应该是向前。在其他例子中我已经打了一个循环,即推一行到正确的位置抛出另一条线出来的位置,反之亦然。
In the above example, as soon as I hit return after "Next", "End If" two lines below randomly jumps two tabs forward from where it should be. In other examples I've hit a circle where pushing one line to the correct place throws another line out of position and vice versa.
我很生气,在这一点上我很乐意完全禁用自动缩进,只是管理它自己,但我甚至不能找出如何做到这一点!在另一个线程以下建议,停止我禁用缩进HTML页面,但所有的HTML标签的压痕 - 在code块仍然四处滑动所有的地方
I'm so annoyed at this point I'd be happy to disable auto-indentation completely and just manage it myself, but I can't even find out how to do that! Following advice on another thread I disabled indentation for HTML pages but all that stops is indentation of HTML tags - the code blocks still slide around all over the place.
我想延长可能会导致这个问题,但我禁用所有这些,重新启动后问题仍然存在。我在做某种根本性错误?我很难相信这样似乎更容易,我只是不使用它的权利,微软将发布这么差的东西。
I thought an extension might be causing the problem but I disabled them all and restarted and the problem remains. Am I doing something fundamentally wrong? I find it hard to believe Microsoft would release something so poor so it seems more likely I'm just not using it right.
推荐答案
我发现(一种时尚)溶液的另一个问题(我确实张贴了这个问题之前,搜索硬找不到任何东西):<一href=\"http://stackoverflow.com/questions/6902204/why-doesnt-visual-studio-$c$c-formatting-work-properly-for-razor-markup\">Why不Visual Studio的code格式正常工作的剃刀标记?
I found a solution (of a fashion) on another question (I really did search hard before posting this question and couldn't find anything): Why doesn't Visual Studio code formatting work properly for Razor markup?
从本质上解决似乎是确保您的code使用,而不是标签的空白空间。同时提高,因为增加的空白页面的整体大小,但它确实减轻问题(虽然不是完全消除的话)。在挂线,别人谁似乎与微软相连承认这确实是关系到重叠格式化HTML和VB.NET,他们希望在新版本改善的错误。我已经下降到每缩进2个空格,以减轻对带宽的影响。
Essentially the solution seems to be to ensure that your code uses spaces instead of tabs for the whitespace. Whilst increasing the overall size of the page because of increased whitespace, it does lessen the problem (whilst not eliminating it completely). On the linked thread, someone who appears to be connected with Microsoft has acknowledged it is indeed a bug related to the overlapping formatters for HTML and VB.NET which they hope to improve in a new release. I've dropped to 2 spaces per indent to lessen the bandwidth impact.
感谢谁贡献的球员。
这篇关于我怎样才能让code缩进正确运行在vbhtml剃刀文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!