Yes, it’s possible, it’s called snippet. The documentation of the resource is found 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
will the code you want expanded when you enter the chosen keyword (<Shortcut>hello</Shortcut>
). It is possible to 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>
Has a plugin that helps. Has one from Microsoft. Had the Snippeteditor, but was abandoned. There are also others better commercials.
But it’s nothing compared to available on Resharper. It’s another life.
Before you see if you have not ready. There are several collections of snippets ready.