Reputation: 185
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>cr</Title>
<Shortcut>cr</Shortcut>
<Description>Code snippet for Console.ReadLine</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>SystemConsole</ID>
<Function>SimpleTypeName(global::System.Console)</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[$SystemConsole$.ReadLine($end$);]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
I have been created my own snippets in VS for C#. At this time I am using ReSharper, but my own snippets doesn's show to me like cw, prop or any other.
Upvotes: 0
Views: 253
Reputation: 19081
You can define your own templates under:
Resharper > Tools > Template Explorer
In case usage is not immediately clear, here's an example. The following is a template I use for generating unit-tests for NUnit:
Click the dashed square icon to create a new template file (in a yellow circle below). Write your template-code in the window that opens up in the background, using $ before and after words you want to be able to tab between.
Give your template a shortcut in the upper right corner, and save. You should now be able to use it.
The example above can be run using "tmTab" or "tmEnter".
At that point, DO_SOMETHING
will be selected for editing. Use Tab or Enter to jump to and select Test_logic
.
Upvotes: 0
Reputation: 2261
In Visual Studio Menu go to Resharper - Tools - Template Explorer. Add your snippets there.
Upvotes: 2