06.41 Surround with a Code Snippet

DEFAULT

Ctrl+K, Ctrl+S

VISUAL BASIC 6

Ctrl+K, Ctrl+S

VISUAL C# 2005

Ctrl+K, Ctrl+S; Ctrl+K, S

VISUAL C++ 2

[no shortcut]

VISUAL C++ 6

Ctrl+K, Ctrl+S

VISUAL STUDIO 6

Ctrl+K, Ctrl+S

WINDOWS

Alt,E, I, S

MENU

Edit | IntelliSense | Surround With

COMMAND

Edit.SurroundWith

VERSIONS

2005, 2008, 2010

LANGUAGES

C#

CODE

vstipEdit0052

This is one that even people who know about snippets tend to forget. You can actually put a snippet around existing code, assuming you have some code selected.

Just press Ctrl+K, Ctrl+S:

image with no caption

Then type the statement you want to surround the code with. In this case, let’s use an if statement:

Press your Tab key ...

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.