views:

146

answers:

1

One particular problem I was having was using ${word_selection} in an Eclipse PDT template.

I was recently trying to use some code templates with Eclipse PDT 2.1 to speed up some common tasks. We use a lot of getters/setters, so I wrote the following template.

function get${word_selection}() {
return $$this->getData('${word_selection}');
}

function set${word_selection}($$${word_selection}) {
$$this->setData('${word_selection}', $$${word_selection});
}

I named the template "getset" and the only way I know to use the Code Assist is to type: "getset" then hit my code assist keys (I have it set to Esc, but I think the default was Ctrl+Space). The problem is, this doesn't actually let me select a word to be used by the ${word_selection}.

how do I type in my template name, hit the key combo, and have a word selected all at the same time?

I also want to know what kinds of templates people have set up and any other tips for using templates to speed of programming.

+1  A: 

Look at this link : http://2tbsp.com/node/104 It describes two things : pdt code templates and code snippets.

how do I type in my template name, hit the key combo, and have a word selected all at the same time?

I think this cannot be achieved with code templates, but with code snippets. Personnally I do not use them at all, but I might start :-)

greg0ire