Is it possible to create a code snippet or something similar to automate the process of generating and inserting GUIDs in to the text editor in Visual Studio 2012? I frequently
ReSharper allows you to insert a new guid by typing "nguid" and pressing tab.
Obviously this is a tad on the expensive side just for the ability to generate a Guid however ReSharper has many other useful features that might be worth considering.
Looks like they brought it back - in VS 2015 (I'm using the Community version) there is a Tools > Create GUID option.
You could write a Visual Studio 2012 extension to accomplish this!
If you've never written an Add-in before, this is a simple one to get you started!
Here are the steps to create this type of add-in:
Finish the wizard and implement the follow code in Exec(...)
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if (commandName == this.GetType().Namespace + ".Connect." + this.GetType().Namespace)
{
if (_applicationObject.ActiveDocument != null)
{
TextSelection objSel = (EnvDTE.TextSelection)(_applicationObject.ActiveDocument.Selection);
objSel.Insert(Guid.NewGuid().ToString());
}
handled = true;
return;
}
}
}
Build the project, and deploy AddInName.dll, AddInName.AddIn, and AddInName.xml to c:\users\username\documents\Visual Studio 2012\Addins. [If the Addins folder doesn't exist, create it]
Voila! Hotkey GUID generation and a little bit of Visual Studio Add-in know how. :)
My SCLAssist extension has this feature. You can bind the "Paste GUID" to a key mapping. SCLAssist is free.