问题
Given this code snippet, how can I change the default code provided in this snippet, in Visual Studio 2017?
回答1:
Visual Studio 2010 -> Tools -> Code Snippet Manager
Change if needed the programming language and look ah the path of the snippet files. Close and create in VS17 a new xml file for a new snippet file. Save this as a Codesnippetfile with "Save File as" . Go to the Folder of the existing snippetfiles and copy the needed part.
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title> </Title>
<Description> </Description>
<Author> </Author>
<Shortcut> </Shortcut>
<SnippetTypes>
<SnippetType> </SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language=" ">
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Fill the rest and save the codesnippet file. Go back to the Code Snippet Manager and import your new custom file snippet file. Otherwise you can edit a existing snippet file and change on this way the automatic insertet code.
For detailed instructions. https://www.telerik.com/blogs/visual-studio-tip-creating-your-own-code-snippets
来源:https://stackoverflow.com/questions/48573878/how-to-change-the-a-default-code-snippet-in-visual-studio-2017