The VS Code Way
How would you create snippets without this extension?
Great job creating your first snippet in the previous tutorial! Now that you know how, you can skip this page and never consider working with snippets without the help of the extension.
Wait, you really want to see how to do it without the extension?
Without the help of SnippetStudio
FINE! You don't want help? Do it the way Microsoft intended.
- Click the in the bottom left corner of VS Code
- Click
Snippets
- Choose a language. If you pick a new language you don't have snippets for, it will give you helpful comments.
- Create a new JSON object that contains at least
prefix
andbody
properties. - Expand the
body
array and code inside as if each line of code is a string of the array. - Go to a file of that language and see if you can type the prefix and expand the snippet.
If it worked you're good to go! If not, maybe ask AI?
Was that painful? Yeah. IDEs like XCode and JetBrains help you quite a bit. I don't know who decided it is a good idea to ask developers to manually code in a json file and stringify each line of code, but that's the way you'd have to do it without an extension.
Problems with the 'VS Code way'
- You can't easily create a snippet from existing code.
- Any programming language's LSP (autocomplete, word coloring, error detection, etc) can't help you in a json file.
- It's more difficult to open the snippet files every time you need edit a snippet.
- SnippetStudio also adds tooling for adding snippet insertion features too.
If you found your experience was much better using the extension, consider giving the SnippetStudio GitHub a star or leave a rating at the marketplace.