[ajug-members] Eclipse 'snippets' plugin = ?
Jason Vinson
vinson.lists at charter.net
Thu Aug 3 11:37:45 EDT 2006
Just as a follow up (from my old blog):
http://jroller.com/page/vinsonizer?entry=adding_code_templates_to_eclipse
Jason
-----Original Message-----
From: ajug-members-bounces at ajug.org [mailto:ajug-members-bounces at ajug.org]
On Behalf Of James Mitchell
Sent: Thursday, August 03, 2006 11:30 AM
To: General AJUG membership forum ((100-200 messages/month))
Subject: Re: [ajug-members] Eclipse 'snippets' plugin = ?
POE (Plain ole Eclipse) has snippets, which I use all the time when
writing stuff in a JSP. I mean, who wants to retype JSF or Struts
tags all the time....(in unison) "old school".
However, what you describe sounds like templates. As Jason
mentioned, with templates you can customize existing templates or
create your own. For example, say I want to add a log variable to
the class I'm working in and being the lazy-a## that I am, I do not
want to type this repeatedly for every class I was creating. So I
type what I want to see:
private static final Log log = LogFactory.getLog(SomeClass.class);
..., then copy it and go to the templates preferences section (Window-
>Preferences). Then I create a new template and name it 'psfl' for
public static final...ok, you get the point.
Then I hightlight the part I want to be specific to the file I'm in,
and delete it, then click "Insert Variable". Simple enough there are
many variables to choose from, so its rtfm for the one's that seem
confusing. The one I need will be the class name, so I picked
"enclosing_type".
private static final Log log = LogFactory.getLog($
{enclosing_type}.class);
And so now, typing psfl<ctrl+space> brings up the code completion
list, and my template is the first one listed, and hitting enter
creates that line:
public class ReallyCoolClassByJames {
private static final Log log = LogFactory.getLog
(ReallyCoolClassByJames.class);
// try it for youself, type 'main<ctrl+space>' ... you like?
}
Given the simple example above, you can get pretty creative with these.
--
James Mitchell
678.910.8017
On Aug 3, 2006, at 9:54 AM, Howard Kapustein wrote:
> No. 'Snippets' as in, a predefined block of code in a list of such
> things, you can drag onto the an edit window and it'll, ultimately,
> paste in text.
>
>
>
> Download Exadel's freebie (non-Pro) and take a peek. MyEclipse has
> a similar thing.
>
> The variable-substitution part is the plus. Straight text
> drag'n'drop isn't as interesting.
>
>
>
>
>
>
>
> From: ajug-members-bounces at ajug.org [mailto:ajug-members-
> bounces at ajug.org] On Behalf Of Jason Vinson
> Sent: Thursday, August 03, 2006 8:53 AM
> To: 'General AJUG membership forum (100-200 messages/month)'
> Subject: RE: [ajug-members] Eclipse 'snippets' plugin = ?
>
>
>
> Do you mean code templates? An example being "instanceof" in
> eclipse, where it expands a template that you can tab through and
> fill out the proper values.
>
>
>
> Jason
>
>
>
> From: ajug-members-bounces at ajug.org [mailto:ajug-members-
> bounces at ajug.org] On Behalf Of Howard Kapustein
> Sent: Thursday, August 03, 2006 8:47 AM
> To: General AJUG membership forum (100-200 messages/month)
> Subject: [ajug-members] Eclipse 'snippets' plugin = ?
>
>
>
> MyEclipse has one. Exadel has one. But if I'm not using either
> framework, I can't seem to find one that works.
>
> MyEclipse + Exadel both have the notion of 'variables', i.e. when a
> snippet is dropped into the editor, a dialog with prompts for
> substitution values can be displayed for user input, before text
> insertion.
>
> Does anyone know of a snippet plugin for Eclipse (3.1) that doesn't
> require MyEclipse or Exadel?
>
> - Howard
>
> "Your training is nothing! The will is everything! The will to act."
>
> _______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
_______________________________________________
ajug-members mailing list
ajug-members at ajug.org
http://www.ajug.org/mailman/listinfo/ajug-members
More information about the ajug-members
mailing list