BT

JavaScript Powered Macros in Visual Studio 2013

| by Jeff Martin Follow 17 Followers on Nov 26, 2014. Estimated reading time: 1 minute |

Many popular development environments offer a scripting language or similar method of automating common tasks to make ease life for the developer.  The Visual Studio Platform Team has released a new extension for Visual Studio 2013 that will allow developers to record and playback macros from within the editor. 

The extension works by storing commands that control Visual Studio directly through the DTE Interface.  A recorded macro can be replayed as needed, and can easily be edited within VS2013 like any other JavaScript file.  Users also have the ability to assign macros to specific hotkeys, and share recorded macros with other users.  (Macros are stored in a user’s local profile: AppData\Local\Microsoft\VisualStudio\12.0\Macros\Macros .)

There are a number of sample scripts provided with the extension to use and use as a basis for your own scripting.  Some of the scripts start simple with by inserting the current date & time while others toggle line numbers or head a header to all C# files in the active solution.  Having the source code in hand allows for more complex scenarios to be quickly designed and demonstrates how the extension can do more than just replay user keystrokes.

The extension is available now from the Visual Studio Gallery.  

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

... by Mark N

Good for .NET devs. You'd think this would have been built into VS.NET years ago (like other IDE's). And would not require JS scripting.

Re: ... by Michael Donkhin

It was built-in until VS2012. See this: stackoverflow.com/questions/12062515/can-i-reco....

Adding javascript code to macros by Richard Drain

I use to have some extremely helpful Macros running in the original Macros of VS2010 but those no longer work! I thought I'd try adding similar macros via the extension. I wanted to replace an "InputBox" method using the JavaScript 'prompt' method to get input from the user. How can this be done in the new Macro editor. I put in "var myString = prompt("Input String", "new string here")" and get "Current.js error Line nnn: Object expected". I have trouble with even getting simple string methods to work. I found ALL of the samples to be extremely simple macros compared with the ones we had for code documentation.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

3 Discuss
BT