Dev Doomari
Dev Doomari

Reputation: 997

(intellij) format xml with tag-end part on new line

I'm using Android Studio, and layout xml indentation is auto-formatting in somewhat wrong way for me.

Instead of

<!-- case1: miss-diffs on git -->
<SomeXML
    attr1="hello" >
</SomeXML>

or

<!-- case2: wrong end(?) indentation level -->
<SomeXML
    attr1="world"
    >
</SomeXML>

I'd like to format my xml as

<SomeXML
    attr1="hello"
>
</SomeXML>

so that my git diff won't show any miss-diffs from case1, and without wrong indentation level (case2) to confuse myself.

Are there any options in intellij for this? Thanks in advance : )

Upvotes: 6

Views: 2113

Answers (2)

Twisted Lullaby
Twisted Lullaby

Reputation: 591

On Android Studio 4.0.1:

Go to Settings (or Preferences on MaxOS) -> Editor -> Code Style -> XML -> "Other" Tab.

Check Keep line breaks.

Upvotes: 1

Supun Wijerathne
Supun Wijerathne

Reputation: 12958

Go to File -> Settings -> Editor -> Code Style -> XML

Change the Scheme there to Default. Normally it doesn't restrict on what you are trying to do, unnless there is any defined settings.

enter image description here

Upvotes: 1

Related Questions