Your Editor should Encourage You

vs vsix dev encouragement 27 comments suggest edit

I love to code as much as the next developer. I even professed my love in a keynote once. And judging by the fact that you’re reading this blog, I bet you love to code too.

But in the immortal words of that philosopher, Pat Benatar,

Love is a battlefield.

There are times when writing code is drudgery. That love for code becomes obsession and leads to an unhealthy relationship. Or worse, there are times when the thrill is gone and the love is lost. You’re just going through the motions.

In those dark times, bathed in the soft glow of your monitor, engrossed in the rhythmic ticky tacka sound of of your keyboard, a few kind words can make a big difference. And who better to give you those kind words than your partner in crime - your editor.

With that, I give you ENCOURAGE. It’s a Visual Studio extension that provides a bit of encouragement every time you save your document. Couldn’t we all use a bit more whimsy in our work?

encouragement light

And it’s theme aware!

encouragement dark


Yes, it’s silly. But try it out and tell me it doesn’t put an extra smile on your face during your day.

This wasn’t my idea. My co-worker Pat Nakajima came up with this idea and built a TextMate extension to do this. He showed it to me and I instantly fell in love. With the idea. And Pat, a little.

Apparently it’s very easy to do this in TextMate. Here’s the full source code:

 #!/usr/bin/env ruby -wU

  puts ['Nice job!', 'Way to go!', 'Wow, nice change!'].sample

It’s a bit deceiving because most of the work in getting this to work in Textmate is configuration.


As for Visual Studio, it takes quite a bit more work. You can find the source code on GitHub under an MIT license.

The code hooks into the DocumentSaved event on the DTE and then cleverly (or hackishly depending on how you look at it) uses an IIntellisenseController combined with an ISignatureHelpSource to provide the tool tip.

Here’s the relevant code snippet from the EncourageIntellisenseController class:

public EncourageIntellisenseController(
  ITextView textView,
  DTE dte,
  EncourageIntellisenseControllerProvider provider)
  this.textView = textView;
  this.provider = provider;
  this.documentEvents = dte.Events.DocumentEvents;
  documentEvents.DocumentSaved += OnSaved;

void OnSaved(Document document)
  var point = textView.Caret.Position.BufferPosition;
  var triggerPoint = point.Snapshot
    .CreateTrackingPoint(point.Position, PointTrackingMode.Positive);
  if (!provider.SignatureHelpBroker.IsSignatureHelpActive(textView))
    session = provider.SignatureHelpBroker
      .TriggerSignatureHelp(textView, triggerPoint, true);

Many thanks to Pat Nakajima for the idea and Jared Parsons for his help with the Visual Studio extensibility parts. I’m still a n00b when it comes to extending Visual Studio and this silly project has been one fun way to try and get a handle on things.

Get Involved!

As of today, this only supports Visual Studio 2013 because of my ineptitude and laziness. I welcome contributions to make it support more platforms.

Parting Thoughts

On the positive side, when you need a specific service, it’s nice to be able to slap an [Import] attribute and magically have the type available. The extensibility of Visual Studio appears to be nearly limitless.

On the downside, it’s ridiculously difficult to write extensions to do some basic tasks. Yes, a big part of it is the learning curve. But when you compare the Textmate example to what I had to do here, clearly there’s some middle ground here between simplicity and power.

Also, the documentation is quite good but often wrong in places. For example, in this Walkthrough it notes:

Make sure that the Content heading contains a MEF Component content type and that the Path is set to QuickInfoTest.dll.

That might have been true with the old VSIX manifest format, but is not correct for the new one. So none of my MEF imports worked until I added this line to the Assets element in my .vsixmanifest folder.

  Path="|%CurrentProject%|" />

I’m not really sure why that’s just not there by default.

There are certainly a lot of extensions in the Visual Studio Extension Gallery, so I would still call consider the extensibility model to be a success for the most part. But there could be a lot more extensions in there. More people should be able to extend the IDE for their own needs without having to take a graduate course in Visual Studio Extensibility.

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.



27 responses

  1. Avatar for Mads Kristensen
    Mads Kristensen June 20th, 2014


    I tried to add support for VS 2012, but I wasn't successful. It would have been easier if you wrote it in VS2012 and then add support for VS2013

  2. Avatar for Viscious
    Viscious June 20th, 2014

    Thank you.

    My colleague is on vacation. I will be installing this on his behalf while he is away.

  3. Avatar for Igal Tabachnik
    Igal Tabachnik June 21st, 2014

    Instead of adding the Asset line manually, you could have added it via the UI (double-click on the vsixmanifest file), but you have a point...

  4. Avatar for hilton
    hilton June 22nd, 2014

    Of course the obvious feature request is to allow custom words of "encouragement"

  5. Avatar for James Tryand
    James Tryand June 23rd, 2014

    Have you seen StudioShell? It makes visual studio extensions trivial and fun.

  6. Avatar for Ruben Bartelink
    Ruben Bartelink June 23rd, 2014

    I couldnt live without [OS_CompilationResult]( [which uses DevExpress's DXCore free portion of CodeRush to pop a yes/no upon each build]

  7. Avatar for nportelli
    nportelli June 23rd, 2014

    Can you make the breakpoint icons into emoticons?

  8. Avatar for nanqi
    nanqi June 23rd, 2014

    Why can not I be transplanted to It in vs2010

  9. Avatar for Scott Koon
    Scott Koon June 23rd, 2014

    Oh man, now I totally want emoji support in Visual Studio.

  10. Avatar for haacked
    haacked June 23rd, 2014

    Ha! I was thinking about making that as a fun experiment by rendering images.

  11. Avatar for haacked
    haacked June 23rd, 2014

    :( Is the VSIX manifest format different?

  12. Avatar for haacked
    haacked June 23rd, 2014

    Ooh, yeah. I should make that configurable.

  13. Avatar for Mads Kristensen
    Mads Kristensen June 23rd, 2014

    No, it's the required VS assemblies that didn't match up. It's odd

  14. Avatar for Tom Burton
    Tom Burton June 23rd, 2014

    More than just custom words, custom sources of words. The Unix/Linux Fortune command would might be good for this.

  15. Avatar for flemgrem
    flemgrem June 24th, 2014

    may the force be with you

  16. Avatar for Konrad
    Konrad June 24th, 2014

    Hi Phil. Could you add "So smart!" please or even some option to add own messages.

  17. Avatar for Jon Davisx
    Jon Davisx June 25th, 2014

    Somebody bring back the Xbox 360 style Visual Studio Achievements extension to VS 2013! It was previously published for VS 2010.

  18. Avatar for John Bubriski
    John Bubriski June 26th, 2014

    I added this! I simply reverted most of the version references from 12 to 11, and then with a Tweak from Jared Parson it should work with 2012 and 2013. There is a Pull Request open right now for it:

  19. Avatar for aaron
    aaron June 26th, 2014

    I installed this, its starting to sound a bit patronising. after doing something a little hackish to get it to compile, "Wow, nice change" pops up.

    like you could do any better you stupid ide


  20. Avatar for haacked
    haacked June 26th, 2014

    Ha! I should add configuration of messages.

  21. Avatar for Mike Cattle
    Mike Cattle July 23rd, 2014

    I want this, and I want to use it in VS2010, but I don't have the spare cycles right now to add the support, myself.

    Anyway, Nice Job! Way to go!

  22. Avatar for Juliano
    Juliano July 26th, 2014

    So good!

    Is it possible that I'm the only commenter here merely thanking you for doing this?

  23. Avatar for AndreiV
    AndreiV August 8th, 2014

    This is just awesome! Thank you! I cannot stop giggling whenever I save my code. One question though: is it possible to make it available in Express editions?

  24. Avatar for haacked
    haacked August 8th, 2014

    Only Microsoft can make extensions for Visual Studio Express. It's closed off to everyone else still. :(

  25. Avatar for AndreiV
    AndreiV August 8th, 2014

    Oh... I didn't know that... Oh well, I still get to enjoy it at work. Again, nice work.

  26. Avatar for danvy
    danvy November 12th, 2014

    Interesting. I would have used successful build instead of save file.

  27. Avatar for haacked
    haacked November 12th, 2014

    That could be an interesting setting. I'd accept a PR for that. :)