Community
Participate
Working Groups
From Eclipse Corner: Code templates Great IDE! One thing I miss though: code templates. I would like to have user defined shortcuts to generate statements like: for (int i=0; i<[vector].size(); i++) { Object item = [vector].get(i); } where [vector] would be replaced by a user supplied name. NOTES: CM (8/23/2001 3:57:39 PM) Further info on feature: > It would be useful if you could supply more info: > - where have you used these before : JBuilder > - how did you invoke them - specific shortcut key? user-specified shortcut > key[s]? : shortcut (possible user-defined) > - i.e. did the U/I provide a list of them for you when you invoked it, or > could you invoke each one with some separate key sequence? : you could start typing the template, then hit one special key for templates and see the list of available templates. Please: NO separate keys for different templates! > - are they just a macro? : ? > - did you name them? : yes. > - did you fill in the parameter (i.e. [vector]) (in a dialog, perhaps?) when > you invoked the template, or did the U/I place the cursor for you to type it > in? "U/I place the cursor for you to type it in" right after the template has been injected in your code.
We're getting there. Templates as of now support arguments to avoid typing the same name multiple times. Argument variables are named ${0}, ${1} etc. The corresponding template would be Name: itvec Context: java Description: iterate over vector Pattern: for (int i=0; i<${0}.size(i); i++) { Object item= ${0}.get(i); } and could be called by: itvec(myVector)<CTRL-SPACE>
implemented > 204 If there are unresolved variables, a popup editor allows to enter the missing variable names.
PRODUCT VERSION: R0.9