• 常用Live Templates

模板

说明

sout
System.out.println($END$);
soutv
System.out.println("$EXPR_COPY$ = " + $EXPR$);

main

psvm

public static void main(String[] args){
  $END$
}

说明: 对于普通模板输入后,回车/tab键即可;对于环绕的模板,选中代码,再使用快捷键: ctrl+Alt+J,再选择对应的模板.

位置:

  1. 快捷键:Ctrl + Shift + A,打开搜索框;输入“live templates”IntelliJ IDEA使用技巧--Live Templates 及Postfix
  2. 模板界面,可以查看预定义模板及进行自定义模板IntelliJ IDEA使用技巧--Live Templates 及Postfix
  3. 预定义模板IntelliJ IDEA使用技巧--Live Templates 及Postfix
  4. IntelliJ IDEA使用技巧--Live Templates 及Postfix
  5. 自定义模板,根据各自需要进行定义使用.

  • 常用Postfix

postfix 说明
var Introduces variable for expression.定义变量

try

Insert statement in try-catch block.
soutv Creates System.out.println with a description of printed value call.
sout Creates System.out.println call.
return Returns value from containing method.

for

iter

Iterates over enumerable collection.
fori Iterates with index over collection.
if Checks boolean expression to be 'true'.
lambda Surrounds expression with lambda.
opt Creates Optional object.
while Iterating while boolean statement is 'true'.
switch Produces switch over integral/enum/string values.
synchronized Produces synchronization statement.

 

说明: 对应的方法/参数后.postfix回车,即可.如: m().try --->

try {
    m();
  } catch(CheckedException e) {
    e.printStackTrace();
  }

位置:

IntelliJ IDEA使用技巧--Live Templates 及Postfix

IntelliJ IDEA使用技巧--Live Templates 及Postfix

相关文章: