How to add Eclipse Code Formatter file in Android Studio
Asked Answered
C

1

22

What I have:

I have a customised code format (.xml) file that my team wants to use in our project. This file includes predefined coding styles and conventions for java file.

What I want to do:

Now I have to add this formatter as a default code format, so that when click the shortcut of auto code format, the entire file will be formatted according to the the conventions defined in the formatter.

Convenient answered 11/5, 2015 at 19:11 Comment(3)
as far as I know, you'll have to re-configure/re-type the format parameters inside AndroidStudio. That can be later exported for others on the team to use. It's in File -> Settings -> EditorDisinfect
can I ask, why do you use a custom code format, and what good is it?Toothy
Well, some software developer groups or even some companies keep their own coding convensions and styling, so that the code will be neat & clean and readable for each and every developers of the team. Even it will be helpfull for new developer who join the team to collaborate. We know there is a default formatter allready exist in most of the modern IDEs. But some times (in my case) a developer team has to create its own convensions to keep there code maintainable.Convenient
C
50

After a long 2days effort I managed the steps to integrate Eclipse Code Formatter in Android Studio

Here I am sharing step by step procedures to integrate Eclipse Code Formatter in Android Studio:

Step 1: Go to the Plugins Section of Android Studio. The easiest way is Click Shift twice and type Plugins. Now go to the plugins menu.

enter image description here

Step 2: Click on Browse Repositories

enter image description here

Step 3: Type Eclipse Code Formatter in the search box. Select it and Click Install button in the right section

enter image description here

Step 4: After successful installation you can see a blue Eclipse Icon in the top pen

enter image description here

Step 5: Now go to Settings >> Other Settings >> Eclipse Code formatter

Click the Browse button.

enter image description here

Step 6: Then select the Code Format XML file

enter image description here

Thats it

Any time you click the code formatting command your full code will be formatted according to the code formatter.

Code formatting shortcut:

Windows: Ctrl + Alt + L

Linux: Ctrl + Start + Alt + L

Mac: Option + Command + L

In case anyone want to see how the code formatter xml looks, you can check this one.

One of the mostly used code style used by google is here.

Convenient answered 12/5, 2015 at 17:16 Comment(6)
FYI: If you are using Ubuntu, you will need to change your system's Lock-Screen shortcut, which is also Ctrl-Alt-L by default.Rectifier
You can also download and install a Save Actions plugin to format the code automatically: File > Settings > Other Settings > Save ActionsUntinged
that is really helpfulWesternism
where did u get the eclipse java formatter config file from?Cohl
how can i get augmedix_android_dev.xml? and there are no any selection for Android StudioSpirochaetosis
Still useful answer for Android Studio 3.4Goldshell

© 2022 - 2024 — McMap. All rights reserved.