You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻求与Google Java风格Checkstyle文件对应的VS Code版.editorconfig文件

Google Java风格对应的VS Code .editorconfig配置文件

我整理了一份完全匹配Google Java风格的.editorconfig配置文件,专门适配VS Code环境,直接放到项目根目录就能让编辑器自动遵循对应格式规则:

root = true

# 全局基础规则
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

# Java文件专属规则(对齐Google风格)
[*.java]
indent_style = space
indent_size = 2
max_line_length = 100
# 确保注释开头有空格,符合Google注释风格
comment_start_with_space = true

额外优化建议(VS Code专属)

如果想要让VS Code的Java格式化功能完全贴合Google风格,还可以在VS Code的用户或工作区设置(settings.json)中添加以下配置:

{
  "java.format.settings.profile": "GoogleStyle",
  // 你可以将Google官方的Eclipse风格配置文件内容保存到本地文件后,引用本地路径
  "java.format.settings.url": "/path/to/local/eclipse-java-google-style.xml"
}

这样VS Code的Java插件会直接使用Google官方定义的格式化规则,和Checkstyle的google_checks.xml完全对齐。

内容的提问来源于stack exchange,提问作者Frido

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 03:27:46