-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[html] attribute on separate line formatting #2204
Comments
From what I've read, the js-beautify project is what's used for HTML formatting in VSCode. I submitted a suggestion to them to implement this feature (feel free to up-vote it). If/when they do, VSCode will need to implement the configuration to support the feature. |
+1 |
1 similar comment
+1 |
For people wanting this feature right now, read on. Ok it seems this function is already implemented on js-beautify, see: https://github.com/beautify-web/js-beautify and look for this setting: So, I did some digging in the source code and found the setting in the beautify-html.js script. I modified the wrap-attributes settings from auto to force and voila, it works! Here is the repro for people wanting this feature also:
|
@Maus3rVonDutch Thanks for this temporarily solution! The only ugly way obviously is to set it up, otherwise it would be brilliant. |
+1 to wanting this |
+1, MUST HAVE! |
+1 |
+1 edit: it seems this might be coming to js-beautify pretty so pretty soon, via |
+1 |
Yeah this is really needed; doing binding interpolations on things like SVG element attributes can make the elements rather long. |
+1 For readability of elements and attributes, and to prevent long lines |
@Maus3rVonDutch I updated to 1.7.1 and it doesn't work anymore, is there any other solution/fix ? |
It seems a new option was added for the ---wrap-attributes flag ( force-aligned ) js-beautify library. Maybe this solves the problem? |
Indeed, I saw this new option too but it doesn't work also. I tried to set wrap-attributes settings to :
:( ... |
'force-align' is not out yet, see beautifier/js-beautify#916 Hopefully 1.6.5 of js-beautify will come out soon so this feature can find its way into vscode! |
I'm using "wrap_attributes" with jsbeautify in vscode. I have: vscode: 1.7.1 I'm using a
then calling On Sun, Nov 20, 2016 at 8:05 PM Hanno Neuer [email protected]
|
Is anyone having this break with the latest vscode? (1.8.1)? My jsbeautify wrap_attributes stopped working with that version. Thanks! |
Using VSCode 1.9.0 with the following setting works fine:
|
Using 1.9.1 on code: <div>
<div>
<div attr1="" attr2=""></div>
</div>
</div> With settings: <div>
<div>
<div attr1=""
attr2=""></div>
</div>
</div> With js-beautify extension and .jsbeautifyrc:
the same result |
@vitaly-andriyanets You can file your issue directly against https://github.com/beautify-web/js-beautify which is the formatter VSCode use. |
This issue is fixed in js-beautify 1.6.9 |
@mvdenk Is there any way to get vscode to "consume" this js-beatify fix? I am on VS Code 1.9.1 and experiencing this issue. |
@vigie I'm also at VS Code 1.9.1 and it works for me. I just use it like this: |
An updated version for jsbeautify went into VSCode 1.10 has the fix. |
@vigie To temporary fix this in VSCode 1.9.1 you can replace C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions\html\server\node_modules\vscode-html-languageservice\lib\beautify\beautify-html.js with beautify-hytml.js. |
@mvdenk Works like a charm, thanks! |
@mvdenk using the setting
instead of:
|
@mtpultz The code sample you showed is not valid html. I don't think |
@mtpultz what about It works for me. It's formatting output is now :
|
@mtpultz That seems to be working for me |
Thanks @lacroixdavid1 and @zatchgordon you're right. I had |
I added |
Here's a little hint: Maybe someone uses Vetur or other plugins and it's not working. It's possible that they use their own settings. For example Vetur uses the property EDIT This is obsolete now. {
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "force-aligned"
}
}
} |
I really want a setting that allows me to align the attributes if they are on a new line, but not force them. My ideal setting would be something like so: "html.format.wrapLineLength": 50, That way it drops attributes to a new line if they get too long, but also aligns them properly. As far as I can tell there is no way to do this with the current VSCode options. |
HTML Formatting ideally should have a feature to separate attributes on new lines when using
format code
.e.g.
When using format code should be formatted as:
The text was updated successfully, but these errors were encountered: