205

Apparently macros were dropped from Visual Studio 2012.

Is there a plugin/extension/tool that will let me record & play keyboard macros (much like the record/play temporary macro in Visual Studio 2010)?

For example, I typically would use a macro when converting code from one language to another or to quickly generate properties from a text list, etc.

Xavier Poinas
  • 19,377
  • 14
  • 63
  • 95
laktak
  • 57,064
  • 17
  • 134
  • 164
  • 1
    It looks like you might want to look into T4 templates, at least for your code generation scenarios. – John Saunders Aug 22 '12 at 01:13
  • Visual Studio 2012 and macros - http://www.viva64.com/en/b/0175/ –  Nov 01 '12 at 06:24
  • 2013 still does not support macros! - see bharry http://blogs.msdn.com/b/bharry/archive/2013/06/03/visual-studio-2013.aspx#10425640 – laktak Aug 29 '13 at 07:46
  • You can [create an add-in](http://stackoverflow.com/questions/12027485/alternative-to-macros-in-visual-studio-2012/12394986#12394986) as an alternative to creating a macro. The process is a bit more cumbersome, but on the bright side, you do get full VB or C# ([or apparently even F#](http://stackoverflow.com/questions/3399637/how-to-create-a-f-based-visual-studio-add-in)) capabilities instead of the awkward and fragile VB-only editor that VS macros always used in the past. – Ryan Lundy Nov 11 '13 at 20:20
  • 3
    UPDATE: They're back! A new extension for VS2013 has been released allowing users to "record most of the commands in Visual Studio including text editing operations." ( details here: https://visualstudiogallery.msdn.microsoft.com/d3fbf133-e51b-41a2-b86f-9560a96ff62b) – kmote Dec 01 '14 at 16:41
  • I just installed the new extension (from MSDN) and it is very buggy. Seems to drop letters randomly during playback! And the keyshortcuts don't work. So I tried VCMD instead and it is much better. Free version allows up to 10 saved macros. http://vlasovstudio.com/visual-commander/index.html – John Henckel Jan 22 '15 at 15:51
  • 1
    Worth reading about Wintellect's [Jon Robbins' reaction to macros being dropped](http://www.wintellect.com/devcenter/jrobbins/using-nuget-powershell-to-replace-missing-macros-in-dev-11) – Jason Evans May 16 '15 at 19:45

10 Answers10

185

You can try the Text Macros for Visual Studio 2012-2022 extension (I am the author). It basically does the same thing as the Notepad++ macros (text editing, no UI automation).

The code is open source (GitHub), so feel free to contribute improvements :-)

Xavier Poinas
  • 19,377
  • 14
  • 63
  • 95
161

In this version of Visual Studio, while there are literally hundreds of features, there are some we’ve actually taken out. One of those is the macros automation feature, including macro record/replay, macro projects and the Macros IDE. While we know that macros have been valuable for those who use them, unfortunately our usage data shows that less than 1% of Visual Studio developers take advantage of this feature. Therefore, we’ve found ourselves investing more deeply in the Visual Studio areas that get used every day, and have not updated macros for several releases.

Source: Macros in Visual Studio 11 Developer Preview

I have started to get around this (although inconvenient) by cutting/pasting into Notepad++, record and run the macro there and then cut/paste it back into Visual Studio 2012.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Guy
  • 65,082
  • 97
  • 254
  • 325
  • 194
    Cutting code out of your world class IDE to paste into Notepad++ to record and play a simple macro is a clear Microsoft Fail. However, I concur that this is the currently the simplest solution to this. Sad, but true. – mattmc3 Sep 04 '12 at 17:38
  • 74
    Less than 1% is definitely madeup, every (VS/C#) developer I know have used macros, I agree not everyday. – Sanjeevakumar Hiremath Sep 26 '12 at 20:36
  • 13
    Another reason to stick with VS2010 - or beg for it to be brought back here http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2650757-bring-back-macros – Mister Cook Oct 03 '12 at 08:08
  • 15
    This is unbelievable...1%??? This can't be true! This feature needs to be added back in - I used macros constantly in 2010. – Rockdocta Nov 19 '12 at 16:21
  • 4
    Wow... Killing of "Create Unit Test" context menu item is a big deal for a lot of folks. But killing this makes it even worse because now we can't even simulate the first thru a macro... Watta great thinking, M$ PMs! Fabulous... – Schultz9999 Nov 28 '12 at 05:27
  • 3
    That seems Microsoft it's cutting features of his products for reasons not related with the interest of the users. The same with drop the support for SQL Server 2000 in VS2010. May be one day Sharp Develop will be a better alternative. At least they will not remove features already working. – Apocatastasis Jan 17 '13 at 22:28
  • 44
    @SanjeevakumarHiremath I agree the number sounds low (not sure it's made up), but this is an argument in favor of always checking that box when you install a Microsoft product that says "send anonymous usage statistics to help better MS products." – Michael Jan 22 '13 at 04:05
  • 3
    What would be nice is if MS just offered the old code so we can re-implement it as a plugin like the one offered by Xavier Poinas. This is truly frustrating. – dyslexicanaboko May 21 '13 at 20:04
  • 5
    I used to use this feature far more in VS when it wasn't so sloooooow. I suspect one of the reasons people don't use it so much is the 10 second start up time, and then 1-2 seconds per macro playback. If worked really well on VS2003 and previous. Solution isn't to remove it, but to make it work faster. – Nick Jul 31 '13 at 10:13
  • 2
    @Guy I have to use UltraEdit for Macros as I've always felt the one in Visual Studio never was as robust. Instead of removing it, make it better and more would use it. – Chizl Aug 12 '13 at 17:09
  • 2
    I think VB IDE was removed from Visual Studio codebase without a planned replacement. Rest all "1% ..." is customer facing message. – mkale Aug 15 '13 at 01:39
  • 2
    Lame. Macros were the quickest way to paste new GUIDs into XML files. Used to just press ALT+G. Now I have to go up to tools, open the GUID generator tool, generate a GUID, copy the GUID, close the GUID generator tool, then paste the GUID... EVERY. SINGLE. TIME. Super lame. – BrainSlugs83 Aug 22 '13 at 05:54
  • Unfortunately this doesn't help people who used macros to things other than editing the code. I have a macro which is my own variant of "collapse to definitions" - which leaves comments open (basically "header file" mode). I just realized I can't import it from VS2010. It makes me feel like I have a handicap. – Amir Abiri Nov 01 '13 at 08:19
  • I may only use the macro recorder once in a blue moon, but when faced with a major refactoring, or when faced with some severely repetitive typing (like taking a list of properties and creating methods for each), macros are INVALUABLE. Macros have saved me literally dozens of hours of laborious typing when making the same change to 100's of files, doing a project-wide search and running the macro on each found identifier (find next being the last step of the macro). PLEASE BRING THIS FEATURE BACK IN SOME FORM!!! – James Hugard Nov 03 '13 at 16:09
  • 8
    I'd be willing to bet that there is a significant overlap between people who used macros to speed up their coding and people who see that "Send Microsoft Usage Data" checkbox, think about the fraction of a second they'll spend waiting for the usage collection code to run, and decide to uncheck it. – Paul Nov 16 '13 at 15:31
  • 3
    I hope no one is surprised that people who use macros have come to the conclusion with anecdotal evidence that more than 1% of developers use macros. – Joel McBeth Jan 31 '14 at 15:56
  • WTF?!... are you for real? now I'll need to cook copy-pasta in notepad++ that had MUCH better macro support that VS which for some reason was always insanely freaking slow – Pavel P Feb 20 '14 at 17:31
  • Is a large percent of their usage statistics coming from students and novices who aren't ready to unleash the full power of their IDE perhaps? 1% seems ridiculously low to me as well. – crush May 28 '14 at 18:28
  • In usage time, I know I used macros less than 1% of my time while coding. However, when I needed a macro (to turn a default constructor code into a copy constructor code, for instance), it was extremely handy. So I can believe the "less than 1% usage"--- as most developers would not, in fact, be using a macro 1 second out of every 100 seconds of IDE usage--- or even code creation/editing. But that doesn't stop them from being a very useful feature in the IDE. – StarPilot Jul 29 '14 at 17:04
  • 1
    So only 1% of people who use Visual Studio have a clue? – Mick Jan 30 '15 at 08:42
  • 2
    Only 1% used it because the MS implementation sucked so bad. If it were implemented correctly i think more people would have used it. So if you cant do something right then don't even try. That's an interesting approach. Its a very valuable feature. I vote that they revisit this. – Menace Jul 12 '15 at 01:02
  • I must admin I have just come to this and found an instance where I want to record a macro and then run it on my code. I am stunned that M$oft have done this. - Truly this is retarded, please listen microsoft and put this feature in – julian guppy Mar 18 '16 at 14:34
  • unfortunately... about that. I'm that one percentage... I'm so great :D Any way I need it and it's not exists, Microsoft code base sucks. I think I request for macro in Resharper forum other than Microsoft. I think it's good if Microsoft keep things lightweight, and let other companies run their plugins at better performance. – Hassan Faghihi May 03 '16 at 07:29
  • I guess I'm in the 99% who don't use macros.. Although, if the macro language matched up with .Net (either C# or VB) and the API was fully documented, I might occasionally use it (there are times I really wish I could use a macro, instead I have to weigh the cost of writing a small app, using a complex RegEx, or doing things by hand as Macros have been unavailable for several VS releases). – Zarepheth Jul 18 '17 at 20:40
  • Even seen the movie Idiocrity? – Brain2000 Apr 29 '19 at 22:20
  • It could be that less than 1% of VS SESSIONs used this feature (vs. 1% of USERs). Or maybe less than 1% SAVE their macros (I do not - I typically just record edit snippets for record one-time, but play back 100 times, use). – franji1 Feb 13 '23 at 15:29
50

Stand out and vote for bringing macros back!

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2650757-bring-back-macros

UPDATE (10/4/2013):

Yay! Thank to your votes the macros are now considered for return! Keep pushing!

We are currently reviewing the feasibility of delivering a scripting capability in a future version of Visual Studio. Please continue to offer your comments on what scripting capability we should offer while we research this suggestion.

Tony Goodhew, Program Manager, VS Pro.

Community
  • 1
  • 1
Trident D'Gao
  • 18,973
  • 19
  • 95
  • 159
  • 1
    Voted +3. Though, I did the same for Bluetooth SPP support in WP7 (which was the #1 requested feature), and it took them over two years to implement a limited version of SPP. :( – eduncan911 Mar 19 '13 at 18:56
25

Since using Sublime Text I found that there are in fact better ways to edit text than by using macros.

Sublime allows you to to edit your text with multiple cursors at once. It's hard to explain but there are several animations that show it off at http://www.sublimetext.com

Sublime Screenshot

I've also added Sublime as an external tool to Visual Studio:

  • open Tools/External Tools
  • add: Sublime, select the exe and use these arguments: $(ItemPath):$(CurLine):$(CurCol)
  • (also move it to the top as this makes the next step easier, otherwise remember its position)
  • then go to customize/Keyboard, search for Tools.ExternalCommand1 and add your preferred keyboard shortcut.

This will open the current document in Sublime at the same cursor position that you were in VS.

(also, Sublime can do macros in case you still need them)

laktak
  • 57,064
  • 17
  • 134
  • 164
  • 3
    Here is a great extension for VS2012+ that adds this type of editing, it has been very useful to me: http://visualstudiogallery.msdn.microsoft.com/2beb9705-b568-45d1-8550-751e181e3aef?SRC=VSIDE – Duane Jun 04 '14 at 16:21
  • 2
    That said, there are times when macros are handy, like having to perform the same action in multiple files. – Duane Jun 04 '14 at 16:22
23

MACROS ARE BACK!

Under Review → Completed

We’ve heard your feedback loud and clear, and we’ve been working on a solution. We’re therefore very happy to announce that we’ve now released a version of Macros that supports both Visual Studio 2015 and Visual Studio 2013.

While we were at it, we took the opportunity to fix a couple of bugs and improved the keyboard shortcuts. We hope you enjoy it.

For more information, see the blog post here: http://aka.ms/vsmacros

We’ve also open-sourced the code under the MIT license. If you have any suggestions or contributions, feel free to create an issue or a pull request in the new GitHub repo: http://github.com/Microsoft/VS-Macros

Justin Clareburt Senior Program Manager

Macros for Visual Studio

Macros for Visual Studio is an extension for Visual Studio 2013 and Visual Studio 2015 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

enter image description here

laktak
  • 57,064
  • 17
  • 134
  • 164
  • This plugin is very buggy. I got it working on VS2017 eventually, but it stopped working a couple of hours later. Reviews are largely negative. – StuartN Oct 27 '17 at 08:56
  • Please note that while the source code is open source, "This extension was originally created by a group of interns on the Visual Studio team. It is no longer maintained" – Yann Duran Mar 29 '19 at 08:00
18

Visual Commander extension (developed by me) supports code editing macro recording and playback in Visual Studio 2015/2017/2019.

Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66
5

I just was brought to my attention that Microsoft released an extension to Visual Studio 2013 to support macro's back again:

https://visualstudiogallery.msdn.microsoft.com/d3fbf133-e51b-41a2-b86f-9560a96ff62b

I'd advice to still vote for the feature to encourage them to make the extension available for Visual studio 2015 too: https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2650757-bring-back-macros

codetuner
  • 316
  • 3
  • 8
  • This sounded pretty good, but the CTRL-M,P keys are bound to "stop outlining". Even after removing this binding, the default playback doesn't seem to work. – Wheezil Nov 16 '15 at 00:10
3

Use Macros for Visual Studio 2013 + 2015

Macros open source URL: https://github.com/Microsoft/VS-Macros

Announcement on MSDN Blog: Macros extension: VS 2015 support and open-sourced

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Reader Man San
  • 2,159
  • 1
  • 15
  • 9
2

VSScript allows recording, writing, and editing macros in Lua, though I have not yet been able to make it work with Visual Studio 2015 (the command button is greyed out; documentation says Visual Studio 2005 to 2015 RC are supported).

It is currently released as a freeware.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Erwin Mayer
  • 18,076
  • 9
  • 88
  • 126
2

The Visual Commander extension lets you automate repetitive tasks in Visual Studio.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
alexanoid
  • 24,051
  • 54
  • 210
  • 410