Chandra
Chandra

Reputation: 565

EditorConfig in Android Studio

There is an option in Android studio to enable EditorConfig support( defaultsettings->codingstyle dialog),but not sure how it works.Could you please let me know how to integrate .editorconfig file in the Andriod Studio project?

Upvotes: 23

Views: 12515

Answers (1)

Joshua
Joshua

Reputation: 3920

The website EditorConfig.org has a good explanation of how to get it set up. Android Studio has it built-in so there should be no need to add a plugin or set up Android Studio, just..

  1. Add your .editorconfig file in the root directory of the project (as mentioned at EditorConfig.org)
  2. Enable EditorConfig support (SettingsEditorCode StyleEnable EditorConfig support)
Note:

A search for .editorconfig files will stop if the root filepath is reached or an EditorConfig file with root=true is found.

Edit:

I would recommend starting with something along these lines, and tweaking it as your team sees fit:

# indicate this is the root of the project
root = true

[*.{kt,java,xml,gradle,md}]
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

Upvotes: 39

Related Questions