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

One thought on “Visual Studio 2008 default keyboard shortcuts and customisation

  1. I Would really advice you to use Resharper when working with Visual Studio! You can download and test a 30 day fully functional free trial version.
    Resharper can either use its own set of keyboard shortcuts or use Visual Studios own shortcuts.

    Especially when working with legacy code there is a very big advantage by using Resharper.

    Pål.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s