Author Topic: Instantiate template in current file  (Read 2949 times)

ryanston

  • New Community Member
  • Posts: 1
  • Hero Points: 0
Instantiate template in current file
« on: March 31, 2009, 12:38:38 AM »
I'd like to have the option of instantiating my 'new class' template in the currently-opened file @ the current cursor location, rather than into a new file.  Can someone direct me on how to do this?

Thanks,
--R

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Instantiate template in current file
« Reply #1 on: March 31, 2009, 05:02:38 PM »
What will (mostly) address your needs is an alias. Aliases aren't quite the same as the whole-file templates, and we've considered unifying the mechanism, but they are still two separate things. But aliases are still a quick way to insert some boilerplate code.

Go to Tools > Options > Languages, expand the language you want to make an alias for, and select the Aliases tab.
There a two types of alias: "plain" and "surround with". If you click the surround with checkbox, you'll see any pre-defined surround-with aliases. These are meant to surround existing code, like do/while loops and try/catch blocks. You'll most likely want a "plain" alias.

I've attached a screenshot of creating a simple alias called myclass. Note on the top of the definition I've created a %(cname) parameter, which I've then added as a parameter in the lower section. When I type myclass in a code file, I'll get a syntax expansion popup. When I select it, I'll be prompted for the replacement value.