当前位置:网站首页>IDEA的模板(Templates)
IDEA的模板(Templates)
2022-08-03 12:38:00 【Redamancy06】
4.模板
4.1Live Templates(实时代码模板)功能介绍
它的原理就是配置一些常用代码字母缩写,在输入简写时可以出现你预定义的固定模式的代码,使得开发效率大大提高,同时也可以增加个性化。最简单的例子就是在Java中输入sout会出现System.out.println();
官方介绍 Live Templates:
https://www.jetbrains.com/help/idea/using-live-templates.html
4.2已有的常用模板
Postfix Completion 默认如下:
Live Templates 默认如下:
二者的区别:Live Templates可以自定义,而Postfix Completion不可以。同时,有些操作二者都提供了模板,Postfix Templates较Live Templates能快0.01秒
4.3举例
4.3.1psvm或者main:可生成main方法
4.3.2sout : System.out.println() 快捷输出
类似的:
soutp=System.out.println("方法形参名 = " + 形参名);
soutv=System.out.println("变量名 = " + 变量);
soutm=System.out.println(“当前类名.当前方法”);
“abc”.sout => System.out.println(“abc”);
4.3.3fori : 可生成for循环
类似的:
iter:可生成增强for循环
itar:可生成普通for循环
4.3.4list.for : 可生成集合list的for循环
List list = new ArrayList();
输入: list.for 即可输出
for(String s:list){
}
又如:list.fori 或 list.forr
4.3.5 ifn:可生成 if(xxx = null)
类似的:
inn:可生成 if(xxx != null) 或 xxx.nn 或 xxx.null
4.3.6prsf:可生成 private static final
类似的:
psf:可生成 public static final
psfi:可生成 public static final int
psfs:可生成 public static final String
4.4修改现有模板:Live Templates
如果对于现有的模板,感觉不习惯、不适应的,可以修改:
通过调用out调用println方法不习惯,可以改为跟Eclipse一样,使用syso调取。
4.5自定义模板
IDEA提供了很多现成的Templates。但你也可以根据自己的需要创建新的Template
先定义一个模板的组

选中自定义的模板组,点击”+”来定义模板

- Abbreviation:模板的缩略名称
- Description:模板的描述
- Template text:模板的代码片段
- 应用范围。比如点击Define。选择如下:

可以如上的方式定义个测试方法,然后在java类文件中测试即可。
边栏推荐
- ECCV 2022|通往数据高效的Transformer目标检测器
- How to build an overseas purchasing system/purchasing website - source code analysis
- B站回应“HR 称核心用户都是 Loser”:该面试官去年底已被劝退,会吸取教训加强管理
- Win11怎么禁止软件后台运行?Win11系统禁止应用在后台运行的方法
- Yahoo! Answers-数据集
- In order to counteract the drop in sales and explore the low-end market, Weilai's new brand products are priced as low as 100,000?
- 基于php校园医院门诊管理系统获取(php毕业设计)
- 图像融合DDcGAN学习笔记
- 【精品必知】Pod生命周期
- 新评论接口——京东评论接口
猜你喜欢

链游NFT元宇宙游戏系统开发技术方案及源码

YOLOv5 training data prompts No labels found, with_suffix is used, WARNING: Ignoring corrupted image and/or label appears during yolov5 training

Station B responded that "HR said that core users are all Loser": the interviewer was persuaded to quit at the end of last year and will learn lessons to strengthen management

图像融合DDcGAN学习笔记

An动画基础之元件的影片剪辑效果

shell编程之条件语句

海外代购系统/代购网站怎么搭建——源码解析

基于php家具销售管理系统获取(php毕业设计)

An动画基础之散件动画原理与形状提示点

如何免费获得一个市全年的气象数据?降雨量气温湿度太阳辐射等等数据
随机推荐
SQL分页查询_Sql根据某个字段分页
R语言使用zoo包中的rollapply函数以滚动的方式、窗口移动的方式将指定函数应用于时间序列、计算时间序列的滚动标准差(设置每个窗口不重叠)
从器件物理级提升到电路级
Yahoo! Answers-数据集
Random forest project combat - temperature prediction
B站回应“HR 称核心用户都是 Loser”:该面试官去年底已被劝退,会吸取教训加强管理
欧曼自动挡、银河大马力、行星新产品 欧曼全新产品以燎原之势赢领市场
Image fusion SDDGAN article learning
shell编程之条件语句
(通过页面)阿里云云效上传jar
Kubernetes 网络入门
Using the Work Queue Manager (4)
免费的网络传真平台_发传真不显示发送号码
图像融合DDcGAN学习笔记
php microtime encapsulates the tool class, calculates the running time of the interface (breakpoint)
第十五章 源代码文件 REST API 简介
[Verilog] HDLBits Problem Solution - Circuits/Sequential Logic/Latches and Flip-Flops
Mysql重启后innodb和myisam插入的主键id变化总结
使用 %Status 值
[Verilog] HDLBits Problem Solution - Verification: Writing Testbenches