Skip to Main Content
Professional Visual Studio® 2008
book

Professional Visual Studio® 2008

by Nick Randolph, David Gardner
July 2008
Intermediate to advanced content levelIntermediate to advanced
1026 pages
27h 59m
English
Wrox
Content preview from Professional Visual Studio® 2008

17.1. Code Snippets Revealed

Code snippets have been around in a variety of forms for a long time but generally required third-party add-ins for languages such as Visual Basic 6 and the early versions of Visual Studio. Visual Studio 2008 includes a full-fledged code snippet feature that not only includes blocks of code, but also allows multiple sections of code to be inserted in different locations within the module. In addition, replacement variables can be defined that make it easy to customize the generated snippet.

17.1.1. Original Code Snippets

The original code snippets from previous versions of Visual Studio were simple at best. These snippets can be used to store a block of plain text that can be inserted into a code module when desired. The process to create and use them is simple as well: select a section of code and drag it over to the Toolbox. This creates an entry for it in the Toolbox with a default name equal to the first line of the code. You can rename and arrange these entries like any other element in the Toolbox. To insert the snippet you simply drag the code to the desired location in the "Code view" as shown in Figure 17-1. Alternatively, positioning the cursor where you want the snippet to be inserted, holding Shift, and clicking the snippet will place the code at the cursor location.

Figure 17.1. Figure 17-1

Many presenters used this simple technology ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Visual Studio® 2010

Professional Visual Studio® 2010

Nick Randolph, David Gardner, Michael Minutillo, Chris Anderson

Publisher Resources

ISBN: 9780470229880Purchase book