Skip to content
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

Improve xml.format.splitAttributes settings #631

Open
informatik01 opened this issue Dec 29, 2021 · 4 comments
Open

Improve xml.format.splitAttributes settings #631

informatik01 opened this issue Dec 29, 2021 · 4 comments

Comments

@informatik01
Copy link

Hi.

Currently when xml.format.splitAttributes is set to true, all the attributes appear each on a new line, like this:

<tag
        type="sample"
        name="foo"
        value="bar">

It would be really nice to be able to leave the very first attribute on the same line as the opening tag
and all the other attributes could be aligned by the beginning of this first attribute, like this:

<tag type="sample"
     name="foo"
     value="bar">

Like add an additional option to either leave the first attribute on the same line as the opening tag OR make each attribute appear on a separate line. And if the "leave the first attribute on the same line" is selected then its beginning should be the start of alignment for all the subsequent attributes.

I am just used to how the "XML Tools Plugin" in Notepad++ does it, so I didn't expect to see the first attribute also on a separate line.

@angelozerr
Copy link
Contributor

Indeed we should have this settings.

@fbricon what about having xml.format.firstAttributeOnSameLineAsStartTag ?

@angelozerr
Copy link
Contributor

It should be nice to have this feature, but I don't know when we will have time to implement it.

@martin-braun
Copy link

martin-braun commented Feb 8, 2022

There are really a lot of ways to format. See for instance the way Android Studio does it:

<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="MyApp"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher">

I would also argue that someone could go for

<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="MyApp"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher"
>

for personal preferences like myself. So in conclusion I think we need more variables to fine-tune, something like:

  • splitAttributes (true for multiline)
  • dontSplitOffFirstAttribute (true to put first attribute in same line)
  • dontSplitOffLastAttribute (true to put last attribute in same line)
  • unguidedAttributeIntention (number of spaces to intent the attributes when the first attribute is not on the same line as the tag)

(Intentionally negated the new variables to make false the default value, but this is personal preference whatsoever)

Please make this happen, thanks a lot! :)

@angelozerr
Copy link
Contributor

@fbricon @JessicaJHee it could be nice if experimental formatter could provide this support.

We need at first clarify all suggested settings.

Thanks @martin-braun for your suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants