首页 > 编程知识 正文

idea自动格式化代码,idea代码自动换行

时间:2023-05-03 13:26:22 阅读:269054 作者:3985

一、代码自动格式化提高效率

如果在保存代码时能自动格式化代码,例如去掉没有被引用的import类,并且按照格式模板格式化,那么既能提高代码质量又能提高开发效率。

二、代码格式化插件Save Actions

1.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.

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。