Using Code Snippets

xxkylexx edited this page Sep 28, 2012 · 2 revisions

You can insert IntelliSense Code Snippets using the Insert Code Snippet Menu or by typing the shortcut name of the snippet and pressing Tab.

How to Use Code Snippets via Snippet Shortcuts

  • In the Code Editor, put the cursor where you want to insert the code snippet.
  • Select the shortcut in one of two ways:
  1. Type the shortcut for the code snippet that you want to add to your code.
  2. Type the first few letters of the shortcut and then press either CTRL+SPACE (C#) or a question mark followed by the TAB key (VB) to view the completion list, and then select the snippet shortcut from the list.
  • Press the TAB key once for Visual Basic or twice for C Sharp to invoke the code snippet.

How to Use Code Snippets via Insert Code Snippet Menu

  • In the Code Editor, put the cursor where you want to insert the code snippet.
  • Launch the Insert Code Snippet menu in one of three ways:
  1. Press CTRL+K, CTRL+X.
  2. On the Edit menu, point to IntelliSense, and then click Insert Snippet.
  3. Right-click the mouse and then select the Insert Snippet command on the shortcut menu.
  • Select the code snippet from the code snippet inserter and then press TAB or ENTER, or double-click the snippet.