views:

124

answers:

1

I have this code:

myVariable

which I want to change into

trace("myVariable: " + myVariable);

using a direct hotkey like "alt-f12" to do it. I.e not using "ctrl-space" and arrow buttons.

is it possible in eclipse?

+3  A: 

I don't know if it's possible to bind hotkeys for templates. One way for somewhat similar behavior could be using proper template name and "insert automatically"..

That is, you would write trcc (for example) and Eclipse would automatically expand it to a template trace("${name}: " + ${name}); (and you would end up editing the name). The drawback is that you should choose such a name that you won't use it otherwise in the code. (So if you would end up writing trcc for other things, you should choose another name)

Regarding to the templates, one blog entry on them. (Note the ${enclosing_type} and ${enclosing_method} if you're not familiar with them already)

Touko