Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Christopher Bennage

Our WPF book is now available!


My Favorite Keyboard Shortcuts

I'm such a wannabe ReSharper padawan. My motivation is good though: I want to be more productive.  On a recent project, I was writing some code in front of a client employee, a novice developer himself, and he exclaimed "The code is just writing itself." 

I learned a long time ago that I could impress my clients by navigating without the mouse, more recently I learned that I could get more work done without it.

Enough talk, here is my current set of favorite keyboard shortcuts.  Some are ReSharper (R#) and some are Visual Studio (VS).

VS Ctrl+K,C Comment out a block of code
VS Ctrl+K,U Uncomment a block
VS Ctrl+K,D Format your code, I prefer R#'s version but this is handy for XML.
R# Ctrl+Shift+R Presents a context-sensitive menu for refactoring.  This is a must for newbie ReSharper padawans.
R# Alt+Enter Another padawan must; this present recommended refactorings, e.Shiftg. inserting a namespace, changing accessibility of a member, etc.
R# Alt+Insert The 3rd padawan must; this helps you insert "missing" code and is essential for TDD.
R# Ctrl+Alt+Shft+F It's a handful, but it reformats your code.  This can sometimes be a bit much, and can cause some unnecessary churn in source code repository. (I do it without thinking.)
VS/R# Ctr+Space Did you know that R# will even suggest variables names?  Isn't that totally sweet? Yes. Yes it is.
R# F6 Moves a class, either to a new namespace or (my favorite) to a new file.
R# Alt+F7 Find usages.
R# Ctrl+Left Click I was giddy when I discovered this.  This is equivalent to Go To Definition.
VS Ctrl+- That's the minus key.  It's like the back button in your browser, it takes you back to the last file you were editing.  This is incredibly useful when you are writing a test, you insert a member into the class under test, and you want to jump back to the test.  w00t!


Comments

sotto said:

Hey, thanks for posting. not having R# ... (not event tried the trial version, cause then i'm sure i won't live without anymore), I see myself also often using : Ctrl+shift+- to return one step when you've used Ctrl+- (repeat for more steps) ***-F12 to find all references Ctrl-r, Ctrl-t to Run tests with testdriven.NET (think i've mapped these myself) ctrl+k, ctrl-s surround with (for #region) shift-F9 when debugging, mouse on a variable: for the quick watch-window and of course F5 and Ctrl-F5 (lol)
# October 5, 2007 5:02 AM

James Gregory said:

One that I can't live without is Alt+` (that's left of the 1), which brings up a context menu for Goto Definition, Usages, Inheritor etc... Great stuff! I feel lost without Resharper.
# October 5, 2007 6:12 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# October 5, 2007 6:14 AM

Joe said:

A couple that I use constantly besides the ones you've mentioned: ctrl+alt+f to bring up the class browser - then start typing the method name, and hit enter to go to it alt+r, n, c - to add a new class and shift+alt+l to get me to the file in solution explorer.
# October 5, 2007 9:57 AM

Jason Meridth said:

ReSharper: Ctrl + / = comment/uncomment code Ctrl + B = go to Ctrl + Shift + F7 = show usages in current file (once highlighted use Alt + Up/Down to move through the highlighted items) Ctrl + U = Go to base Ctrl + Alt + B = show inheritors I use these daily.
# October 5, 2007 11:52 AM

Christopher Bennage said:

Very cool.  Maybe we should have a shortcut wiki.  :-)

# October 5, 2007 12:35 PM

Keith Nicholas said:

more padwin commands

R#   Ctrl-N -  Allows you to type in the type...  can do it title case too so if you have   TheCoolAssClass   type TCAC   and it will get it.... in fact you'd probablly only have to type TC before it matches it...

R#  Cntrl-Shift-N   Same thing again but for file names.  Works with C++ projects also

R#  Cntrl-F12  same again but for methods in a file.... only difference is by default it does a drop down of all the methods straight away

These are really useful for whizzing arouns the place, especially with the find base and find inheritor stuff.

So now you can whizz around the place you want to get solution explorer to catch up with you  SHIFT-ALT-L

now your a keyboard junkie, why the hell waste your screen space with these GUI things?   be a man (or woman) and hit SHIFT-ALT-ENTER

Another super cool and powerful command

R#   -   CNTRL-D     Copies the current like down one and moves the cursor down also, and keeps the cursor in the same column position.   Most Excellent!

# October 7, 2007 4:32 PM

Chris Brandsma said:

Quick way to comment with ReSharper: Ctrl+/ Quick way to uncomment with ReSharper: Ctrl+/ And my favorite Visual Studio command: Ctrl+M+Ctrl+M That toggles code between expanded and collapsed mode. (I have some co-workers that love to collapse code).
# October 8, 2007 11:27 AM

Emad said:

I can't live without shortcuts.  I actually love them so much I created a site just for them at http://www.kbshortcuts.com

The site was recently featured on Microsoft AJAX website.

# October 8, 2007 3:26 PM

Christopher Bennage said:

Ooo, that reminds me.  I use Ctrl+X and Ctrl+C and Ctrl+V to cut entire lines.  I sometimes do this just clean up.  Just hit the command on a line without selecting any text.  (I think this one is R#).

# October 8, 2007 11:41 PM

About Christopher Bennage

Christopher is a software developer and consultant at Blue Spire Consulting, a company he co-founded with Rob Eisenberg in 2006. He is a Christian, a marginal musician, and an armchair philosopher. His interests include programming, liberal education, science, truth, beauty, and a number of deceased British authors (C. S. Lewis, G. K. Chesterton, and most recently Owen Barfield.) He lives in Tallahassee, FL with his wife and three children and still prefers to play as the Night Elves in WarCraft 3. Check out Devlicio.us!

Our Sponsors

Red-Gate!