Hi,
I know that this might be very scary for some people. But I recognized that not many developers work with snippets. To be honest I was one of them. I thought it is much faster to copy and paste the needed stuff from other files. Well, maybe it is faster but that's not the point.
Since my tries with Komodo Edit I used abbreviations for the first time. It's a very handy tool if you write the same things over and over again in many files. (And bigger extensions have a lot of files in the most cases.) You just enter your code and put some placeholders here and there and than you can use it with a keyword and key combination. Can be useful for any kind of code you use more than one time week.
In my Komodo Edit post I wrote, that I will stay with Eclipse as my editor. Because Eclipse is such a big product it supports templates too of course. It took my some minutes and a chat with Robert (who really impressed me with the templates in his presentations! ;-) ) to figure out how you can use this feature on OS X.
As you can see on the first screenshot you have to go to Eclipse preferences to the page "keys" und "General". In the list of key bindings search for "Content Assist" and than change the key binding as you like. In my case I had to change it because other programs registered for that combination already.
When did that you can define some templates. I assume that you have PDT installed! Go to page PHP -> Templates and create a new template. Now you write your PHP code as usual. You can add some placeholders in the form ${nameOfPlaceholder}. The clue with that placeholders is, that you can use them several times in the same template. When you fill the first placeholder with data all others with the same name will be substituted automatically.
There are some predefined placeholders like ${year} that prints the current year without the need to type it yourself. After all I really like this feature and I'm sure I'll use it much more in the future.
By the way, you can export your set of templates and share them with others. A set of FLOW3 templates are available here.
I also made a short demo video how a template could be used:
Greets,
Thomas
#2: Thomas Hempel commented on Friday, 13-06-08 16:03
I'm not sure if it's worth the download for getting two small templates. ;-) But maybe one can create a forge rep for this. ;-)
Greets,
Thomas
#3: Roy Ganor commented on Friday, 13-06-08 21:54
Looks like a very usefull information for all Eclipse and PDT users!
do you mind to add it as a tutorial to the following wiki page:
http://wiki.eclipse.org/PDT/TUTORIALS
#4: Thomas commented on Friday, 13-06-08 22:36
Hi Roy,
thanks for adding the link! :-)
Greets,
Thomas
#5: Semseo commented on Thursday, 19-06-08 01:25
thanks for the very usefull information for all Eclipse and PDT users!
#9: Tworzenie stron commented on Monday, 28-07-08 19:37
Oh, it's good advice. Your article is very helpfull. Thanks
#10: Mateus commented on Monday, 15-09-08 17:58
Hello, how i configure specified ${nameOfPlaceholder} ? Thanks for help.
#11: neochung commented on Sunday, 28-09-08 06:14
As you mentioned above, " it is much faster to copy and paste the needed stuff from other files."
This really helps for Big project management.
thanks a lot.
#12: Firma commented on Thursday, 27-11-08 20:49
Could anybody tell me where I can get more about setting Smarty with Eclipse ?
#1: Ingo commented on Friday, 13-06-08 15:21
Do you want to share your templates maybe? =)