Snippets
Customizable shortcuts inspired by VS Code Snippets for Roblox Studio
Plugin | Demo | User Guide (soon)
(Plugin contains some documentation out of the box.)
Features
- Easy to use snippet editor
- Built-in example templates with instructions
- DockWidget UI
- Simplistic user interface
- Lookbehinds/Lookaheads for arguments passed to the snippet
- Whitespace preservation for snippets in the middle of code blocks
FAQ
Click to view FAQ
Can I make arguments to snippets optional?
Unfortunately, it is currently not possible to make optional arguments with user defined snippets. It is possible to do internally, but unless you know what you are doing I do not recommend trying to implement it yourself. The internals do not have as much documentation.Why does my cursor position get reset when I input a snippet?
Due to the limitations of Roblox Studio, there is no way for a plugin to set the position of the cursor in the script editor. We would love to make the cursor position properly but it is not possible at the moment.Can I edit the default snippets?
For the most part, yes! The only exception to this rule is you cannot edit special snippets like eval or go because they are implemented differently internally.Can I disable the use of snippets in my script?
Indeed you can. If you wish to disable all snippets for any specific script, just add an attribute named "snippetLocked" to the script and set the value to anything that isnt falsey.Why Snippets?
While I was researching other implementations of similar modules, I came across this plugin by A1rfoil. To be clear, I think the plugin is good but it has some pretty obvious issues which are solved by Snippets.
The worst issue with that plugin in my opinion is the lack of arguments to the snippet code. It supports basic syntax for things like the time but its not flexible enough to be very useful and as far as I’m aware there is no way to define your own replacements.
Snippets completely solves this issue with the use of Lookaheads and Lookbehinds. Your snippet can take any number of arguments and you can use them anywhere in the snippet via $kn
where n is the index of the argument. This allows for some pretty interesting templates like the included class template. The only limitation is that you cannot make optional arguments.
Snippets also implements some non standard snippets that don’t follow the simplistic find → replace idea behind the rest. They have much more utility. They aren’t user creatable (mainly because it would be a pain to serialize user functions + limitations with upvalues) but as a result, they are much higher level. As an example, if I use the snippet:
--(this just uses loadstring internally so you can put any valid lua code here)
--@eval {2 + 2}
It would actually output 4 to the console.
While the utility snippets aren’t exactly the most useful things all the time I think they are pretty fun and can speed up how fast you navigate Studio.
Credits
- Honorable Mentions
- @cowsoncows Didn’t Contribute But I Like His Name
- @kisty1 “My name’s Deez”
- @Raccoonyz “dont add my devforum username”
- @Jiramide Spelunky 2 Caveman Enthusiast