Hey, there's a Macro in my Visual Studio! (Well, there will be if you install this extension…)

  • submit to reddit

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.

image

Macros for Visual Studio 2013 is an extension for Visual Studio 2013 that enables the use of macros to automate repetitive tasks in the IDE. The extension can record most of the commands 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

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.

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, (show/hide status bar): 
    var property = dte.Properties(“Environment”, “General”); property.Item(“ShowStatusBar”).Value = true
  • Undo 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

If you present, this might be a huge time saver for you. If you do the same thing, over and over in VS, this might be a huge time saver for you. If you just like the idea of have Macro’s in your VS, this…

Now, we just need a “store” or gallery and/or an easy means to share our Macro’s and I think we’d be good. 🙂

Published at DZone with permission of Greg Duncan, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Source: Hey, there's a Macro in my Visual Studio! (Well, there will be if you install this extension…)

Post author

Dustin Gurley is an Designer, Developer, Artist, Instructor, Critical Theorist and Systems Engineer. He has an extensive background working professionally with 2D/2.5D/3D Motion Graphics, Compositing, Film, Video, Photography and client-side performance techniques as it pertains to web development. Dustin recently completed work on his Master of Fine Art degree in Motion Media Design (Motion Graphics) from the Savannah College of Art and Design. Prior to beginning his graduate work, Dustin obtained a Bachelor of Art degree in Communication Studies with a concentration in Broadcast and Emerging Media from the University of North Carolina at Wilmington. In addition to design and modeling, Dustin enjoys toying with his view camera, working with scratch film, authoring media related material and contributing to various industry conferences. When not in front of a computer, Dustin can be found with his wife, Regina Everett Gurley. The couple enjoys dividing their time between their home just outside of Raleigh, North Carolina and the beautiful North Carolina coast. Currently, Dustin serves as the Lead Instructor of Internet Technologies for Wake Technical Community College in Raleigh, North Carolina.