键绑定键插入自定义代码Eclipse [英] Keybinding keys to insert custom code Eclipse

查看:136
本文介绍了键绑定键插入自定义代码Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

线与时间测量。

像这样:

1:

CODE
CODE
CODE

2 :选择三行,然后按CTRL + SHIFT + T

2: Select three lines and press CTRL+SHIFT+T

3:

long startTime = System.currentTimeMillis();
CODE
CODE
CODE
Print.pln("Time taken: " + (System.currentTimeMillis() - startTime) + "ms");


推荐答案

您可以通过使用模板来实现这一点,例如:

You can achieve this by using a template, for example:

long ${newName} = System.currentTimeMillis();
${line_selection}
Print.pln("Time taken: " + (System.currentTimeMillis() - ${newName}) + "ms");

您可以在首选项 - > Java->编辑器 - >模板下添加。在这里,你必须给它一个名字,例如定时器

You can add this under Preferences->Java->Editor->Templates. Here you will have to give it a name, e.g. timer.

要使用它,请选择代码按CNTRL + SPACE两次,然后选择计时器(或您给模板的任何名称)。

To use it, select the code press CNTRL+SPACE twice, then select timer (or whatever name you gave to the template).

请注意,这将生成时间变量的名称。

Note that this will generate a name for the time variable.

这篇关于键绑定键插入自定义代码Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆