If you’re like me, I’m sorry. Oops! Er… what I mean to say is, if you’re like me, you love to be productive using your keyboard. As a developer, there’s nothing more frustrating than having to do the whole mouse-to-keyboard-to-mouse dance. The Visual Studio 2010 integrated development environment (IDE) is packed with keyboard shortcuts, what Microsoft calls “Default Key Bindings,” designed to help you do more faster without your hands having to leave the keyboard.
The default key bindings inside Visual Studio 2010 are categorized into what could best be described as workflows.
- File creation
- Window manipulation
- Code debugging/refactoring
- Building and compiling
One cool feature the Microsoft folks have provided is a web page at their Download Center, where you can download keybinding posters in Adobe .PDF format. Just for ease, I’ve uploaded two of these into our resources right here at ChurchMag. You’ll find the download links for C# and VisualBasic at the end of this article. All of the posters are full-color, printable on letter size (8.5″ × 11″) or A4, and available in both standard and high-resolution print formats. They are also broken down by the specific .NET language implementation, so whether you’re using C#, F#, VB or C++ you only have to download what’s applicable to your work!
While on the surface it might seem almost superficial, you may find considerable value in the scores of keybindings at your fingertips, some you may not have even known existed. For example, how many times have you wanted to rename a variable, method or class in a large project and thought you had to go change the instance of that wherever it’s used? Instead, highlight the variable, method or class and press Ctrl+ R+R: you’ll be presented with a window that not only allows you to perform the renaming but also provides a preview of every file and location in the program where that object is referenced or method is called. Sweet!
Or how about this one? You see a method being referenced but you’re not sure in which code file it’s located. No problem! Double-click the method and then press F12, which is the “Go to Definition” key. In a flash, Visual Studio opens the appropriate code file and takes you directly to that method definition. This also works for classes and interfaces.
One of my personal favorites is the Edit.SurroundWith command. I’ve written 15 lines of code and suddenly I think: “Gee, I should really put that code in a try-catch statement, so I can trap exceptions.” Luckily, I don’t have to type the try statement, go to the bottom of the code block and add the catch statement, repeatedly typing the opening and closing braces until my fingers are ready to fall off or the lunch bell sounds (they don’t really have a lunch bell where I work but you get my meaning). I just highlight the code block and press Ctrl+K+S. IntelliSense then allows me select the “try” statement and with a simple press of the tab key I have my try-catch statement in a single stroke.
An article was recently published in the .NET Tips and Tricks section of Visual Studio Magazine titled 4 Must-Know Visual Studio Keyboard Shortcuts. You’ll want to check it out. An Internet search on “Visual Studio shortcuts” will also point you to a score of other sites with additional tidbits. But then there’s always us right here at ChurchMag, where we’ll keep you up to date on the latest and greatest. Happy coding!