Https://www.cnblogs.com/awaTangjay/p/6644952.html
1. Open vs2012--Tool--code Snippet Manager
2. After entering code manager, select Visual C #, then copy the address in the Location box
3, open My Computer, in the address bar paste the above copied address press ENTER will jump to the directory we are going to
4, in this directory randomly copy a code snippet file (here I copy the Cw.snippet file)
5, the purpose of the above copy of the code snippet file is to be modified to encapsulate their own code snippet (here I pasted to the desktop, the code snippet file name to my own to encapsulate the code snippet name)
6. Open the Mc.sinppet file with Notepad, as shown below
<?xml version= "1.0" encoding= "Utf-8"? ><codesnippets xmlns= "http://schemas.microsoft.com/VisualStudio/ 2005/codesnippet "> <codesnippet format=" 1.0.0 "> <Header> <Title>cw</Title> Code Snippets for <Shortcut>cw</Shortcut> <description>console.writeline </Description> <author>microsoft corporation</author> <SnippetTypes> <snippettyp e>expansion</snippettype> </SnippetTypes> </Header> <Snippet> <Declarations> <literal editable= "false" > <id>systemconsole</id& Gt <function>simpletypename (global::system.console) </Function> </Literal> </de clarations> <code language= "CSharp" ><! [cdata[$SystemConsole $. WriteLine ($end $);] > </Code> </Snippet> </CodeSnippet></CodeSnippets>
7. I'm now trying to encapsulate this code snippet
public class MYCALSS {public mycalss () { } }
8. Modify the Mc.sinppet file now
<?xml version= "1.0" encoding= "Utf-8"? ><codesnippets xmlns= "http://schemas.microsoft.com/VisualStudio/ 2005/codesnippet "> <codesnippet format=" 1.0.0 "> <Header> <title>mc</title > <Shortcut>mc</Shortcut> <description>myclass Code Snippets </Description> < author>myname</author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> </ declarations> <code language= "CSharp" ><![ Cdata[public class MYCALSS {public mycalss () { } } $end $]]> </Code> </Snippet> </CodeSnippet></CodeSnippets>
Modify the contents of the title,shortcut,description tag to its own name.
$end $ This code means where the cursor appears, set in the last position of the code snippet.
Put the code snippet you want to encapsulate in cdata[] and save it after you've changed it.
9. The Mc.sinppet file needs to be imported into vs to take effect when it is modified. The import is below. Into the code Snippet manager, click the Import button, an open file dialog will pop up, select the Mc.sinppet file, click Open, then click Finish.
10, to this step of their own code snippet is encapsulated, you can make a quick call. You can quickly call out the encapsulated code snippet by typing the MC and then pressing the TAB key twice.
public class MYCALSS {public mycalss () { } }
Category: C #, Miscellaneous
Visual Studio Creates a code snippet that encapsulates itself (C #)