As we all know by now, Microsoft (in their infinite “wisdom”…) have dropped macro support from Visual Studio 2012.
Unfortunately for me, I make extensive use of simple macros in Visual Studio 2010. These macros are very simple indeed; for example, doing things like inserting a GUID at the current caret location.
I would like to have the same functionality of all of these simple macros in VS2012, but for now I’d settle for one of my most-used ones: My “InsertTodo()” macro. All this does is to insert my initials and the current date at the current caret location, like so:
// TODO(MRW:2012-09-11):
It leaves the caret at the end of the inserted text, ready for me to type my TODO comment.
I have assigned this to the Alt+T key, for easy use.
The macro code in VS2010 is extremely basic (no pun intended ;):
Sub InsertTodo()
DTE.ActiveDocument.Selection.Text = String.Format("// TODO(MRW:{0}): ", DateTime.Now.ToString("yyyy-MM-dd"))
End Sub
My question is simple: How do I replicate this in Visual Studio 2012?
You can write a VS addin as described here:
http://www.codewrecks.com/blog/index.php/2012/08/24/converting-visual-studio-macro-to-visual-studio-plugin/
Or you can use a Powershell/NuGet hybrid as described here:
http://www.wintellect.com/CS/blogs/jrobbins/archive/2012/03/30/using-nuget-powershell-to-replace-missing-macros-in-dev-11.aspx