06.40 Inserting Code Snippets

DEFAULT

Ctrl+K, Ctrl+X

VISUAL BASIC 6

Ctrl+K, Ctrl+X

VISUAL C# 2005

Ctrl+K, Ctrl+X; Ctrl+K, X

VISUAL C++ 2

[no shortcut]

VISUAL C++ 6

Ctrl+K, Ctrl+X

VISUAL STUDIO 6

Ctrl+K, Ctrl+X

WINDOWS

Alt,E, I, I

MENU

Edit | IntelliSense | Insert Snippet

COMMAND

Edit.InsertSnippet

VERSIONS

2005, 2008, 2010

LANGUAGES

C#, VB

CODE

vstipEdit0051

Even though these have been around for a while, a lot of people still don’t fully understand snippets. Let’s assume you are in the editor and you want to create an if statement. You can type it out, but that would be the hard way. Why not just use a snippet? You have several ways to do this.

Tab

Just type if, and press the Tab key twice.

C#

The paper-like icon, shown in the following illustration, indicates ...

Get Coding Faster: Getting More Productive with Microsoft® Visual Studio® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.