Search code examples
htmlvisual-studio-codeelement

Is there any shortcut/hotkey in vscode to format attributes of an html element


I have this code of element, and i need to format the attributes from this:

<input class="cool-input" id="input" value="test" placeholder="test" />

to

<input class="cool-input"
  id="input"
  value="test"
  placeholder="test"
/>

but I didn't find any hotkey to do it. Is there any, and if there is, what is it?


Solution

  • Try this setting:

    HTML > Format: Wrap Attributes set to force

    and then select your line:

    <input class="cool-input" id="input" value="test" placeholder="test" />

    and trigger the command Format Selection and you will get:

    <input class="cool-input"
      id="input"
      value="test"
      placeholder="test" />