As a software developer, I strive to write a better quality code and perform it more efficiently. Arguably, the easiest productivity improvement a developer can make is to maximize a keyboard utilization for everyday tasks. Initially when I started using Visual Studio, I printed out Microsoft’s official C# shortcut poster so I could reference it when needed. Having to search through a long list of shortcuts was counterproductive. It frustrated me and decreased my productivity. Therefore, I created a short list of the top most utilized Visual C# 2008 shortcuts. I purposely did not include any shortcuts common to most windows application in order to keep the list brief and easily searchable. I am sharing the list with everyone who is tired of going through the long lists as I once was. A printable version is also available here.
- CTRL + M, O Collapses existing regions to provide a high-level view of the types and members in the source file.
- CTRL + M, M Toggles the currently selected collapsed region between the collapsed and expanded state.
- CTRL + K, C Inserts // at the beginning of the current line or every line of the current selection.
- CTRL + K, U Removes the // at the beginning of the current line or every line of the current selection.
- CTRL + K, D Formats the current document according to the indentation and code formatting settings specified on the Formatting pane under Tools | Options | Text Editor | C#.
- CTRL + K, X Displays the Code Snippet Picker. The selected code snippet will be inserted at the cursor position.
- CTRL + K, S Displays the Code Snippet Picker. The selected code snippet will be wrapped around the selected text.
- CTRL + . Displays the available options on the smart tag menu.
- CTRL + TAB Displays the IDE Navigator, with the first document window selected.
- CTRL + K, R Displays a list of all references for the symbol selected.
- CTRL + ] Moves the cursor location to the matching brace in the source file.
- F12 Navigates to the declaration for the selected symbol in code.
- CTRL + Minus sign (-) Moves to the previously browsed line of code.
- CTRL + SHIFT + Minus sign (-) Moves to the next browsed line of code.
- CTRL + SHIFT + F Displays the In Files tab of the Find and Replace dialog box.
- F5 Launches the application under the debugger based off of the settings from the startup project. When in Break mode, invoking this command will run the application until the next breakpoint.
- CTRL + F5 Launches the application without invoking the debugger.
- F11 Executes code one statement at a time, following execution into method calls.
- F10 Executes the next line of code, but does not follow execution through any method calls.
- F9 Sets or removes a breakpoint at the current line.
- SHIFT + F5 Stops running the current application under the debugger.
- F6 Builds all the projects in the solution.
- SHIFT + F6 Builds the selected project and its dependencies.
Visual Studio allows keyboard shortcut mapping. This is handy if some other applications already use Visual C# shortcut keys. It is also convenient if you just prefer to use other key combination. In order to modify existing default mapping or create a new one, go to Tools | Options | Environment | Keyboard. There you can choose from a large list of operations and assign custom keyboard shortcuts to them.
I keep the shortcut poster updated by removing the shortcuts I know, and adding the new ones I would like to learn. It is a never-ending process, which constantly improves my efficiency.
What shortcuts do you find most useful? Do you keep a reference sheet? Please share your experience in the comments.
Catching bad data early improves code quality. Next week in “Validating method arguments” I will share my experience concerning argument validation.