Yes, it is possible, this is called snippet . The resource documentation is here .
Go to the Tools menu - > Code Snippets Manager and import the * snippet that you created. The file that contains your definition follows this template:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title></Title>
</Header>
<Snippet>
<Code Language="">
<![CDATA[]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
In CDATA
goes the code you want to be expanded when you enter the chosen keyword ( <Shortcut>hello</Shortcut>
). You can create "variables" in the template ( $SqlConnString$
):
<Declarations>
<Literal>
<ID>SqlConnString</ID>
<ToolTip>Replace with a SQL connection string.</ToolTip>
<Default>"SQL connection string"</Default>
</Literal>
<Object>
<ID>SqlConnection</ID>
<Type>System.Data.SqlClient.SqlConnection</Type>
<ToolTip>Replace with a connection object in your application.</ToolTip>
<Default>dcConnection</Default>
</Object>
</Declarations>
You have a plugin that helps . You have one from Microsoft . It had the SnippetEditor , but was abandoned. You also have other best commercials .
But it compares to the available in Resharper . It's another life.
First make sure you do not have it ready. There are several collections of snippets ready.