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:
- Move your hand (right/left depending on your orientation) from your keyboard to the mouse.
- 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)
- 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)
- Move your mouse pointer to the save button (let's save explicitly)
- Click the save button (again, hopefully you hit it correctly)
- Move your mouse pointer to the toolbar button for launching the app
- Click the toolbar button for launching the app.
Predefined VS2008 ShortcutsF5 or Ctrl + F5
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:
- Press Ctrl + K,C (on VS2008).
- Press Ctrl + S (to save explicitly)
- 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
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.
+ (Arrow up/down)
Scroll the code editor without moving the cursor.
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
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 +
Comment out code.Ctrl + K, U
Un-comment a commented code part.Custom
defined VS2008 ShortcutsCtrl + W
Close the active code editor window. This is a must
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 :)