PrimalScript: Did you know about Snippets?

I’d like to think that Primalscript’s Snippets feature is one of its more well known features, but I think I take it for granted. Primalscript ships with a large number of language specific snippets that you can freely incorporate into your work. Depending on your configuration, you may or may not see the Snippets browser panel on the left side of the IDE.  If you can’t find it, go to View – Browser Panels and select Snippets Browser.

Navigate in the tree to the language you are working in.  Find a snippet you want and either drag and drop it into your script or double-click it. If you know the snippet name you can add it with Ctrl-J. For example, suppose you are writing a PowerShell script and want to insert an If Else construct. In your PowerShell file (which must have a .ps1 extension) type ifelse  followed immediately by Ctrl-J and the code snippet will be inserted. With a little practice you can create a script prototype in an incredibly short period of time using code snippets.

Finally, if you have some snippet of code that you use more than once, you should never have to rewrite it.  Highlight the code block, right-click and use SaveAs Snippet. Primalscript will detect the appropriate language. Provide a name and then you’ll be able to re-use that snippet by typing its name and Ctrl-J.