I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

February 2, 2006

Smart Tags and Sane Keyboard Shortcuts

I constantly rename variables. It's probably the single most frequent refactoring activity I do. And that's why I love Visual Studio 2005's built-in Smart Tags feature.

If you're not familiar with smart tags, check out K. Scott Allen's post; he has some nice screenshots illustrating how it works. Here's a demo movie of it in action:

Smart tag rename demo movie

Unfortunately, as Scott points out, the smart tags are a pain to use via the keyboard. To maintain compatibility with Microsoft Office's implementation of smart tags, they chose the same keyboard shortcut:

Shift + Alt + F10

Go ahead. Just try to type that. I double dast dare you. It's the most psychotic keyboard shortcut ever.

If that's the best keyboard shortcut they can come up, I'll stick with mousing over the approximately 5 pixel drop-down trigger area of the smart tag. This is really unfortunate, because the keyboard shortcuts in Visual Studio are generally well thought-out and usable in my experience.

Luckily, I don't have to suffer through this bad keyboard shortcut for a frequent activity. There's an alternate shortcut defined:

Ctrl + .

But that's still not very intuitive. I prefer to use ..

Alt + Down

.. which is an excellent physical map to the conceptual activity of "dropping down" a smart tag menu. You can easily set this new keyboard shortcut up via Options, Environment, Keyboard. Search for commands containing "ShowSmartTag":

Smart Tag keyboard customization

Then just map a new global shortcut. Way better!

In general, it's safer to learn the default keyboard shortcuts for an environment-- too much customization is a self-defeating exercise. But sometimes the defaults are poorly chosen and you have no alternative but to customize them. What default keyboard shortcuts are you obliged to change in your environment, and why?

Posted by Jeff Atwood    View blog reactions
« Don't Acronymize Your Users
Keeping Private Keys Private »
Comments

I use ALT+1 and ALT+2 for View Find 1 and View Find 2 respectively.

kagevf on February 3, 2006 2:12 PM

I use F2 for renaming identifiers. It's the default hotkey used by ReSharper.

Matthijs van der Vleuten on February 3, 2006 2:17 PM

Thank you! I knew there had to be a hotkey for that function, but I could not find it. I didn't know what those smart tags were called, or the associated operation that showed them. Now I can re-map the shortcut to Alt+/ like I did for ReSharper and it's smart tag-like functionality.

As for other short cuts, I generally pretty happy with the default ones in Visual Studio. Usually it's just a matter of me knowing the shortcut, and then forcing myself to use it until it becomes habit. Generally the ones I use the most are F5, Ctrl+Shift+B, Ctrl+Shift+F9(clear breakpoints), F10, F11.

Marty Thompson on February 3, 2006 2:32 PM

"Ctrl+Alt+Knee" equivalent keystroke are really painfull for common tasks :)

AlbertD on February 3, 2006 6:10 PM

I reckon there's at least one piano player working on the VS team...

I studied the piano for about 12 years, starting from the age of 5. I think it had a positive impact on my typing abilities.

I don't find the Shift+Alt+F10 combination particularly challenging, and I suspect that's why.

So the answer is simple - study the piano intensively. And make sure you start age 5.

Failing that, now that ThinkPads reputedly have a Windows key (thanks, presumably, to IBM no longer owning them), we can start to petition for even more shift keys. Bring on Escape+Meta+Alt+Coke-bottle+Shift. (That's left coke-bottle - the full one rather than the empty one.)

Ian Griffiths on February 3, 2006 7:14 PM

Dude, use Quickeys, and the world is at your fingertips.

Products - QuicKeys for Windows - Overview
http://quickeys.com/products/qkw.html

RBLevin@RBLevin.net on February 3, 2006 7:30 PM

Get a keyboard with the function keys on the left and shift-alt-f10 is no problem to type.

Loren Pechtel on February 4, 2006 11:57 AM

if you like that, you should definitly check out the refactorings and sync edit features of Borlands developer studio product.

Cheers Tim.

Tim Jarvis on February 4, 2006 5:34 PM

I always remap File/Close in Visual Studio to be Ctrl-W. That's what it is in Firefox, Internet Explorer, Microsoft Word, and gVim, among others. If it's a tabbed windowing environment, I expect that shortcut to work.

Philip Taron on February 4, 2006 5:44 PM

Study the piano since age 5 or sit for a moment, meditate, and channel the spirit of Ian Griffiths.

I doubt there's much that Ian finds challenging. ;)

Haacked on February 6, 2006 7:50 PM

For the example mentioned above(Providing smarttags which basically asks whether the variable names should be renamed), why not the IDE just go ahead and change the instances of the variable instead of asking the user?

Krishna on February 19, 2006 11:46 PM






(no HTML)


Verification (needed to reduce spam):


Content (c) 2009 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.