Saturday, July 29, 2006

Surround With in VB.NET 2005

The Visual Studio 2005 Code Editor provides a Code Snippet Picker that allows you, in a few mouse clicks, to insert ready-made blocks of code into the active document.

The procedure to display the Code Snippet Picker varies according to the language you are using.

  • Visual Basic - Right-click at the desired location in the Code Editor to display the Shortcut menu, and select Insert Snippet.
  • Visual C# and Visual J# - Right-click at the desired location in the Code Editor to display the Shortcut menu, and click Insert Snippet or Surround With.
  • Visual C++ - The Code Snippet Picker is not available.
  • XML - Right-click at the desired location in the Code Editor to display the Shortcut menu, and click Insert Snippet or Surround With.

Right-click or press Ctrl+K, Ctrl+X and you will see this context menu.

Another way is to use shortcuts like TryC followed by the TAB key. The result is like this.

Notice that VB.NET does not have the Surround With functionality. There is a solution for this. DPack that just released version 2.5.6. One thing that first puzzled me was that Surround With that I've used a lot in VS.NET 2003 was not there. After reading the readme I found out this note: "Much more powerful surround with functionality is available in VS 2005 'out of the box'. DPack's surround with feature is left in the VS 2005 installation mainly for backward compatibility reasons." This is true if you use C# but not if you use VB. To enable this great feature I had to do it at Tools>Options>DPack.

Links:
What's New in Visual C# 2005 - Code Snippets
FAQ on Visual Basic IDE Team Blog
Coding Horror with an animated GIF

No comments:

Post a Comment

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner

Contact Us | About JTB World | Website General Terms of Use | Privacy Policy
^ Top of page

© 2004- JTB World. All rights reserved.