Two simple tricks to speed development

I just wanted to post two simple keyboard tricks to speed up development when you are using the Visual Studio 2010 IDE. Both have to do with getting the information you need quickly when developing within the Source page.

First, you can easily flip from the Source page to its Code Behind file by hitting F7. You can also see the Designer page by hitting Shift+F7.

Second, you can access the Properties window of any control by placing your cursor on the control and hitting the F4 key.

I will post more navigation tricks like this in the days to come.

Surround With in C#

As I mentioned in yesterday’s article entitled Inserting snippets in C# you can also insert snippets around existing code. To do this you need to use the Surround With option.

These snippets can be accessed on the design page (where you will receive snippets of HTML and ASP.NET code) or from the code behind page where you can get C# snippets.

You can access these snippets in several ways:

  • Highlight the text that you want the snippet to surround, right-click and select Surround With
  • Highlight the text that you want the snippet to surround and hit CTRL+K, CTRL+S, The same dialog box as above appears
  • Highlight the text that you want the snippet to surround and on the Menu Bar browse to Edit–>Intellisense–>Surround With

Inserting snippets in C#

In Visual Studio 2010 there are a lot of built-in snippets available to the developer. The IDE also allows you to create your own snippets but today I wanted to talk about accessing the built-in ones.

Microsoft provides you with snippets which are pre-written pieces of code that developers tend to use on a regular basis and when dropped in can save you time. Some are just placeholders that you have to modify (like the #region snippet) whereas others act as wrappers of code (like the try-catch block)

Snippets can be accessed on the design page (where you will receive snippets of HTML and ASP.NET code) or from the code behind page where you can get C# snippets along with snippets for developing tests and for working with Microsoft Office products.

You can access these snippets in several ways:

  • Set the cursor on the page where you want the snippet, right-click and select Insert Snippet
  • Set the cursor on the page where you want the snippet and hit CTRL+K, CTRL+X, The same dialog box as above appears.
  • Set the cursor on the page where you want the snippet and on the Menu Bar browse to Edit–>Intellisense–>Insert Snippet
  • Set the cursor on the page where you want the snippet and type the name of the snippet you want (eg #region) and hit the Tab key to get the snippet

 Microsoft also offers the Surround With option which I will explore in another post.

Visual Studio 2010 Shortcut Keys

In his excellent book The Productive Programmer author Neal Ford talks about the importance of using the keyboard for most of your coding. He says that always reverting to the mouse will lessen your effectiveness as you can get more done by simple typing.

He also recommends that everyone learn the basic IDE keyboard shortcut commands that we use everyday as a way to speed up this process. This seems like common sense once you read it but many of us reach for the mouse to scan the tool bar for a daily command when we should really be committing it to memory.

I have started to write down the shortcut keys and tips that I am seeing in the articles and books I am reading on Visual Studio 2010 and specifically ASP.NET 4. My goal is to memorize these simple commands and I think by blogging about them I will do just that. I have created a new post tag called Shortcuts that I will associate this and future blog articles on tips under.

If you are looking to get started immediately, look at this list created by Microsoft: Visual Studio 2010 Keybinding Posters It contains all of the reference posters for the default keybindings in Visual Studio 2010 for Visual Basic, Visual C#, Visual C++ and Visual F#.

Follow

Get every new post delivered to your Inbox.