--wrap-attributes
选项有这些可能的值: auto|force|force-aligned|force-expand-multiline
这允许将所有属性压缩到一行或自动包装每个属性。
是否有可能只保持初始包装?
这是一个好主意,没有一个选项允许手动包装。
如果auto
仅包含所需的属性数量,则只有在force|force-aligned|force-expand-multiline
的选项会很棒。 像auto-expand-multiline|auto-aligned
选项?
@罗布拉
请为您在第二段中的内容打开一个新问题。
@Montago , @Andikki - 你所描述的是一个名为unchanged
或preserve
,对吗?
@bitwiseman不,只是另一个选项,例如“强制对齐”……而是“自动对齐”
它应该做的只是对齐所有手动包装的属性。
所有其他元素/属性都保持不变。
@Montago - 啊,更像align-only
。
是的,这是有道理的:)
撞这个!
在新行上手动设置一些属性,在同一行上手动设置一些属性会很棒。 然后我可以决定我想要哪一个,其他所有内容都会自动格式化。 谢谢
@bitwiseman我不认为对齐是必要的,但如果是,则必须有两个选项 - 一个应用通常的 indent_size,另一个用于对齐 - 同时保持初始换行符。
例子
来源:
<input type="text" class="form-control" autocomplete="off"
[(ngModel)]="myValue" [disabled]="isDisabled" [placeholder]="placeholder"
[typeahead]="suggestionsSource" [typeaheadOptionField]="suggestionValueField" [typeaheadItemTemplate]="suggestionTemplate" [typeaheadWaitMs]="300"
(typeaheadOnSelect)="onSuggestionSelected($event)" />
仅强制缩进:
<input type="text" class="form-control" autocomplete="off"
[(ngModel)]="myValue" [disabled]="isDisabled" [placeholder]="placeholder"
[typeahead]="suggestionsSource" [typeaheadOptionField]="suggestionValueField" [typeaheadItemTemplate]="suggestionTemplate" [typeaheadWaitMs]="300"
(typeaheadOnSelect)="onSuggestionSelected($event)" />
仅强制对齐:
<input type="text" class="form-control" autocomplete="off"
[(ngModel)]="myValue" [disabled]="isDisabled" [placeholder]="placeholder"
[typeahead]="suggestionsSource" [typeaheadOptionField]="suggestionValueField" [typeaheadItemTemplate]="suggestionTemplate" [typeaheadWaitMs]="300"
(typeaheadOnSelect)="onSuggestionSelected($event)" />
不确定这是否是请求这个的正确问题,但我觉得auto-align
选项应该像auto
; 在某个列截断后换行,如果换行,它会将标签视为force-align
。
例子
当行长大于 wrapLineLength 时强制对齐:
<div [isWrapped]="false" [attributesAligned]="false"></div>
<really-long-angular-component-that-would-force-wrapping class="wrapped"
[isWrapped]="true"
[attributesAligned]="true">
几乎浏览了 5 或 6 个人们期待此功能实施的主题。 既然不是,最好在 vscode 上使用 if wrap requries 和 force-alignment for this对应的行 vs.
😞
@kaankucukx不确定你的意思? 前面的示例中是否涵盖了它?
为此 +1,我目前使用force
的车把效果最好,但它仍然会导致在我的车把块中出现不必要的包装:
</label>
{{#artdeco-hoverable-trigger placement="right"
as
|card|}}
和
<ul class="text-ad-edit-panel__dropdown-list">
{{#each yourCompanyPageTypes
as
|companyPageType
index|}}
我只需要保留手动换行属性的换行符,但要获得正确的缩进。
FWIW 这在我发现的任何编辑器中都不起作用,除了 Intellij。 不过很想看到这个实现!
FWIW 这在我发现的任何编辑器中都不起作用,除了 Intellij。 不过很想看到这个实现!
也适用于 Netbeans。
FWIW 无法在 VSCode 中使用此功能
用 Vue 开发
扩展名:Prettier、Vetur
格式化不断将所有 html 标记和属性还原为一行。 我已经尝试了很多建议的解决方案。
很高兴知道人们是否可以在 VSCode 的 .vue 文件中使用此功能
@christoferd这就是这个问题的意义所在。 这是行不通的。 js-beautify 无法保留换行符。 它将始终将其设置为一行。
我继续使用 WebStorm,因为他们有自己的格式化程序,并且可以使用换行符。
与#1404相关
感谢您修复@MacKLess! 我正在焦急地等待新版本,所以我可以尝试一下😃
最有用的评论
这是一个好主意,没有一个选项允许手动包装。
如果
auto
仅包含所需的属性数量,则只有在force|force-aligned|force-expand-multiline
的选项会很棒。 像auto-expand-multiline|auto-aligned
选项?