原文引自:https://blog.csdn.net/sisixiaocainiao/article/details/104238085
C语言版
点击工具->代码片段管理器
语言选择Visual C++ ->以class为模板-> 复制位置路径
进入文件资源管理器,将class文件复制到本路径下。
对复制后的文件右键–属性–安全–编辑–选择Users,勾选完全控制–确定–确定
改名#1或#2..snippet
以记事本方式打开 ->修改
修改前:
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>#1</Title> <Shortcut>#1</Shortcut> <Description>main</Description> <Author>Microsoft Corporation</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> <SnippetType>SurroundsWith</SnippetType> </SnippetTypes> </Header> <Snippet> <Code Language="c"><![CDATA[#define_CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { system("pause"); return 0; } ]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
修改后:
#1
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>#1</Title> <Shortcut>#1</Shortcut> <Description>main</Description> <Author>Microsoft Corporation</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> <SnippetType>SurroundsWith</SnippetType> </SnippetTypes> </Header> <Snippet> <Code Language="c"><![CDATA[#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { system("pause"); return 0; } ]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
#2
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>#2</Title> <Shortcut>#2</Shortcut> <Description>main</Description> <Author>Microsoft Corporation</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> <SnippetType>SurroundsWith</SnippetType> </SnippetTypes> </Header> <Snippet> <Code Language="c"><![CDATA[#define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; int main() { system("Pause"); return 0; } ]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
保存后,重启VS,键入#1或#2;