IntelliJ IDEA(三)代码自动格式化 |
您所在的位置:网站首页 › idea中代码格式化 › IntelliJ IDEA(三)代码自动格式化 |
一、代码自动格式化提高效率
如果在保存代码时能自动格式化代码,例如去掉没有被引用的import类,并且按照格式模板格式化,那么既能提高代码质量又能提高开发效率。 二、代码格式化插件Save Actions1.Save Actions的功能如下: Optimize imports Run on file save, shortcut, batch (or a combination) Run on multiple files by choosing a scope Reformat code (whole file or only changed text) Rearrange code (reorder methods, fields, etc.) Include / exclude files with regex support Works on any file type (Java, Python, XML, etc.) Uses a settings file per project you can commit Available keymaps and actions for activation Eclipse 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.下载阿里代码模板: github.com/alibaba/p3c… ![]() 3.使用阿里代码模板: ![]() 至此,就可以在保存Java代码时自动按照阿里的代码模板格式化代码了。 end. 站点: javashizhan.com/ 微信公众号: ![]() |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |