在IntelliJ IDEA中配置Google Java Code Style及代码格式化快捷键

google-java-format plugin should intercept the “Reformat Code” action in IDEA (Ctrl+Alt+L) and apply its own rules. However, it does not work with imports for some reason, so to fix that you have to import a Java Google Code Style XML file  to your code style settings in IDEA.

 

1.下载Google Java Code Style在IntelliJ中的配置文件 https://github.com/google/styleguide
2.选择”File”菜单组下的”Settings”菜单项:
3.选择”Editor->Code Style”菜单项,并点击图示的”Intellij IDEA code style XML”导入第1步中下载的配置文件(可修改导入的配置名,此处使用默认的”GoogleStyle”):

4.将当前项目的”Schema:”设置为第3步中导入的”GoogleStyle” 

5.”Editor->Code Style->Java->Imports->Names count to use static import with *”菜单项, 输入1

6.Install google-java-format plugin (File -> Settings -> Plugins -> Browse repositories -> search for “google-java-format” and install)

   After installation, the plugin has to be enabled per-project (it is disabled by default). To do that, open your project and go to File -> Settings -> Other Settings -> google-java-format Settings and check “Enable google-java-format”

转载网址:在IntelliJ IDEA中配置Google Java Code Style及代码格式化快捷键

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值