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

Time:03-07

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

<input  id="input" value="test" placeholder="test" />

to

<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?

CodePudding user response:

Try this setting:

HTML > Format: Wrap Attributes set to force

and then select your line:

<input id="input" value="test" placeholder="test" />

and trigger the command Format Selection and you will get:

<input 
  id="input"
  value="test"
  placeholder="test" />

CodePudding user response:

Check this thread Stackoverflow thread

Installing an VSCode extension can help too. Here's one Prettier – Code formatter

Can be set up to format on save and Format on selection. The Doc has a very detailed how to guide.

P.s. Don't know why some users devoted my answer.

  • Related