XMP-Snippets for Visual Studio Code.
Recently, I found myself in the position of needing to create two complete web applications back to back on DNN sites with XMP. Because both time and keystrokes are valuable commodities to coders, I wanted to rely on my code editor of choice – VS Code. Out of that desire was born XMP-Snippets.
XMP-Snippets is a free snippet extension for VS Code. It allows you to quickly scaffold your XMP projects, or to fully code your forms and templates. In addition, I added support so that you can create and edit XMP's .ascx files directly. This has many benefits such as:
- Edit in Code and preview side by side in your browser.
- Better versioning control.
- Ease of backing up your XMP files.
- IntelliSence style snippets – start typing and hit enter.
- Multiple Undos. Even undo past saved points as long as you have not closed the file.
- Tab to placeholders within inserted code to quickly change properties.
- Easier troubleshooting/fixing code errors.
Non Power Users
Non Power Users, (those who want to copy and paste from VS Code to the XMP editor), the snippets are broken down into three categories.
- xt for XMP template controls
- xf for XMP form controls
- fx for Form.X controls
Power Users, If you open any of the .ascx files created with the built-in editor, in a standalone code editor, you will realize that there is more code under the hood than what you normally see in the built-in ecitor. Most of the template controls have runat="server". 3rd party control registration and token processing are also written differently. I have accounted for this with Power User snippets. When working in .ascx files, simply start your snippet with an underscore*.
- _xt for XMP template controls
- _xf for XMP form controls
- _fx for Form.X controls
* WARNING: you should have a solid understanding of working in .ASCX files if you choose to use this method. If you are going to use this method to edit existing XMP forms, templates, or feeds, take precaution and backup your files first!
With some of the included snippet templates, quickly go from a few key strokes to a complete form (in the case below) or template scaffold. From there you can quickly build out the form or template with the individual form and template control snippets.!
How To Get Them
In VS Code under Extensions, search for XMP-Snippets and click on the install button. Alternatively download and install them here: https://marketplace.visualstudio.com/items?itemName=SteveKrantzman.xmp-snippets. If you don't have VS Code and would like to give it a try, you can download it here: https://code.visualstudio.com/
I hope you enjoy using XMod-Snippets, as much as I enjoyed creating them. If you have any ideas to improve XMP-Snippets, send me a message with your suggestions.