Snippet 在 SSMS 中创建 Snippet
Snippet to create Snippet in SSMS
问题:
通常,如果您想将代码保存为片段,您必须打开一些 xml 模板、调查标签等。Reference
是否可以尽可能地简化这个过程:即创建一个 SurroundsWith
片段,将通过片段代码包装选定的代码?
请尝试以下操作:
- 将此代码另存为 create_new_snippet.snippet 并通过代码片段管理器(Ctrl+K、Ctrk+B)将其添加到您的 SSMS
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Create_new_snippet</Title>
<Shortcut></Shortcut>
<Description>Snippet to create a snippet</Description>
<Author>Denis Sipchenko</Author>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal> <ID>Title</ID> <Default>NewSnippetTitle</Default> <ToolTip>NewSnippetTitle</ToolTip> </Literal>
<Literal> <ID>Description</ID> <Default>NewSnippetDescription</Default> <ToolTip>NewSnippetDescription</ToolTip> </Literal>
<Literal> <ID>Author</ID> <Default>Unsung Hero</Default> <ToolTip>NewSnippetAuthor</ToolTip> </Literal>
<Literal> <ID>SnippetType</ID> <Default>SurroundsWith</Default> <ToolTip>SurroundsWith OR Expansion</ToolTip> </Literal>
<Literal> <ID>CodeComment</ID> <Default>-- Sorry. I was too lazy to write some usefull comment here</Default> <ToolTip>Comment for you code</ToolTip> </Literal>
</Declarations>
<Code Language="sql"
Delimiter="`">
<![CDATA[<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>`Title`</Title> <!--`Title`.snippet -copy/paste for filename-->
<Shortcut></Shortcut>
<Description>`Description`</Description>
<Author>`Author`</Author>
<SnippetTypes>
<SnippetType>`SnippetType`</SnippetType> <!--SurroundsWith/Expansion-->
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal> <ID></ID> <Default></Default> <ToolTip></ToolTip> </Literal>
</Declarations>
<Code Language="SQL">
<![CDATA[`CodeComment`
$selected$`selected`$end$`end`
]]`fake`>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Select 您的代码(您想要保存为片段)并调用 Surround With...
片段 (Edit\IntelliSense\Surround With...
Ctrl+K, Ctrl+S
)
必要时编辑参数(如标题、描述等...)并另存为 [YourSnippetName].snippet
到您的代码段文件夹中。
问题: 通常,如果您想将代码保存为片段,您必须打开一些 xml 模板、调查标签等。Reference
是否可以尽可能地简化这个过程:即创建一个 SurroundsWith
片段,将通过片段代码包装选定的代码?
请尝试以下操作:
- 将此代码另存为 create_new_snippet.snippet 并通过代码片段管理器(Ctrl+K、Ctrk+B)将其添加到您的 SSMS
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Create_new_snippet</Title>
<Shortcut></Shortcut>
<Description>Snippet to create a snippet</Description>
<Author>Denis Sipchenko</Author>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal> <ID>Title</ID> <Default>NewSnippetTitle</Default> <ToolTip>NewSnippetTitle</ToolTip> </Literal>
<Literal> <ID>Description</ID> <Default>NewSnippetDescription</Default> <ToolTip>NewSnippetDescription</ToolTip> </Literal>
<Literal> <ID>Author</ID> <Default>Unsung Hero</Default> <ToolTip>NewSnippetAuthor</ToolTip> </Literal>
<Literal> <ID>SnippetType</ID> <Default>SurroundsWith</Default> <ToolTip>SurroundsWith OR Expansion</ToolTip> </Literal>
<Literal> <ID>CodeComment</ID> <Default>-- Sorry. I was too lazy to write some usefull comment here</Default> <ToolTip>Comment for you code</ToolTip> </Literal>
</Declarations>
<Code Language="sql"
Delimiter="`">
<![CDATA[<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>`Title`</Title> <!--`Title`.snippet -copy/paste for filename-->
<Shortcut></Shortcut>
<Description>`Description`</Description>
<Author>`Author`</Author>
<SnippetTypes>
<SnippetType>`SnippetType`</SnippetType> <!--SurroundsWith/Expansion-->
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal> <ID></ID> <Default></Default> <ToolTip></ToolTip> </Literal>
</Declarations>
<Code Language="SQL">
<![CDATA[`CodeComment`
$selected$`selected`$end$`end`
]]`fake`>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Select 您的代码(您想要保存为片段)并调用
Surround With...
片段 (Edit\IntelliSense\Surround With...
Ctrl+K, Ctrl+S
)必要时编辑参数(如标题、描述等...)并另存为
[YourSnippetName].snippet
到您的代码段文件夹中。