Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops. Juri is also a recognized Google Developer Expert in Web Technologies

Boost your productivity using shortcuts in Visual Studio

4 min read

A major aim of everyone is (or should be) to increase his personal productivity. Now productivity is a vast term actually. It can be related to individual programming productivity focusing on code quality problems but it can also be related to management issues and so on.

This post targets the individual human-computer-interaction topics, more specifically on how you interact with your Visual Studio IDE during development. Personally what I don't like is when I have to use the mouse. Yes, I'm a keyboard fanatic ;) , just use your mouse if you have no other possibilities. Mouse interactions cost time! Take for instance the following situation:
You're currently going over some code in your editor, you see a line which looks suspicious and really shouldn't be there. Your approach: comment the line and launch the app to check it. I assume your hands are on the keyboard (as they should be ;) )
Mouse interaction:
  1. Move your hand (right/left depending on your orientation) from your keyboard to the mouse.
  2. Move the mouse pointer up to point to the right symbol on the toolbar for commenting out the current line (ensure you have the focus on that line, otherwise you have to position it first)
  3. Click the toolbar button for commenting that line of code (hopefully you hit it correctly, otherwise the steps will increase for the according undo operation)
  4. Move your mouse pointer to the save button (let's save explicitly)
  5. Click the save button (again, hopefully you hit it correctly)
  6. Move your mouse pointer to the toolbar button for launching the app
  7. Click the toolbar button for launching the app.
These are 7 steps. Now let's take a look at the keyboard interaction. Again, I assume the hands are on the keyboard, and the cursor blinks at the line which we want to comment out:
  1. Press Ctrl + K,C (on VS2008).
  2. Press Ctrl + S (to save explicitly)
  3. Press F5 to launch in debug mode or Ctrl + F5 to launch without debugging.
That's it. Pretty simple, huh? Now imagine how much faster I am by using these simple keyboard shortcuts. While you are on the way to the save button with your mouse, I'm probably already waiting for my app to launch. Of course the example above is a really simple one, but adding these things up, you save quite a lot of time. Or another example, I always again get goosebumps (do you call them like this?) when I see devs formatting their code by manually pressing the Tab key instead of just writing it down followed by a quick Ctrl + K,D (for auto-formatting) and a Ctrl + S (for saving).

Below there is a small list of the top shortcuts I'm using in my everyday working with Visual Studio. I tried to just pick the most frequently used and unfortunately they're taken to my working experience related to VS2008. Most of them should work with VS2010 too, however. I'll update the list  below as I find more useful ones.

Simple keyboard text navigation shortcuts (work in most text editors)
Ctrl + (Arrow left/right)
Quickly jump from word to word. Combine this with Shift (see below).

Shift + (above mentioned shortcuts)
Select the text.

Pos 1 and End
These are quite useful for quickly jumping to the beginning/end of line. Try combining them with Shift for selecting whole rows, like Shift (right) + End.

Ctrl + (Arrow up/down)
Scroll the code editor without moving the cursor.

Predefined VS2008 Shortcuts
F5 or Ctrl + F5
First to launch in debug, second to launch the app without debugging.

Alt + Shift + F10
Open the suggestion context menu which appears beneath code statements, i.e. for implementing an interface, creating a method which doesn't exist but is referenced and so on.

Ctrl + - / Ctrl + Shift + -
This allows you to navigate back and forth in your cursor position history. This is veeery useful. Try it out.

Ctrl + Tab / Ctrl + Shift + Tab
Easy, for navigating among the open code editor windows.

Ctrl + Shift + B
Start a build.

Ctrl + K, D
Auto-formats your code.

Ctrl + R,R
Refactor > Rename.

Ctrl + K, C
Comment out code.

Ctrl + K, U
Un-comment a commented code part.

Custom defined VS2008 Shortcuts
Ctrl + W
Close the active code editor window. This is a must to quickly navigate.

Ctrl + R, S (combined shortcut)
Rebuild the entire solution. Scrolling up the Solution Explorer and right-clicking on that solution icon takes just too much time :)
Questions? Thoughts? Hit me up on Twitter
comments powered by Disqus