Microsoft provides a simple how-to on adding a script to the code editor at http://msdn.microsoft.com/en-us/library/aa676080.aspx. In the following sections, we will create some scripts that save us time while writing code.
To add an editor script, we modify the EditorScripts
class. Looking at the classDeclaration
, we see this comment:
// This is a framework class. Customizing this class may cause problems with future upgrades to the software.
In this case, the warning means that Microsoft may change this class or the technology in future versions, and this is likely given the direction they are going in with rationalizing development tools. We will therefore proceed under the knowledge that we may need to remove this code when upgrading to the next release.
The scripts context menu is opened while in the code editor, using the scripts icon or by selecting Scripts from the right-click menu. This is shown here:
Now look at the methods in the EditorScripts
class. You can see from the following screenshot that the method name actually creates this menu structure: