none
[VS2015] 请问Razor代码块的自动排版经常错乱,是什么原因?有办法解决吗? RRS feed

  • 问题

  • 使用的vs15

    前端页面的Razor代码块的自动排版经常错乱,比如正常应该是(手动排版)如下这样

    然后我Ctrl+K,Ctrl+D自动排版后,就变成如下这样

    想问一下有没有什么解决办法?

    2017年9月13日 7:33

答案

  • 你好,

    关于这个问题,请您参考:

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

    已经有很多成员有同样的疑问,您可以参考下marcind的解释:

    It does not work correctly in all cases because it's a difficult problem to solve. Essentially you have 3 different editors (HTML, C#, and Razor) all interacting over the same text buffer. There are some cases (like this one) where the interactions have bugs. But we are working on improving the editor for the next release of Razor.

    由于在HTML里面内勤了C#和Razor的代码,在格式统一的交互中存在text buffer,导致在format过程排版中不能统一。我已经把这个问题通过 Developer Community反馈给产品组,请您耐心等待这个问题在下个Razor发布版本里面优化。

    感谢您的理解与配合:)


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • 已标记为答案 xiaojunjor 2017年9月18日 1:14
    2017年9月14日 9:29
    版主

全部回复

  • Edit => Advanced => Format Document

    专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms

    2017年9月14日 0:44
  • 你好,

    关于这个问题,请您参考:

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

    已经有很多成员有同样的疑问,您可以参考下marcind的解释:

    It does not work correctly in all cases because it's a difficult problem to solve. Essentially you have 3 different editors (HTML, C#, and Razor) all interacting over the same text buffer. There are some cases (like this one) where the interactions have bugs. But we are working on improving the editor for the next release of Razor.

    由于在HTML里面内勤了C#和Razor的代码,在格式统一的交互中存在text buffer,导致在format过程排版中不能统一。我已经把这个问题通过 Developer Community反馈给产品组,请您耐心等待这个问题在下个Razor发布版本里面优化。

    感谢您的理解与配合:)


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • 已标记为答案 xiaojunjor 2017年9月18日 1:14
    2017年9月14日 9:29
    版主
  • 原来是这样。。那只能先忍着了,谢谢了
    2017年9月18日 1:14