How can I put a HTML tag in one line in VS Code?
Asked Answered
C

3

7

The VS Code in my Mac pc is automatically breaking the customer HTML tags in new lines. This is making the length of the whole code much bigger. For example, I want below code in one line

<FormInput name="propertyTax" width="43%" height="7%" placeholder="3,200"></FormInput>

But the VS code is showing as below.

<FormInput
name="propertyTax"
width="43%"
height="7%"
placeholder="3,200">
</FormInput>

I tried change wordwrap from settings with no luck.

Please help me.

Clos answered 17/5, 2022 at 21:37 Comment(1)
Do you have the setting HTML > Format: Wrap Attributes set to anything besides auto? If so, that can cause what you are seeing. And see https://mcmap.net/q/642371/-disable-html-attribute-alignment-in-visual-studio-code.Kean
C
6

Just press F1, and type: join lines

Cabbagehead answered 15/11, 2022 at 13:44 Comment(1)
Don't forget to select all. Ctrl/Command + aScaler
A
1

You can try switching off any formatters that you have in VSCOde. Go to Code > Preferences > Settings and search for "Format" and try switching off "Format on Save" and any other format option that you have.

Afterdeck answered 17/5, 2022 at 21:41 Comment(2)
"Format on Save" worked. Thanks a lot.Clos
Eventually you have to format one day! How can I override the lint formatter itself ?Faints
J
1

If you're using Prettier formatter. Go to Settings and search for this: prettier.printWidth and change from default 80 to 300.

Jerrodjerrol answered 14/11, 2022 at 7:17 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.