VS Code中Emmet: Wrap with Abbreviation无法换行包裹文本求助
解决VS Code Emmet「Wrap with Abbreviation」不换行问题
问题场景
使用VS Code的Emmet「Wrap with Abbreviation」功能包裹文本时,无法让被包裹的文本单独换行并缩进,常规Emmet缩写能正常生成带换行的结构,但此功能无效。已尝试以下配置均无效果:
"emmet.preferences": { "output.inlineBreak": 1, "format.forceIndentationForTags": [ "div", "p" ] },
"emmet.syntaxProfiles": { "html": { "tag_nl": true } }
期望效果:
<p> This is what is expected </p>
实际效果:
<p>This is what I get</p>
可行解决方案
方案1:全局配置Emmet输出格式
在VS Code设置中添加以下配置,强制Emmet以展开格式输出:
"emmet.preferences": { "output.format": "expanded" }
该设置会让所有Emmet生成的代码(包括Wrap with Abbreviation)都使用展开换行的格式。
方案2:包裹时指定格式缩写
如果不想全局修改,可在使用「Wrap with Abbreviation」时,输入带格式指定的缩写,比如要包裹成p标签,就输入p:expanded,这样会强制当前包裹操作生成展开格式的标签结构。
方案3:配合HTML格式化设置
若上述方案仍无效,可调整VS Code的HTML格式化设置,确保不会压缩Emmet生成的代码:
"html.format.wrapLineLength": 0, "html.format.preserveNewLines": true
内容的提问来源于stack exchange,提问作者Mattie C
相关产品推荐
相关产品推荐

