I am using prettier to format my code in VS Code but I really dislike how it does it.
My main beef is it splitting attributes over multiple lines.
<input type="checkbox" name="asiaNews" id="asiaNews" value="asiaNews" />
I'd much prefer it to look like this
<input type="checkbox" name="asiaNews" id="asiaNews" value="asiaNews" />
I can't find anything in the docs or on SO
How to prevent VS Code from breaking up long HTML lines into multiple lines?
Is there a way to do it or a different tool that I can use so I can have my own custom formatting rules that suits my sensibilities?
How can you prevent VS Code from breaking up long HTML lines into multiple lines? My solution: Select the SVG you want to convert to single line. Then press F1 and type Join Lines and hit enter.
Command+Shift+P to open it. It will show search bar with right arrow >, just start typing Format Document With, and you will come up with results as below. Select Format Document With and again you will be asked for few options. Select Prettier — Code Formatter and your file will be formatted.
A quick fix is to go to Prettier Extension Settings (ctrl + shift + X) and in Prettier Extension Settings search for "Print Width" set it to 250 or anything that works for you.
1: Go to Extention Settings:
2: Change the value of Print Width to your liking.
To disable format code on save. Turn off the "Format On Save" and use Alt+Shift+F
to format the code when ever you want.
You can visually check the setting here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With