Generate New GUID Using Visual Studio

 Admin   
183 View    Jan 19 2020 12:30AM

A simple Visual Studio Code command extension for inserting globally unique identifiers(GUIDs) in a variety of formats into the Code text editor.

 

This provides the same useful formats as Create GUID that ships with Visual Studio, but without specific language syntaxes for some formats and without unwanted line feeds. Currently, formats supported include:

  1. Simple string: 11d4dc2e-375a-4b89-9ad4-aa30105385aa
  2. Registry string: {11d4dc2e-375a-4b89-9ad4-aa30105385aa}
  3. C structure: static const struct GUID __NAME__ = {0x11d4dc2e, 0x375a, 0x4b89, {0x9a, 0xd4, 0xaa, 0x30, 0x10, 0x53, 0x85, 0xaa}};
  4. C macro: DEFINE_GUID(__NAME__, {x11d4dc2e, 0x375a, 0x4b89, 0x9a, 0xd4, 0xaa, 0x30, 0x10, 0x53, 0x85, 0xaa);
  5. Unformatted string: 11d4dc2e375a4b899ad4aa30105385aa

The token __NAME__ is easy to replace by double clicking to select every character, unlike <<name>> used in the Create GUID tool.

Installation

You can easily search for and install extensions directly within Code.

  1. Open the command palette: Ctrl+Shift+P (Cmd+Shift+P on Mac)
  2. Type: Install Extension
  3. Type: Insert GUID
  4. Press Enter or click the download button to install

Code also makes it easy to update extensions:

  1. Open the command palette: Ctrl+Shift+P
  2. Type: Show Outdated Extensions
  3. Press Enter or click the download button to install updates

Using

Whenever you want to insert a new GUID at the cursor or replace the currently selected text:

  1. Open the command palette: Ctrl+Shift+P (Cmd+Shift+P on Mac)
  2. Type: Insert GUID
  3. Press Enter and select the desired format by typing the number or using the arrow keys.

You can also skip right to step 3 using the default keyboard binding, Ctrl+Shift+[. This is more easily remembered as Ctrl+{ as with the curly brace used in the registry string format, or as Cmd+{ on the Mac.