At one time I was a fan of CodeRush. He allowed two or three keystrokes to create a property on the object or to compose the body of the cycle. It was a pleasure to type the code of the institute labs.
Then 2008 studio came out with C # 3.0 and there were automatic properties. I didn’t like it anymore when CodeRush didn’t do what I wanted. Short shotkat contribute to this. And at one point, I refused to use it. I spent more time fighting the instrument than if I typed the code myself.
Then I learned about studio snippets. In essence, these are the same code templates from CodeRush, only simpler ones. There are standard ones like for, foreach, prop and exception. To open them you need to write the name of the template and press TAB. If you use autocomplete, you can write part of the template name, and then TAB, TAB.
But the beauty is that you can write your own templates. Manually, however, it is better not to do this. The template is stored in XML and editing it manually is difficult.
')
However, there is an addition to the studio that allows you to create and edit templates -
http://www.codeplex.com/SnippetDesigner . Editing is as follows:

All fields are highlighted, settings are made in the document properties, as well as in the table of parameters. There is no syntax highlighting, but it's still an order of magnitude better than editing XML.
To connect a new snippet to the studio, you need to create it. This is done either through the context menu (for the selected code), or by copying an existing snippet file. Where are the templates can be viewed in the Tools \ Code Snippets Manager. Custom templates are the default in \ Documents \ Visual Studio 2008 \ Code Snippets \. If you create a template by copying a file, then you need to change its Shortcut property in XML. Either the studio, or SnippetDesigner caches snippets, and if you save the snippet with the same shortcut, you can lose the changes.
Examples of user snippets that I wrote while working with a recent WPF project I cited below. These templates saved me a few hours of routine typing and debugging.
Property with notification:
/// <summary>
/// $comment$
/// </summary>
/// <remarks>
///
/// </remarks>
private $type$ m_$property$;
/// <summary>
/// $comment$
/// </summary>
public $type$ $property$
{
get
{
return m_$property$;
}
set
{
m_$property$ = value ;
OnPropertyChanged( "$property$" );
}
}
Lazy initialization property:
/// <summary>
/// $comment$
/// </summary>
/// <remarks>
///
/// </remarks>
private $type$ m_$property$;
/// <summary>
/// $comment$
/// </summary>
public $type$ $property$
{
get
{
if ( m_$property$ == null )
{
m_$property$ = null ;
}
return m_$property$;
}
}
MS Prism team:
#region Command - $name$
/// <summary>
/// $comment$
/// </summary>
public DelegateCommand <$type$> $name$Command { get ; private set ; }
/// <summary>
/// $comment$
/// </summary>
private void $name$( $type$ parameter )
{
// TODO:
// $name$Command = new DelegateCommand<$type$>( $name$, Can$name$ );
// TODO: Shortcuts, ReturnKeyAssistants
}
/// <summary>
/// $comment$
/// </summary>
/// <returns>true </returns>
private bool Can$name$( $type$ parameter )
{
// TODO:
//return Errors.Count == 0;
return true ;
}
#endregion