如果在保存代码时能自动格式化代码,例如去掉没有被引用的import类,并且按照格式模板格式化,那么既能提高代码质量又能提高开发效率。
二、代码格式化插件Save Actions1.Save Actions的功能如下:
Optimize importsRun on file save, shortcut, batch (or a combination)Run on multiple files by choosing a scopeReformat code (whole file or only changed text)Rearrange code (reorder methods, fields, etc.)Include / exclude files with regex supportWorks on any file type (Java, Python, XML, etc.)Uses a settings file per project you can commitAvailable keymaps and actions for activationEclipse configuration file 168飞艇6种不亏钱的方法ctions的功能如下: Optimize importsRun on file save, shortcut, batch (or a combination)Run on multiple files by choosing a scopeReformat code (whole file or only changed text)Rearrange code (reorder methods, fields, etc.)Include / exclude files with regex supportWorks on any file type (Java, Python, XML, etc.)Uses a settings file per project you can commitAvailable keymaps and actions for activationEclipse configuration file .epf support (Java IDE only)Automatically fix Java inspections (Java IDEA only)2.安装Save Actions插件:
3.Save Actions默认没有激活,需要激活:
阿里的代码规范是开源的,编码时如果遵循阿里的代码规范,则可使用阿里的代码模板。
1.先安装Eclipse Code Formatter插件并安装:
2.下载阿里代码模板:
https://github.com/alibaba/p3c/tree/master/p3c-formatter
3.使用阿里代码模板:
至此,就可以在保存Java代码时自动按照阿里的代码模板格式化代码了。
end.