Eclipse中文件编辑时常用的几个快捷键和输入模板

最近比较关注如何提高自己的工作效率,比如Launchy的使用。Eclipse作为最常用的IDE,掌握一些常用的快捷键和输入模板,会很大的提高工作效率

常用快捷键

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}
}

全部的快捷键和模板见Eclipse的帮助文件,当然你也可以根据自己的习惯定义自己的快捷键和模板

整理完了以后才发现以前浪费了多少时间啊,浪费可耻!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值