Visual Studio 2010 Productivity Tips and Tricks-Part 2: Key Shortcuts

Visual Studio 2010 Productivity Tips and Tricks-Part 2: Key Shortcuts

Ask anyone that knows me, and they will confirm that I hate the mouse.  This isn’t because I deny affection to objects that don’t look like their mammalian-named self, but rather for a much more simple and not-insane reason: I have terrible eyesight. 

Introduction

Thanks to a degenerative eye disease known as, I have learned to rely more on the keyboard which I can feel digital/static positions of keys relative to my fingers, than the much more analog/random position of the mouse.  Now, I would like to share some of the keyboard shortcuts with you now, as I believe that they not only increase my productivity, but yours as well once you know them (if you don’t already of course)...  I share one of my biggest tips for productivity in the conclusion at the end.

Visual Studio Key Shortcuts

Global Editor Shortcuts

These are shortcuts that are available from almost any application running in Windows, however are many times forgotten.


ShortcutActionVisual Studio 2010 Functionality
Ctrl + XCutThis shortcut works without a selection. If nothing is selected, the entire line that the caret is on is cut from the editor.
Ctrl + CCopyThis shortcut works without a selection. If nothing is selected, the entire line that the caret is on is copied from the editor.
Ctrl + VPasteIf you copied an entire line by the method above, the data is pasted in the line above the current caret line.
Ctrl + Shift + VNext Clipboard ElementCut/Copy multiple things, and then hit this combo repeatedly to switch to the next clipboard item when pasting.
Ctrl + BackspaceDelete PreviousWill delete the previous word from the editor directly before the caret. If anything is selected, will just delete that.
Ctrl + DelDelete Next WordWill delete the next word/space from the editor directly after the caret. If anything is selected, will just delete that.
Shift + DelDelete Focused LineWill delete the line from the editor that the caret is on. If something is selected, will just delete that.
Ctrl + ← or Ctrl + →Left/Right by WordThis will move the caret left or right by word or special character boundary. Holding Shift will also select the word.
Ctrl + FQuick FindEither the Quick Find panel, or the search bar if you have the Productivity Power Tools installed.
Ctrl + Shift + FFind in SolutionOpens up the 'Find in Files' window, allowing you to search your solution, as well as using regex for pattern matching.
F2Rename File...While not debugging, selecting a file in the solution explorer\navigator and pressing F2 allows you to rename the selected file.

Global Application Shortcuts

These are shortcuts that are available from almost any application running in Windows, however are many times forgotten... Again...


ShortcutActionVisual Studio 2010 Functionality
Ctrl + NNew File dialogOpens up the 'New File' dialog to add a new file to the current directory in the Solution\Project.
Ctrl + OOpen File dialogOpens up the 'Open File' dialog to open a file in the editor, not necessarily in the solution.
Ctrl + SSave File dialogSaves the currently focused editor tab back to your HDD/SSD.
Ctrl + Shift + SSave All...Quickly save all open/edited documents back to your disk.
Ctrl + TabSwitch Panel\TabTapping this combo switches between tabs quickly. Holding down Ctrl when hitting tab will bring up a chooser window.

Building Shortcuts

These are shortcuts that are focused on building and running a solution. These are not usable when the IDE is in Debug mode, as the shortcut changes by context.


ShortcutActionVisual Studio 2010 Functionality
Ctrl + Shift + BBuild SolutionStarts a build process on the solution according to the current build configuration manager settings.
Ctrl + BreakCancel a Building SolutionWill cancel a build operation currently in progress. Good for long running builds when you think of one last change.
F5Start DebuggingWill build the solution if needed and launch debugging according to the current configuration manager settings.
Ctrl + F5Start Without DebuggerWill build the solution if needed and launch the startup project without attaching a debugger.

Debugging Shortcuts

These are shortcuts that are used when debugging a solution.


ShortcutActionVisual Studio 2010 Functionality
F5Continue ExecutionContinues execution of code until the next breakpoint.
Ctrl + Alt + BreakPause ExecutionPauses the program execution.
Shift + F5Stop DebuggingStops the current debugging session.
NOTE: Web apps will still continue processing after stopping the debugger. Keep this in mind if working on code such as credit card processing.
Ctrl + Shift + F5Restart DebuggingStops the current debugging session and restarts the debugging session from the beginning.
F9Place BreakpointToggles/Places a breakpoint in the editor on the current line. Set a breakpoint in condensed code by highlighting the statement first.
F10Step Over StatementWhen debugging, executes all code in methods/properties on the current line until the next line.
F11Step Into StatementWhen debugging, steps into a method call so you can walk through the code executed there (if available).
Ctrl + Alt + IImmediate WindowOpen the Immediate Window to execute commands when execution is paused.

These are shortcuts that are used for navigating in the IDE or editor panel.


ShortcutActionVisual Studio 2010 Functionality
Ctrl + -Navigate BackUse this combination to navigate through what you've viewed backwards
Ctrl + Shift + -Navigate ForwardUse this combination to navigate through what you've viewed forwards (after having gone back).
F4Properties PanelOpens the properties panel for the selected item in the editor/designer/solution navigator (context driven).
F12Go to DefinitionPress F12 with the caret on a member to navigate to its declaration. With the Productivity tools, Ctrl + Click works too.
Ctrl + K Ctrl + TView Call HierarchyView the call hierarchy of the member the caret is on. Great for going through n-tier solutions and interface implementations!
Ctrl + Alt + BBreakpoint WindowView the breakpoint window to manage breakpoints and their advanced options. Allows easy toggling of breakpoints.
Ctrl + Alt + LSolution NavigatorOpen the solution explorer panel.
Ctrl + Alt + OOutput WindowView the output window to see build\general output from Visual Studio.
Ctrl + Alt + EnterLive Web PreviewOnly available with the Web Essential plugin. Launches the auto-updating Preview panel.

Testing Shortcuts

These are shortcuts that are used for running tests in the IDE. Please note, Visual Studio 2010 is all about context. If your caret is within a test method when you use one of these combinations, the combination will apply to that test. If your caret is within a test class, it will apply to that class. If the caret is outside of a test class, it will apply to all tests.


ShortcutActionVisual Studio 2010 Functionality
Ctrl + R TRun Test(s)Run all tests in the current context without a debugger attached. Breakpoints will not be stopped on.
Ctrl + R Ctrl + TRun Test(s) (Debug)Run all tests in the current context with a debugger attached. This allows you to use breakpoints.

Substitute A for T from the preceding combos to run/debug ALL tests in the current context.

Substitute Y for T from the preceding combos to run/debug ALL impacted/covering tests for a method in the current context.

Advanced Editor Shortcuts

These are shortcuts that are used for more advanced editing in the editor window.


ShortcutActionVisual Studio 2010 Functionality
Shift + Alt + ↑

Shift + Alt + ↓ | Multiline caret up/down | Use this combo to edit multiple lines at once. Not too many uses for it, but once in a blue moon one comes along. | | | | Ctrl + Alt + Enter | Insert Line Above | Inserts a blank line above the line the caret is currently on. No need to be at end or start of line, so no cutting off words/code. | | | | Ctrl + K Ctrl + C | Comment Selection | Comments the current selection out of compilation. | | | | Ctrl + K Ctrl + U | Uncomment Selection | Uncomments the current selection into compilation. | | | | Ctrl + K Ctrl + D | Format Document | Automatically formats the document into a structured layout. Lines up nodes or code into columns intelligently. | | | | Alt + ↑ Alt + ↓ | Code line up/down | *Use this combo to move a line of code up or down quickly. Great for small rearrangements of code. | | |

*Requires the Productivity Power pack from Microsoft.

Conclusion

This list is by no means meant to be exhaustive, but these are the shortcuts I use regularly every hour/minute of the day. There are still 100s more in Visual Studio that you can discover through the configuration window, or by tooltips.

Something that I started doing months ago seems to have interest in my office.. In my last post, I talked about how I hated a cluttered UI. One of the ways that I aimed to resolve that was by systematically cleaning up the toolbars week by week. First day, I removed ALL icons that I already knew shortcuts to, or would never use them (Undo in a toolbar?!). Then, every week from that point on, I make it a point to remove an icon/two from the toolbar and make an effort to remember its key combination. I gain extra space in the toolbar area, AND become more productive at the same time!

I hope that you found this article interesting or at least somewhat informative.. Maybe a shortcut or two you didn't know. I know some of them seem trivial, but I often see people going to the edit menu for Copy/Paste... Thought a refresher might be helpful!

This article is part of the GWB Archives. Original Author: ToString(theory);

New on Geeks with Blogs