Export (0) Print
Expand All

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# 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.

Community Additions

ADD
Show:
© 2015 Microsoft