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
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. :)