Written by Michael Bauer, Zowe CLI Squad Lead and Senior Product Owner at Broadcom
Recently, Gene Johnston authored a blog detailing Broadcom’s JCL Language Support extension. This extension provides custom code snippets to allow users to quickly and easily build JCL. We have had users interested in authoring code snippets AND sharing those with others in their organization. If you’d like to learn how easy it is to create and share snippets, you’ve come to the right place!
Creating Custom Code Snippets in VS Code
To create your snippet, navigate to File > Preferences > User Snippets and select your language of choice.
In this case, we selected JCL. You’ll notice that the name of the JSON file created is the same as the language. In this case, we have jcl.json
.
You can follow the instructions in the JSON document to create your snippets for the language. You can also refer to the Create your own snippets section of the VS Code documentation for detailed information. A common snippet that would be customized for a particular site would be the Job Card. Here is an example of a custom Job Card snippet.
Now, if we open a new file, change the language to JCL, and start typing our prefix JobCardCustom
we will be able to select the snippet as shown in this GIF.
The JobCard
snippet that was also shown as a choice was provided by the JCL Language Support Extension.
Sharing Custom Code Snippets in VS Code
Now that we have created our custom code snippets, we want to share them with others within our organization. First, simply find where your snippet file was saved. You can see this in the breadcrumbs shown in some of the images above or by right-clicking on the file name and selecting Reveal in File Explorer
as shown below.
These files are typically stored in:
C:\Users\<user>\AppData\Roaming\Code\User\snippets
Next, you can send this content to your colleagues (perhaps via a shared GitHub repo, network drive, or email). Then they can simply place the file in their snippet directory to benefit from your snippets.
If you are interested in sharing your code snippets with the world by publishing an extension, I would recommend reviewing VS Code’s Snippet Guide. If you’ve never published a VS Code Extension before, this is a good place to get started.
Summary
Creating & sharing code snippets is simple and an excellent way to help ensure folks are following similar conventions. I hope you found this content useful whether sharing code snippets for JCL or any other language.
Learn more:
If you enjoyed this blog check out more Zowe blogs here. Or, ask a question and join the conversation on the Open Mainframe Project Slack Channel #Zowe-dev, #Zowe-user or #Zowe-onboarding. If this is your first time using the OMP slack channel register here.