1.Settings->LiveTemplates

2.点击右侧加号添加模板,添加组或者单个模板

3.比如,添加一个单例

其中:
abbrevlation:模板的缩写,写代码时写缩写就会提示出来
description:模板注释
template Text:最终写在编辑器上的代码。$values$ 用$x$代表生成代码后光标会停留在该位置
例子:
private static $CLASS$ instance = null;
private $CLASS$(){ }
public static $CLASS$ getInstance() {
synchronized ($CLASS$.class) {
if (instance == null) {
instance = new $CLASS$();
}
}
return instance;
}
4.新建的模板需要选择使用场景:

5.点击define,选择要使用该模板的场景

网友评论