Yesterday I managed to add snippets support to SubEthaEdit by using AppleScript, PHP and XML. I'm planning on making this available to everybody who wants it but I need to do some refactoring before a release is possible. PHP is not the best language to use + I'm using DOMDocument to parse the snippet storage file. DOMDocument is not apart of the standard PHP installation on OS X Snow Leopard.
Yeah I know, there are snippet apps out there that store snippets and what not but the problem is that when pasting them into SubEthaEdit the indentation gets all screwy. I managed to work around this by returning "perfectly" formatted source when calling a tabbed trigger.
As mentioned above you store the snippets in XML-files. The script is dependent on which Mode your are currently using, for example: if you are using PHP-HTML the script parses PHP-HTML.xml.
This is an extract from PHP-HTML.xml
<completion string="if">
<snippet>if (@:statement) {
} </snippet>
</completion>String is the tab-trigger (in this case 'if').
@: is the placeholder to where the cursor should go after execution and statement is in this case a dummy text (dummy text gets selected if it is connected to the placeholder).
At this time it is only possible to use one placeholder per snippet, you could add more if you wanted to but it would only work "auto-magically" with the first occurring placeholder.
I'm gonna look into this more in the future but for now I'm gonna focus on the refactoring.
I have some other plans as well but I'll tell you more about them later !
Sidenote
I would like to thank
pkrll for all his moral support!
Comments
The pkrll that was mentioned (unauthenticated)
Jan 27, 2010
Oh, exiciting.