How to insert new GUID with one key press

When I work with WiX source code I need to create lots of GUIDs. In my Visual Studio 2005 editor all I need to do is to press Alt+G and new GUID magically appears at the cursor. Achieving this is very easy:

  1. Open Macros IDE by selecting Tools | Macros | Macros IDE.
  2. Create new macro:
  3. Public Sub InsertGuid()

    DTE.ActiveDocument.Selection.Text = Guid.NewGuid().ToString()

    End Sub

  4. Bind new macro to Alt+G keyboard shortcut. Open Options dialog, select Environment, then Keyboard on the left. Type “InsertGuid” to locate the macro you just created. Assign Alt+G to it.

    Fortunately, no standard command is assigned to Alt+G by default.