How to: Insert Code Snippets (Visual J# Express) 

You can insert IntelliSense code snippets using the navigation tools in the Code Editor or by dragging files from Windows Explorer. When you know the name of the snippet you want to insert, you can do so by typing its shortcut. When you need to browse for an appropriate snippet, you can use the snippet picker, which gives you categorized lists of snippets to choose from.

There are three ways to insert code snippets. You can insert them using the IntelliSense menu, type a shortcut, or drag them from Windows Explorer. The following procedures show you how to insert IntelliSense code snippets.

To insert a snippet by browsing in the Code Editor

  1. Right-click the Code Editor where you want to insert the code, and on the shortcut menu, click Insert Snippet.

  2. On the snippet picker, navigate to the task of your choice and click it.

    The snippet code inserts into your code. Once you add the snippet into your code, you can use the Code Editor to customize it. For example you can replace variable names with more appropriate names.

To insert a snippet when you know its shortcut

  • Type the shortcut for the snippet in the Code Editor followed by TAB. The snippet will be inserted.

    -or-

  • Type the first few characters of the shortcut for the snippet in the Code Editor, followed by a TAB. A picker will appear with the list of snippets whose shortcuts begin with the characters you typed.

To insert a snippet into your code using Windows Explorer

  1. Open Windows Explorer.

  2. Navigate in Windows Explorer to the folder that contains the file you want to insert. If you choose the default location for the installation of Visual Studio 2005, the snippets are stored in C:\Program Files\Microsoft Visual Studio 8\V C:\Program Files\Microsoft Visual Studio 8\VJ#\Expansions\.

  3. Drag the file from Windows Explorer to the place in your code where you want to insert it.

See Also

Tasks

How to: Enter Code in Visual J# Express