Visual Studio 設(shè)置快捷代碼段
什么是快捷代碼段:
例如: 只需要輸入mst后按一下TAB就會自動生成代碼memset(str, 0, sizeof(str));,只需要輸入Pow就可以自動生成一個快速冪函數(shù)等等,非常方便快捷,一定程度提高了編寫代碼的效率
Visual Studio 設(shè)置自定義代碼段方法:
①新建文件XXX.snippet,其中的"XXX"就是上述的"Pow"、"mst",也就是代碼段的簡寫
②復(fù)制以下代碼(不知道VS不同版本是否相同,如果不同可以去工具-快捷代碼段里面找現(xiàn)成的,然后再修改)
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>Res</Title> <Shortcut>Res</Shortcut> <Description>結(jié)構(gòu)體代碼段</Description> <Author>Bycds</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> <SnippetType>SurroundsWith</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>index</ID> <Default>i</Default> <ToolTip>索引</ToolTip> </Literal> <Literal> <ID>max</ID> <Default>length</Default> <ToolTip>最大長度</ToolTip> </Literal> </Declarations> <Code Language="cpp"> <![CDATA[typedef struct Res //在這個地方輸入你要快捷生成的代碼 { int x, y; bool operator < (const Res &b) const { if(x<b.x) return 1; return 0; } }Res; Res s[200005];]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
③在CODE位置輸入你需要得代碼段,注意修改Title要和你的文件名一致
④新增自己的代碼段


之后選擇你創(chuàng)建的.snippet文件即可
⑤重啟VS,搞定

浙公網(wǎng)安備 33010602011771號