An extension for Visual Studio 2012-2017 that brings back support for macros in text/code editors
C#
Latest commit 4ab8f99 Apr 27, 2017 @xps Updates for VS 2017
Permalink
Failed to load latest commit information.
Dialogs
Documentation Version 1.10 Apr 23, 2017
Model Added parameterless constructor for SavedMacros May 17, 2016
Properties
Resources Initial Commit Nov 10, 2012
Utilities Save current macro Jan 31, 2013
.gitignore
GlobalSuppressions.cs
GuidList.cs
Key.snk
License.txt Moved license to root so that it is automatically detected by Github Apr 23, 2017
MacroAdornmentManager.cs
MacroCommandFilter.cs
Microsoft.VisualStudio.CoreUtility.dll
Microsoft.VisualStudio.Editor.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.GraphModel.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.OLE.Interop.dll
Microsoft.VisualStudio.Shell.11.0.dll
Microsoft.VisualStudio.Shell.Immutable.10.0.dll
Microsoft.VisualStudio.Shell.Immutable.11.0.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.Shell.Interop.10.0.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.Shell.Interop.11.0.dll
Microsoft.VisualStudio.Shell.Interop.8.0.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.Shell.Interop.9.0.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.Shell.Interop.dll
Microsoft.VisualStudio.Text.Data.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.Text.Logic.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.Text.UI.Wpf.dll
Microsoft.VisualStudio.Text.UI.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.TextManager.Interop.8.0.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
Microsoft.VisualStudio.TextManager.Interop.dll Revert back to compiling against VS 2012 SDK Aug 8, 2015
PkgCmdIDList.cs
ReadMe.md Updates for VS 2017 Apr 27, 2017
Resources.Designer.cs Updated Solution to VS 2015 Aug 3, 2015
Resources.resx Initial Commit Nov 10, 2012
VSPackage.resx Version 1.10 Apr 23, 2017
VSTextMacros.csproj Updates for VS 2017 Apr 27, 2017
VSTextMacros.sln Updates for VS 2017 Apr 27, 2017
VSTextMacros.vsct Added option to save macro May 10, 2016
VSTextMacrosPackage.cs Version 1.10 Apr 23, 2017
VsTextViewCreationListener.cs Namespaces clean-up Jan 31, 2013
envdte.dll
packages.config Revert back to compiling against VS 2012 SDK Aug 8, 2015
source.extension.vsixmanifest Updates for VS 2017 Apr 27, 2017
stdole.dll

ReadMe.md

What is it?

An extension for Visual Studio 2012-2017 that brings back support for macros in text/code editors. These macros can be used to automate repetitive text editing tasks.

You may have used such macros in previous versions of Visual Studio. Indeed, macros used to be supported and removed in Visual Studio 2010.

Although macros used to be very sophisticated at the time, letting you control almost any feature of Visual Studio, this extension only aims at supporting the text editing part of macros.

And if you have not used Visual Studio macros before, you may have used them in other text editors such as Notepad++ or Sublime Text. If you have, then you already know how to use this extension.

Download

You can download the VSIX installer from the Visual Studio Marketplace.

How does it work?

After installing this extension, you will find a menu called Text Macros in the Tools menu. It will only be visible when there is an active text or code editor. It has 3 submenus: one that toggles the recording of a macro (Start/stop recording macro), one that replays the last recorded macro (Playback macro), and another that can repeat the macro any given number of times.

Screenshot

So the idea is that you start recording, make some edits, stop recording, and then replay the edits.
For example, here's what you would do if you just copied a few signatures from an interface that you have to implement:

Demo

You can change the shortcuts associated with the macro menus in Tools > Options > Environment > Keyboard.
Look for the following commands:

  • Tools.RecordMacro
  • Tools.PlaybackMacro
  • Tools.PlaybackMacroMultipleTimes
  • Tools.SaveMacro
  • Tools.OpenSavedMacros

What can be recorded?

Only text editing features can be recorded, so you cannot use this extension to automate work in, say, a Windows Forms editor.

Currently, here are the commands that can be recorded:

  • Cursor movements
  • Characters that you type
  • Tabs, new lines, deletions
  • Some text editing commands from the Edit menu (to lowercase, to uppercase...)

Known limitations:

  • Find operations are not recorded (more details here).
  • Recording copy/paste operations does not work well when the Productivity Power Tools extension is installed (more details here)

Change Log

1.10 - Apr 23, 2017

  • Support for Visual Studio 2017
  • Playback macros in a single undo transaction (thanks to Yves Goergen)

1.9 - May 17, 2016

1.8 - May 5, 2016

  • Added option to save macros

1.7 - Aug 8, 2015

  • Fixed support for VS 2012/2013

1.6 - Jul 21, 2015

  • Support for Visual Studio 2015 (thanks to Ian Prest)

1.5 - Jul 8, 2014

  • Added "Edit.LineFirstColumn" as a recordable command (thanks to Jose Jiminiz).

1.4 - Dec 7, 2013

  • Added menu to repeat macro a given number of times.

1.3 - Nov 28, 2013

  • Fixed macros not working in certain file types (HTML...)
  • Recording additional edit commands: Format Document/Selection, Comment/Uncomment Selection, Delete Horizontal White Space, Increase/Decrease Line Indent, Organize Usings, Move Selected Lines Up/Down (VS 2013).

1.2 - Oct 24, 2013

  • Support for Visual Studio 2013
  • Added 'Ctrl+Shift+R' shortcut to match shortcut of previous Visual Studio versions

1.1 - Feb 8, 2013

  • Added visual cue while recording
  • Currrent macro now persists across sessions

1.0 - Nov 13, 2012

  • Initial version

Want to contribute?

  • Let me know of any issues you may find (include a portion of text and keystroke sequence if it is a problem with a macro)
  • Fork the code and contribute bug fixes or new features

License

Text Macros for Visual Studio Copyright (C) 2012-2017 Xavier Poinas

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.