【问题标题】:Keybinding keys to insert custom code Eclipse用于插入自定义代码 Eclipse 的键绑定键
【发布时间】:2012-07-17 08:33:16
【问题描述】:

我将如何设置键绑定,所以当我在 eclipse 中按下例如 Ctrl+Shift+T 时,它会包围所选线与时间测量器。

像这样:

1:

CODE
CODE
CODE

2:选择三行并按CTRL+SHIFT+T

3:

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

【问题讨论】:

    标签: java eclipse time macros key-bindings


    【解决方案1】:

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

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

    您可以在 Preferences->Java->Editor->Templates 下添加它。在这里你必须给它一个名字,例如计时器。

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

    请注意,这将为时间变量生成一个名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-16
      • 2019-11-16
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      • 2011-08-03
      相关资源
      最近更新 更多