java快捷键

常用快捷键
Shift+Enter:在当前行下插入新行,当光标正在一行的中间时才体现其价值

Ctrl+Shift+Enter:在当前行上插入新行

Ctrl+D:删除整行

Ctrl+Alt+J:合并行,相当于vi中的J

Ctrl+Alt+UP/DOWN:向上/下复制行

Alt+UP/DOWN:行向上/下移动

F2:显示Tip

Ctrl+Shift+F:Format,对文档进行格式整理

Ctrl+Alt+/:word自动完成

Ctrl+1:快速解决(quick fix)

Alt+/:内容帮助(Content Assist),用于激活输入模板等

输入模板(Java)
使用方式:输入模板的名字,然后使用Alt+/快捷键

cast:

${type} ${new_name} = (${type}) ${name};

catch:

catch (${Exception} ${exception_variable_name}) {
${cursor}// ${todo}: handle exception
}

do:

do {
${line_selection}${cursor}
} while (${condition:var(boolean)});

else:

else {
${cursor}
}

elseif:

else if (${condition:var(boolean)}) {
${cursor}
}

for:

for (int ${index} = 0; ${index} < ${array}.length; ${index}++) {
${line_selection}${cursor}
}

foreach:

for (${iterable_type} ${iterable_element} : ${iterable}) {
${cursor}
}

if:

if (${condition:var(boolean)}) {
${line_selection}${cursor}
}

instanceof:

if (${name:var} instanceof ${type}) {
${type} ${new_name} = (${type})${name};
${cursor}
}

main:

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

new:

${type} ${name} = new ${type}(${arguments});

private_method:

private ${return_type} ${name}(${}) {
${cursor}
}

private_static_method:

private static ${return_type} ${name}(${}) {
${cursor}
}

protected_method:

protected ${return_type} ${name}(${}) {
${cursor}
}

public_method:

public ${return_type} ${name}(${}) {
${cursor}
}

runnable:

new Runnable() {
public void run() {
${line_selection}
}
}

static_final:

${visibility:link(public,protected,private)} static final ${type:link(String,int)} ${NAME};

switch:

switch (${key}) {
case ${value}:
${cursor}
break;

default:
break;
}

synchronized:

synchronized (${mutex:var}) {
${line_selection}
}

syserr:

System.err.println(${word_selection}${});${cursor}


sysout:

System.out.println(${word_selection}${});${cursor}

systrace:

System.out.println("${enclosing_type}.${enclosing_method}()");

test:

public void test${name}() throws Exception {
${cursor}
}

toarray:

(${type:elemType(collection)}[]) ${collection}.toArray(new ${type}[${collection}.size()])

try:

try {
${line_selection}${cursor}
} catch (${Exception} ${exception_variable_name}) {
// ${todo}: handle exception
}

while:

while (${en:var(java.util.Enumeration)}.hasMoreElements()) {
${type:argType(en)} ${elem:newName(type)} = (${type}) ${en}.nextElement();
${cursor}
}

原文地址:https://www.cnblogs.com/ldphoebe/p/4969824.html