save code snippets in visual studio code example
Example 1: how to make snippets vscode
Hit > shift + command + p and type snippets
Select Preferences: Open User Snippets
Choose the language type for which you want to add the custom snippet
vscode has comments to explain on how to add a snippet, as described on :> vsdoc
Lets say, we want to open custom snippets for the language GO. Then we can do:
Hit > command + p
Type: go.json + enter And you land on the custom snippet page
Snippets are defined in a JSON format and stored in a per user (languageId).json file. For example, Markdown snippets go in a markdown.json file.
Update new tools:
Snippet generator site: https://snippet-generator.app/
Example 2: visual studio save snippet
Save below as <name>.snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Snippet Name</Title>
</Header>
<Snippet>
<Code Language="CSharp">
<![CDATA[YOUR SNIPPET CODE GOES HERE]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Finally, import in VS: Tools > Code Snippets Manager > Add
Now you can insert via right-clicking at the appropriate location: Snippet > Insert Snippet