5

So I'm trying to configure in Settings--> Code Style --> XML how I would like the order of the attributes to be sorted when reformatting the code using ctrl+shift+L on Windows. In my case, first all xmlns and other namespace attributes and then all the specific views attributes.
In order to do so, I tried playing with the rules preconfigured in the code style settings, and also by creating new rules. By default, first xmlns tags are shown, then view attributes, and then tools:..., as shown in the image here: enter image description here When going to Settings--> Code Style --> XML, I tried playing with the preconfigured rules and even tried creating a new rule, but didn't manage to get the tools:... attributes to be displayed after the xmlns attributes.
This is an image of the code style settings screen, also with the rule, I tried to create.
enter image description here Just to make sure, this is what I'm trying to achieve:
enter image description here
I also trying going over and over the documentaion but couldn't quite figure out how to properly create the rule, since it's not working.
XML code style documentaion
Has anyone tried changing these settings, and/or can help me with the setting?

Thank you

Roy Hen Engel
  • 625
  • 1
  • 7
  • 21
  • Is it `CTRL+ALT+L` or `CTRL+SHIFT+L` like you have saidi\ cause I always use the first one! – Xenolion Oct 17 '17 at 22:40
  • @Xenolion Doesn't really matter since the keyboard shortcut can be changed and may have been and I don't remember doing so. Bottom line is that I want to rearrange the code and sort the order of the attributes to my liking when reformatting using the keyboard shortcut. – Roy Hen Engel Oct 17 '17 at 22:43
  • I did not even if they are can be customized! – Xenolion Oct 17 '17 at 22:45

2 Answers2

5

Found the answer:
1. Add a new rule
2. In my case:
Name = tools:.*
Namespace = .*
3. Done!

Roy Hen Engel
  • 625
  • 1
  • 7
  • 21
0

In the same place, Settings--> Code Style --> XML Set default settings from Android profile.

Wrong setup

Wrong setup

After reimporting default settings (Set From -> Android)

After reimport default settings

andrey2ag
  • 3,670
  • 1
  • 12
  • 12