Android Studio中的EditorConfig

Cha*_*dra 8 java android styles editorconfig

Android studio中有一个选项可以启用EditorConfig支持(defaultsettings-> codingstyle对话框),但不确定它是如何工作的.请您告诉我如何在Andriod Studio项目中集成.editorconfig文件?

Jos*_*ing 12

EditorConfig.org网站对如何设置它有一个很好的解释.Android Studio内置了它,因此不需要添加插件或设置Android Studio,只需...

  1. 将您的.editorconfig文件添加到项目的根目录中(如EditorConfig.org中所述)
  2. 启用EditorConfig支持(Settings→交通Editor→交通Code Style→交通Enable EditorConfig support)
注意:

如果到达根文件路径或找到root = true的EditorConfig文件,将停止搜索.editorconfig文件.

编辑:

我建议从这些方面开始,并根据你的团队认为适合调整它:

# 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
Run Code Online (Sandbox Code Playgroud)