My Favourite Visual Studio Key Bindings

Working with code, there are some operations that are repeated many times every day, hour or even minute. Knowing (and creating) shortcut keys for those operations not only saves time, but keeps focus on the code. Reaching for the mouse might not take much longer time, but it switches the brain over to mouse-control mode and when doing that, some of the code context kept in mind is lost.

These are my favourite key bindings, both standard and non standard.

  • Global go to file/symbol on Ctrl+,. Brings up a small search box in the current windows for quick navigation to any source file, class or method in the solution. With VS2013 this got considerable better as it no longer brings up a large dialog box.
  • Go to current file in solution explorer on Ctrl+´, S. A somewhat awkward chord, but really useful to quickly get to the current file in the solution explorer. This is also the fastest and best way to do a rename of a class. Select the file in solution explorer, hit F2 to rename the file and Visual Studio will automatically prompt you about renaming the class and all references to it.
  • When coding, I usually split the window into two vertical tab groups, to view two code files at the same time. Most of the time one is the current test case and the other is the implementation (yes I’m a TDD fan). Two custom bindings that I use a lot with the split window are Ctrl+Alt+Left and Ctrl+Alt+Right to move the active windows to the previous or the next tab group.

Did I mention that I love TDD? That means that the key bindings related to running tests are among those I use most.

Test commands

  • Ctrl+R, A runs all the tests in the current solution.
  • Ctrl+R, T runs all the tests in the current context. Place the caret in a test method and hit his chord to run the test. Place the caret in a test class, but not inside any of the test methods, to run all tests in that class.
  • Ctrl+R, Ctrl+T debugs all the tests in the current context. Typically used when a test case fails in an unexpected way. Place the caret in the failing test, hit this chord and you’re debugging the right piece of code immediately.
  • Last but not least among the test related is the custom Ctrl+§, T that I use to bring up the test explorer. Doing TDD the test explorer is of course one of the most important windows and it has to be easily accesible. The standard meaning of this binding is to bring up the task list but 1. I never use the task list and 2. It is bound to Ctrl+§, Ctrl+T too.
  • Albin Sunnanbo on 2014-07-03

    Not to forget

    • F12 – Go to definition
    • Ctrl+Q – Quick launch
    • Ctrl+E, Ctrl+D – Format Document (Ctrl+E, Ctrl+F formats only current selection)
    • Ctrl+- Navigate backwards (same as back button on mouse). Ctrl+_ navigates forwards.
    • Shift+Alt+Arrows (Alt and mouse drag works too.) – Block selection for multi line edit. Use this when you want to show of your code editing skills!

    And finally an odd one: Ctrl+Shift+V – Paste from the clipboard ring – I rarely use it since it is hard to predict what you’ll get, and not easy to navigate. If you step pass your entry you need to step through the rest of the 15 items too before you come back. But when you need to copy’n paste a pattern of a few blocks of code it is awesome!

  • Jeremy Cook on 2014-09-16

    Also, since Package Manager Console does not come with a binding I add the custom binding “Ctrl+Shift+;” to open it. Doing so, speeds up EntityFramework development, when using migrations. I also used it a lot in the days when T4Scaffolding and those things that depend on it worked well with the latest version of Visual Studio. I miss those days.

    “Ctrl+,” is fantastic!

  • Leave a Reply

    Your name as it will be displayed on the posted comment.
    Your e-mail address will not be published. It is only used if I want to get in touch during comment moderation.
    Your name will be a link to this address.
Software Development is a Job – Coding is a Passion

I'm Anders Abel, an independent systems architect and developer in Stockholm, Sweden.

profile for Anders Abel at Stack Overflow, Q&A for professional and enthusiast programmers

Code for most posts is available on my GitHub account.

Popular Posts



Powered by WordPress with the Passion for Coding theme.