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.
- 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.