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

IntelliJ IDEA实时代码模板

 

 

在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

相关文章:

  • 2021-05-17
  • 2021-04-14
  • 2021-04-11
  • 2021-07-28
  • 2022-12-23
  • 2021-07-23
  • 2021-05-17
猜你喜欢
  • 2021-04-02
  • 2021-09-15
  • 2021-11-28
  • 2022-12-23
  • 2021-04-01
  • 2022-01-20
  • 2021-05-16
相关资源
相似解决方案