VBA based macros were removed in VS 2012. Since then, the community has stepped up and released extensions to fill that gap, like Extending Visual Studio with your new buddy, VsCommandBuddy.
A couple weeks ago the Visual Studio Team released a new VS Macro extension that takes a new look at build VS macros in JavaScript, but also released the entire thing as open source!
Macros extension: VS 2015 support and open-sourced
Macros have always been popular, first as part of the product, and now as an extension. In response to your feedback we have upgraded the Macros for Visual Studio 2013 extension to be compatible with Visual Studio 2015. You can download the upgraded extension from the Visual Studio Gallery.
But wait, there’s more!
As part of our commitment to partnering with our developer community, we have open-sourced the code. So now you can view the code, make your own improvements, and contribute to the project for future releases. The open source project is available on GitHub under the MIT license.The Macros extension can help you be more productive by enabling you to automate repetitive tasks in the IDE. It lets you record and playback most of the commands in Visual Studio – including text editing operations. Some common examples include: adding a header to all your files; formatting rows of data; and creating shortcuts for frequently used commands. Check out the examples available in the Samples folder in the Macros Explorer – or experiment with it yourself!
... [Read the whole post]
Microsoft/VS-Macros
An extension for Visual Studio 2013+ that enables the use of macros in the IDE. The extension can record most of the features in Visual Studio including text editing operations.
Features
- Record and playback active document operations and Visual Studio IDE commands
- Playback multiple times
- Manage and persist macros with a Macro Explorer
- Assign keyboard bindings to any macro
- Macros recorded as JavaScript files that call VS DTE APIs
- Macro editing in Visual Studio with DTE IntelliSense
- Stop playback
- Sample macros
Example
Suppose you wanted to convert the private variables in the following class to public fields.
...
Getting Started
After installing the extension, the Macro menu will appear under
Tools > Macros
. Under this menu, you'll find commands to record and playback a macro.Current macro
The Current macro is a temporary macro that holds the last recorded macro. To persist it, use the Macro Explorer toolbar command
Save Current Macro
(or right-click the Current macro). Name the new macro and assign a shortcut if you wish. The new macro will then be persisted on your file system.Assigning a shortcut
...
Sample macros
Accessibility
- Decrease Font Size
- Increase Font Size
- Maximize Tool Windows
Documents
- Close Except Active: close all files in Visual Studio except active file
- Headify All: insert header into each C# file in the solution
- Remove and Sort All: remove unused usings and then sort, for each C# file in the solution
Editor
- Beginning of Function: moves cursor to the beginning of the current function
- Insert Date & Time
- Insert Date
- Insert Header: insert header into current C# file
- Insert Time
- Pane Center Screen
- Pane Top Screen
- Save Backup: saves active document as .bak file in current directory
Snippets (inserts code snippet)
- For Each Document: to iterate through each open document in Visual Studio
- For Each Window: to iterate through each open window in Visual Studio
Properties: grab one of the properties in Tools >> Options
For example, to show/hide status bar:
var property = dte.Properties("Environment", "General")
property.Item("ShowStatusBar").Value = trueUndo Context: encapsulate a single undo in macro script
Utilities
- Find Line: queries find tool for current line
- Toggle Line Numbers
- Toggle Word Wrap
Caveats
The following are not supported by the extension right now:
- Recording interaction with dialogs
- Recording of 'async' commands like Build may not execute as expected
- Execute a macro inside another macro
....
Once cloned, the project compiles and runs just fine...
Wait, did I say run? But it's a class library/VS Extension? Check out this answer to How to debug Visual Studio extensions. It's an old question/answer but still works (at least it did for me).
Follow @CH9
Follow @coding4fun
Follow @gduncan411
