vs2015添加.snippet文件,实现快速模板生成
依次找到 工具---->代码片段管理器---->语言选择(自己的开发语言)---->点击导入.snippet文件
//文件一
#1.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>c语言main函数</Description> <Author>Microsoft Corporation</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> <SnippetType>SurroundsWith</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>expression</ID> <ToolTip>要计算的表达式</ToolTip> <Default>true</Default> </Literal> </Declarations> <Code Language="cpp"><![CDATA[#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<time.h> int main() { $selected$$end$ system("pause"); return EXIT_SUCCESS; } ]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
//文件二
#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>#2</Title> <Shortcut>#2</Shortcut> <Description>c++语言main函数</Description> <Author>Microsoft Corporation</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> <SnippetType>SurroundsWith</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>expression</ID> <ToolTip>要计算的表达式</ToolTip> <Default>true</Default> </Literal> </Declarations> <Code Language="cpp"><![CDATA[#define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; int main() { $selected$$end$ system("pause"); return EXIT_SUCCESS; }]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>