Great: Templates! But how...?

2003-10-27
2003-10-29
  • Markus Dreyer

    Markus Dreyer - 2003-10-27

    Great, now there is "Basic templating support"!

    But, how can I use templates? I created a template in Window -> Preferences -> Perl -> Templates

    But the template is never instantiated! When I create a new Perl file in my project, I am not asked which template I want to use. I have not found any hints how to use the template that I created.

    I upgraded to Eclipse 3.0, but there is no difference regarding the Perl templates.

    Any hints?

    M.

     
    • Jochen Ruehl

      Jochen Ruehl - 2003-10-28

      Hi,

      define a template. When editing a file type some characters of the template name and press CTRL+SPACE. If there is only one template with the given name the auto-completion  will insert the template.
      If there are more than one template with the given name a list of available matching templates will be displayed.

      Bye
      Jochen

       
    • Markus Dreyer

      Markus Dreyer - 2003-10-28

      Oh, I see. This is a different concept than I am used to from the Java Perspective. But it's good!

      One thing: It would be nice if one could specify where the cursor will be after the template is inserted.

      if you define a template for a command, like a hash loop (dollar sign is doubled in template editing):

      foreach my $$elem ( %hash ){
          print $$elem;
      }

      The cursor should jump to "hash" after the template is inserted. And the word "hash" should even be marked, so that you can overtype it with the hash name you need.

      Is this related to the "cursor" variable that you can insert when you edit a template (but it is empty)?

      Keep the good work!
      M.

       
    • Jochen Ruehl

      Jochen Ruehl - 2003-10-28

      Hi,

      try this one that should do what you want:
      foreach my $$${elem} ( %${hash} ){
          print $$${elem};
      }

      Bye
      Jochen

       
      • Markus Dreyer

        Markus Dreyer - 2003-10-28

        Cool! If I change the first "elem" the second elem changes at the same time.

        You should definitely document that somewhere so that people can use it and come up with good template files (which you could distribute on this page...). How about a general document paragraph about the templates?

        These are just suggestions because I am really excited about the epic project!

        M.

         
        • Ben Imp

          Ben Imp - 2003-10-29

          The cursor variable controls where your cursor ends up after the template is finished - so just insert that wherever you feel it fits.

          Ex: This is my do-while template

          do{
            ${cursor}
          }while(  );

          And, speaking of templates - if you go into Window->Preferences->Java->Editor->Templates, you will see that the java concept of templates in Eclipse is the exact same - just a little better hidden. :)

           

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks