Wednesday, December 31, 2008

If You Only Learn Two VS Shortcuts

As noted in a previous post, as much as I'd like to be, I'm just not a keyboard junkie.  I feel faster pointing-and-clicking than remembering-and-typing.  In that post, Ctrl + . was the shortcut du-jour. Press that anytime VS prompts for autocompletion, and watch the magic.  That's cool, but since then, I've I have mastered another keyboard shortcut in VS that has saved me a bunch of time.  Install Resharper and witness the power of:

Alt + Enter

CropperCapture[2]Think of this as Ctrl + . on steroids.  With Resharper installed, you'll get nice notifications of all sorts of common coding mistakes, recommendations, and best practices.  Any time you're on one, press Alt + Enter to fix it.

JetBrains clearly thought this feature through, and I've found that most of the time the suggestions are right on the money.  When they're not, you can change them in the addin's options, or make one-time exceptions in your code.  In addition to autocompletion, this same pattern can rename a file to match the class name, copy classes to separate files, switch member accessibility, and much more.


Resharper does a ton more, but another favorite- and the reason I chose it over other, cheaper refactoring tools is the code health indicator it adds to the IDE.  It shows quickly if there are any errors (red) or suggestions (yellow), or if your code is perfect (green).  The small yellow lines you see jump directly to the problem code.  Which brings up another set of keys I use fairly frequently now:

Alt PgUp and Alt PgDn

These navigate between the yellow or red lines on the indicator.  So, to fix up a code file, you have only to press Alt PgDn, Alt Enter a few times.