在每个标记属性上换行并在 Visual Studio HTML 代码编辑器中保持对齐

Break line on each tag attribute and keep them aligned in Visual Studio HTML code editor(在每个标记属性上换行并在 Visual Studio HTML 代码编辑器中保持对齐)
本文介绍了在每个标记属性上换行并在 Visual Studio HTML 代码编辑器中保持对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你希望在下一个版本的 VS 中实现这一点,请投票 <小时>

如果你希望在下一个版本的 VS 中实现这一点,请投票 这里.

解决方案

如果你觉得勇敢,你可以编写一个编辑器扩展来为你做这件事.看看 Noah 前​​段时间为想法编写的 align 扩展:https://github.com/NoahRic/AlignAssignments

If you'd like to see this implemented in the next version of VS, please vote for it here.


Suppose the following horizontally lengthy <button> HTML declaration:

<button type="submit" class="btn btn-primary" id="save" name="action:@ViewContext.RouteData.Values["action"]"><i class="icon-save icon-large"></i> @Localization.Save</button>

As you see all tag attributes are inline such that they extend a long way to right in the code editor...

Do you know of any Visual Studio option or extension that allows it to be formatted with Ctrl + K then Ctrl + F like this:

<button type="submit"
        class="btn btn-primary"
        id="save"
        name="action:@ViewContext.RouteData.Values["action"]">
<i class="icon-save icon-large"></i>@Localization.Save
</button>

I think the above format makes it easy to spot a given attribute although it'll clearly make the vertical scroll-bar a little longer. :)

I tried fiddling with Visual Studio options in TOOLS => Options... => Text Editor => HTML but didn't find an option to control this behavior.

Of course I can align it manually but then if I hit Ctrl + K then Ctrl + F by mistake I lose all the custom made formatting.

If there's no such a thing available, I think this makes a great idea for a Visual Studio extension. As a plus it could even alphabetically order the attributes. :)


Doing a little bit more Googling I found that the XAML editor in Visual Studio has what I'd like to have in the HTML editor:

Position each attribute on a separate line


I asked this same question at the Visual Studio Extensibility forum:

http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/0d97c205-9f29-4ba7-9d0b-253413077dce/


If you'd like to see this implemented in the next version of VS, please vote for it here.

解决方案

If you feel brave, you can write an editor extension that does this for you. Take a look at the align extension that Noah wrote a while ago for ideas: https://github.com/NoahRic/AlignAssignments

这篇关于在每个标记属性上换行并在 Visual Studio HTML 代码编辑器中保持对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

how to remove this error quot;Response must contain an array at quot; . quot;.quot; while making dropdown(如何删除此错误quot;响应必须在quot;处包含数组。创建下拉菜单时(Q;))
Why is it necessary to use `document.createElementNS` when adding `svg` tags to an HTML document via JS?(为什么在通过JS为一个HTML文档添加`svg`标签时,需要使用`Document.createElementNS`?)
wkhtmltopdf print-media-type uses @media print ONLY and ignores the rest(Wkhtmltopdf print-media-type仅使用@media print,而忽略其余内容)
price depend on selection of radio input(价格取决于无线电输入的选择)
calculate price depend on selection without button(根据没有按钮的选择计算价格)
Conditional formatting if a cell matches one from a list of a different sheet using Apps Script(如果单元格与使用Apps脚本的不同工作表列表中的单元格匹配,则设置条件格式)