How to: Use Code Snippets (C#)
The following procedures describe how to use code snippets. Code snippets are available in two ways: through the snippet’s shortcut or through the Insert Code Snippet menu.
To use code snippets through the Insert Code Snippet Menu
In the Visual Studio integrated development environment (IDE), open the file that you want to edit.
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:
Press CTRL+K, CTRL+X.
On the Edit menu, point to IntelliSense, and then click Insert Snippet.
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.
Alternatively, you can type the name of the code snippet, and then press TAB or ENTER.
To use code snippets through the snippet’s shortcut
In the Visual Studio IDE, open the file that you intend to change.
In the Code Editor, put the cursor where you want to insert the code snippet.
Type the shortcut for the code snippet that you want to add to your code.
OR –
Press CTRL+SPACE to view the completion list and then select the snippet shortcut from the list.
Press TAB, TAB to invoke the code snippet.
Note
This procedure can only invoke snippets that have non-null Shortcut Element (IntelliSense Code Snippets). To view a snippet's shortcut element in the Code Snippets Manager, click Code Snippets Manager on the Tools menu.
See Also
Tasks
How to: Use Surround-with Code Snippets
Concepts
Code Snippets Schema Reference