Visual Studio 2008 default keyboard shortcuts and customisation

There is an old “saying” in the world of software development that you should learn to “use a single text editor well” in order to obtain maximum efficiency [see The Pragmatic Programmer]. In the case of Microsoft development the only real choice is Visual Studio and that’s what I’ve focused my energy on the last couple of months.

I have forced myself to find, use and hopefully remember keyboard shortcuts for Visual Studio 2008. On my project I’m in the process of getting familiar with some legacy code so my focus has been on things that help me understand and view code. There are a lot of shortcuts in Visual Studio 2008, but here are a few I find myself using a bit:

Comments:

  • Comment code: ‘Ctrl’+’K’, ‘Ctrl’+’C’
  • Uncomment code: ‘Ctrl’+’K’, ‘Ctrl’+’U’

Bookmarks:

  • Set/unset bookmark on line: ‘Ctrl’+’K’, ‘Ctrl’+’K’
  • Go to next bookmark: ‘Ctrl’+’K’, ‘Ctrl’+’N’
  • Go to previous bookmark: ‘Ctrl’+’K’, ‘Ctrl’+’P’

Navigation:

  • Navigate backward: ‘Ctrl’+’-‘
  • Navigate forward: ‘Ctrl’+’Shift’+’-‘
  • Go to line: ‘Ctrl’+’G’
  • Go to definition: ‘F12’
  • Go to declaration: ‘Ctrl’+’F12’
  • Find all references: ‘Shift’+’F12’
  • Find symbol: ‘Alt’+’F12’

Collapsing/Expanding code regions:

  • Expand all regions: ‘Ctrl’+’M’, ‘Ctrl’+’L’
  • Collapse all regions: ‘Ctrl’+’M’, ‘Ctrl’+’O’
  • Collapse / Expand current region: ‘Ctrl’+’M’, ‘Ctrl’+’M’

Breakpoints:

  • Set/unset breakpoint: ‘F9’
  • Enable/disable breakpoint: ‘Ctrl’+’F9’
  • Show breakpoints window: ‘Ctrl’+’Alt’+’B’

stepping through code:

  • Step over: ‘F10’
  • Step into: ‘F11’
  • Step out: ‘Shift’+’F11’
  • Run to cursor: ‘Ctrl’+’F10’

I’m not sure if these are global shortcuts for Visual Studio 2008 IDE irrespective of development language, but they work for me when coding ASP.NET using C#.

You can also download a nice pdf for the Microsoft Visual C# default keybindings here. However, I didn’t get all of them to work “out of the box”.

Customising the editors keybindings

If the default keybindings aren’t covering your needs then you can customise the editor to your own. The “Tools | customize” menu will open the customize dialog box which in turn let’s you customise the default keybindings.

I found myself building my project often, but found no default keybinding for it apart from the one which applied to the full solution which was too much in my case. According to the pdf mentioned above the ‘Shift’+’F6’ keybinding should have done this, but in my case it wasn’t assigned. The screenshot below illustrates what I did to set it to adhere to my needs.

The cusomize keyboard options

Advertisements

Using WinMerge in Microsoft Visual Studio 2008

As a newcomer to Visual Studio 2008 I am not impressed by the file comparison tools used by default in the IDE (a part of Team Foundation Server, I think). I have always reverted to WinMerge as my tool of choice for comparing text files. Today I came across a great little utility named Visual Studio Comparison Tools that lets me use WinMerge directly from Visual Studio. Well… not directly – but it starts WinMerge as an external tool and supplies the selected IDE files as arguments. The screenshot shows the tool in action from the IDE’s solution explorer.

A screenshot illustrating how text files can be compared using WinMerge from within the Visual Studio 2008 IDE

You need to have WinMerge installed in the default location (C:\Program Files\WinMerge) for it to work.

Missing build configuration dropdown in Visual Studio 2008

My project is using Microsoft Visual Studio 2008 for development. For some strange reason the build configuration dropdown does not show up by default in the IDE.

A screenshot of the build configuration dropdown present in the IDE

I found the following procedure online and very helpful. It describes how to get this useful dropdown visible:

  1. In Visual Studio 2008, click “Tools” -> “Options”
  2. Under “Projects and Solutions” -> “General”, check “Show advanced build options”, and click “OK”
  3. Right click anywhere in the blank space of the toolbar and click “Customize…”
  4. In “Commands” tab, select “Build” in “Categories”.
  5. Scroll the right listbox to the bottom and drag “Solution Configurations” to the toolbar

I really can’t take credit for creating this procedure since I found it somewhere else on the web, but I had a lot of trouble re-finding the original posting in my browser history when the dropdown suddenly disappeared from my IDE today. The original posting is located found here.