5 out of 7 rated this helpful - Rate this topic

How to: Assign a Shortcut Name to a Snippet 

Shortcut names provide a way for you to insert IntelliSense Code Snippets into your code by typing a shortcut name and then pressing Tab. The shortcut name for an IntelliSense Code Snippet is changed by modifying the XML .snippet file.

To change the shortcut name for a snippet

  1. Locate the .snippet file for the snippet that you want to edit. The snippets that appear in the picker are stored as files in subfolders of specific file locations. The file locations can be examined and changed using the Code Snippets Manager.

  2. On the File menu, click Open and then click File.

  3. Click the file you want to open, and then click Open.

  4. In the editor, locate the Header element of the code snippet.

  5. Add a Shortcut element as a child of the Header element. Make the text value of the Shortcut element the shortcut name. For example, if the following code were part of a Visual Basic code snippet XML file, you would type "MyShortcut" and press Tab to insert the code snippet.

    NoteNote

    You must press Tab twice to insert Visual C# and Visual J# code snippets.

    <Shortcut>MyShortcut</Shortcut>

    NoteNote

    The text value of a Shortcut element can only contain alphanumeric characters, hyphens ( - ), and underscores ( _ ).

  6. Save the file.

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
erratum: "change" should be "assign"; VB Snippet Editor

"To change the shortcut name for a snippet" should be

"To assign the shortcut name for a snippet".

This article is about adding a shortcut element, not about changing an existing one.

For VB:

Code snippets are really easy to create with Bill McCarthy's VB Snippet Editor
http://billmccarthy.com/Projects/Snippet_Editor/ *
(source code available too, same URL) **
* http://msdn.microsoft.com/en-us/vbasic/bb973770.aspx refers to
McCarthy's URL and has a screen shot of his editor
** Note: all current builds require .NET 3.5
_______________________________________________________________________

Gerry Lowry, Principal
Ability Business Computer Services ~~ Because it's your Business, our Experience Counts!
68 John W. Taylor Avenue
Alliston · Ontario · Canada · L9R 0E1 · gerry.lowry@abilitybusinesscomputerservices.com

Advertisement