Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
ReSharper Live Templates Distilled

If you are a ReSharper user (I know many of you are) and you are NOT taking advantage of the LiveTemplates feature, you are really not maximizing your productivity.

Today I thought I would do a quick demo on how to create and use a LiveTemplate.  Sit back, relax and learn how to make yourself more productive.  For some info on LiveTemplates from JetBrains check this out.

Steps to creating your LiveTemplate

  1. Determine code that you create all the time
    For me I am always typing out Assert.That( XYZ, Is.EqualTo( ABC ) ) in my tests, so lets turn this into a LiveTemplate
  2. Launch the LiveTemplate Explorer 
    Reshaper -> LiveTemplates

    LiveTemplateExplorer
  3. Determine where you want to place your new template
    I would suggested you put it under the "User Templates" section, but your call.
  4. Select where you want to put your template and click the new button
    This should open up a new editor window, this is where the fun begins.
    1. Provide a Shortcut.  This is what you will type to produce the code in the LiveTemplate.  I would suggest you come up with a standard naming scheme to make life easier, but again your call.
    2. Provide a Description
    3. Copy and Paste in your code you want to use.
    4. Determine if you want any variables (dynamic content) in your template.  If you do, create the variables by putting $ around the name (ie $Value$). 
    5. Determine if you want your variable to use a macro.  If so, choose one fro the list on the right.

      TemplateCreator
  5. Time to use your new LiveTemplate
    Go back to your coding window and type in the shortcut you gave your template (ie ateq) and watch as code is generated.

There you go, 5 simple steps to creating and using a LiveTemplate.  You should not be much more productive and be able to code circles around your fellow developers.

Till next time,

[----- Remember to check out DimeCasts.Net -----]


Posted 06-18-2008 10:37 AM by Derik Whittaker

[Advertisement]

Comments

DotNetKicks.com wrote Learning how to create LiveTemplates with ReSharper
on 06-18-2008 12:11 PM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

sergiopereira wrote re: ReSharper Live Templates Distilled
on 06-18-2008 12:22 PM

I was happy to notice that one of the macros returns one of the other variables with the first character in lower case (I miss that in the VS snippets)... On the other hand, I wish this was a little more scriptable, something easier than a full-blown VS macro but with some more smarts. I love the kind of templates I can add to TextMate for example.

David wrote re: ReSharper Live Templates Distilled
on 06-18-2008 7:56 PM

Great summary. I just wanted to add that you can use $END$ to indicate where you want the cursor positioned after filling the live template. This can be really helpful:

[Test]

public void $ShouldDoSomething$() {

 $END$

}

Dew Droplet - June 19, 2008 | Alvin Ashcraft's Morning Dew wrote Dew Droplet - June 19, 2008 | Alvin Ashcraft's Morning Dew
on 06-19-2008 8:52 AM

Pingback from  Dew Droplet - June 19, 2008 | Alvin Ashcraft's Morning Dew

Andrei Butnaru's blog wrote Productivity tools, Resharper
on 07-21-2008 3:52 PM

Productivity tools, Resharper

on 07-26-2008 11:34 AM

Valium.

name wrote re: ReSharper Live Templates Distilled
on 05-25-2009 7:13 PM

comment1,

kaufen viagra online wrote re: ReSharper Live Templates Distilled
on 07-27-2009 3:37 PM

tqisalxw dilpzuwy tgjxtalf

compra viagra wrote re: ReSharper Live Templates Distilled
on 07-27-2009 4:02 PM

IY0owq yqukcwxw zqcrcrxv mnnwszce

viagra kaufen online wrote re: ReSharper Live Templates Distilled
on 07-28-2009 2:11 AM

ig5lgN jzmpibph zaeghtcn zqrnuflc

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)