I just upgraded my work computer to Snow Leopard and one of the benefits I was most excited about was being able to update Textexpander, the incredibly handy snippet tool. You create short codes and when you type them they are replaced with pre-recorded text. They’re much better at describing what it does. It’s really handy for email signatures, canned content for technical support–really anything you ever type more than once.
With the new features Textexpander got really interesting for use in coding on the Force.com platform. The Force.com IDE doesn’t have code completion like the in-line code editor does, and it’s something I look forward to Salesforce.com providing. But in the meantime Textexpander is a great solution for helping you with code you write over and over again.
Textexpander now allows you to put variables in your snippets and allows you to fill those variables as you are expanding the snippet. So, for example, when you’re declaring a List of Accounts, you don’t have to type List twice, and Account twice. It’s really slick.
I’ve created a Snippet Group for common Apex syntax. To use the file, install Textexpander. Right click on the link to the Snippet Group and save to your computer. It’s an XML file, but you need to maintain the .textexpander extension on it. Then open up Textexpander and ‘Add Group from File.’ The group will show up in Textexpander.
Right now this Snippet Group includes:
- declaration of lists, sets, and maps
- declaration of an sObject
- for loops, both kinds
- if statements
- select statements
- test methods
- try catch block
- system.assert statements
- describe result for an sObject
- describe result for a field
It’s just a start, but if you take it and like it, add to it. Let me know and we’ll expand this Snippet Group to be comprehensive. Clearly there should be a VisualForce Sinppet Group as well. If you create one, please let me know!