IntelliJ IDEA实时代码模板

首先,通过 Settings > Editor - Live Templates进入设置窗口

 

 

在Abbreviation:中设置缩写,在 Template text:中设置模板内容,通过 Change改变模板的使用范围。

 

如图所示,在Java代码的方法体中输入arr,按tab键,就自动使用了该代码模板。

 

一般可以新建一个Template group来存放所有的自定义的代码模板,所有的代码模板都会反映在config/templates文件夹内,目前来说,Deolin常用的有:

1、new一个ArrayList时

2、日志输出info

3、new一个Log4j2的日志实例

4、main方法

5、System.out.println()

6、new一个StringBuilder实例,顺带第一次sb.append()

7、日志输出warn

8、日志输出error

 

详细:https://github.com/spldeolin/intellij-idea-config/tree/master/config/templates

posted @ 2017-10-24 17:32  Deolin  阅读(645)  评论(0编辑  收藏  举报