Snippets How-To
What is a Snippet?
Snippets are little piece of code which are used many times in different projects. The snippets panel will help you to mmage this library (snippets are at least a code library).
How to Use in SEPY?
First you must open the Snippt panel from the panels list.
If you never use this panel you must first set a snippet base directory. This must be a valid directory on your hard disk, where all the snippets will be saved an managed by SEPY.
It is recomended to use a new empty directory for this. (Note that also after deleting a snippet, the file won’t be deleted, but only hidden from the panel and renamed from the filsystem).
Create a Snippet
From the contextual menu you can now manage the snippets panel adding folders and snippets.
Create a new snippet, chose a snippet name and then write into the just created file your snippet code. You can write anything you want in the snippet file (next time you will insert this snippet in a opened file all the code you wrote here will be inserted completely).
There also magic words which can be used in a snippet and they are:
@@variableName@@
This is, any word which start with a double “@@” and ends with a double “@@” is recognized as variable.
Next time you will use the snippet, sepy will ask you with which value you want to replace this variable. So, all the occurrences of @@variableName@@ will be replaced with this new value.
@@variableName=[defaultValue]@@
This is another way to specify a variable.
but in this way you also set a default value, which will be displayed by default in the snippet dialog when you want to insert the snippet.
This is a sample snippet:
var gatewayUrl:String = "@@gatewayUrl=[http://localhost/flashservices/gateway]@@";
NetServices.setDefaultGatewayUrl(gatewayUrl);
var conn = NetServices.createGatewayConnection();
var serv = conn.getService("@@serviceName@@", @@responder=[this]@@);
Which will produce this dialog when you’re going to insert the snippet:

Note
This dialog will appear only if you have set at least one variable in the snippet. For every variable set the value you want to assign, then press “Ok” and all the new code will be inserted in the current document
December 12th, 2005 at 7:54 am
Nice feature !
Would it be possible to have a way to define where the cursor is going to be after the snippet has been placed in the document?
December 12th, 2005 at 9:54 am
hi, how can I use a snippet and include the selection like the homesite snippets ?
is there any syntax like: trace(“info trace = “+@@responder=[mySelection]@@
?
December 14th, 2005 at 4:47 pm
Request: can we set a shortcut key to a snippet?
December 16th, 2005 at 10:37 am
Awesome. Can you also set it so you can hit tab to go to the next variable in the variable list. It would make it a lot quicker to add a snippet.
February 2nd, 2006 at 6:30 am
When i add snipplet, the UTF BOM is added also.
Can i avoid it without turning off Write UTF BOM option in Preferences?
February 9th, 2006 at 8:46 am
>>Request: can we set a shortcut key to a snippet?
I second that.
February 18th, 2006 at 10:00 pm
Very nice indeed! In another IDE I use (JCreator), you type the name of the snippet (purposefully give the snippets abbreviated names) and press [TAB] to automatically insert the full snippet. That would be a VERY cool addition to these snippets.
It would also be nice to have some sort of %%TAB%% function that would automatically indent any line that contained this string to the indent level where the cursor was at at the time of the snippet insert. For example, if I wanted to automatically insert a for loop block and have it automatically placed at the appropriate indent level.
Lastly, it would be nice to have a %%DATE%% and %%TIME%% function that could get parsed also.
Very cool tool, thank you for your hard work!
March 18th, 2006 at 1:15 am
Awesome, I can’t get enough of the snippets!!!! I LOVE some of the requested features like the cursor insertion point, hitting tab (or some other button) after typing the name, auto-indenting (they get a little messed up whilst inserting them inside functions).
Keep up the awesome work and thanks so much, been using SEPY since the beginning!
March 29th, 2006 at 1:55 pm
I don’t think request are noticed on this form, there is a feature request and Sepy is great at adding them in. You can find it at: http://sourceforge.net/tracker/?group_id=90749&atid=594692
June 17th, 2006 at 1:50 am
If I insert snippet, than is also this symbol insterted |ยป|
Can I disable it or must I delete it every time after snippet insert?
Thanks