Plugin similar to code snippets? [message #132470] |
Fri, 27 January 2006 05:47  |
Eclipse User |
|
|
|
Originally posted by: eclipse.marcfearby.com
I'm new to Eclipse and would like to know if there's a plugin available that
provides similar functionality to the "code snippets" feature in Dreamweaver
whereby commonly-used code blocks can be easily managed and accessed. I
believe that you can set up code templates that complete what you're typing,
but I'm looking for something a little more elaborate that can store larger
blocks of code, such as a bubble sort or database connection stuff to save
having to remember these minutiae.
Thanks :-)
|
|
|
Re: Plugin similar to code snippets? [message #134567 is a reply to message #132470] |
Fri, 03 February 2006 11:20  |
Eclipse User |
|
|
|
Originally posted by: chris.zzzz.com
The template facility is more than just "complete what you're typing"...
You can actually insert arbitrary amounts of code.
Go to Window-->Preferences
Expand Java-->Editor-->Templates
Click New
In the Name field, type a name, let's call it sopn
In the Pattern field, paste the following line:
System.out.println("${enclosing_type} ${enclosing_method}() ${cursor}");
Type a carrier return at the end of the line and Click OK to save the new
template. You will now see sopn in the alphabetical list and at a later
time if you need to, you can edit it from there.
Click OK to dismiss the preferences dialog.
Go to a java source window and insert a new line somewhere inside a method,
and type sopn and the press CTRL-Space.
You will see the expansion, and the classname and method name are
automtically entered for you, and the cursor is conveniently placed where
you'd want to type in the unique message.
The pattern you enter into the template can be more or less as much code as
you need. I agree, I doubt wheteher it would be a good idea to put
thousands of lines of code in there
|
|
|
Powered by
FUDForum. Page generated in 0.05469 seconds