How to: Search for Code Snippets Online
Visual Studio provides sample code snippets for some languages. If these snippets do not meet your needs, you can search for additional snippets online for use in Visual Studio. Once you have located and downloaded a codes snippet, you must install the code snippet before it can be used in Visual Studio.
Note
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.
Search for online code snippets
You can search for online snippets by keyword. Once you have located the snippet you intend to use, you can read additional information about the code snippet and decide whether or not to download it.
Security Note: |
---|
Before you use a downloaded code snippet, determine the trustworthiness of the code outside of Visual Studio. Building, debugging, and running projects in Visual Studio that include the code snippet automatically executes code on your local machine in the trusted process of devenv.exe. For more information, see Security Considerations in Using Snippets. |
To search for code snippets online
On the Tools menu, choose Code Snippets Manager.
In the Code Snippets Manager dialog box, click Search Online.
The Search page of Help appears, with the Code Snippets option selected for the Topic Type filter.
In the text box, enter a keyword or name for the type of code snippet you are searching for and then click Search.
Matches are grouped by source and are displayed in the Search Results area.
Click on a result to display additional information, including how to download the snippet.
Install downloaded Code Snippets
Once you have located a code snippet, you must install the code snippet so that it appears in the Code Snippet Manager dialog box as well as in Insert Snippet in the editor.
To install code snippets downloaded from the Web
On the Web page for the code snippet, click the link to download the snippet.
Click Open to download and install the code snippet at the same time.
The Visual Studio Content Installer wizard appears.
On the Welcome to the Visual Studio Content Installer Wizard page, select the items you intend to install and then choose Next.
Security Note: It is highly recommended that you read the information in Publisher Status to determine whether or not the control is signed. For further security, click View Files in Windows Explorer to display a list of the files that will be installed on your computer. For more information, see Security Considerations in Using Snippets.
The CodeSnippet Directory Selection page appears.
In Installation location, for each snippet specify the language and category that you want the snippet to appear in for the Code Snippet Manager dialog box.
Click Finish.
The Installing Content page appears.
On the Installation Complete page, click Close
For information on how to include snippets in your code, see How to: Insert IntelliSense Code Snippets.
See Also
Concepts
Security Considerations in Using Snippets