Freigeben über


VS 2003 Tip #6: Keyboard shortcuts

I'm a keyboard shortcut junkie. I love keyboard shortcuts for tasks. I've been known when speaking to devs to say stuff like “Ctrl+alt+l, Select foo.cpp, Ctrl+alt_w+1...no, hit Ctrl+alt...” instead of “ Open the solution explorer, select Foo.cpp, open a watch window...”. A while ago I saw a post where Jason Mauss asked for the keyboard shortcuts to VS.

However, there are some that I find so useful that I thought I would call them out here (note I tend to use the Visual Studio developer profile in Everett. You can change this from Help->Show Start Page and then pick the My Profile tab):

  • Word wrap. I hate scrolling across the screen to see a really long line of code. Hit Ctrl+R, Ctrl+R instead. Voila - instant word wrap. Hit it again to unwrap. This also works in the output window.
  • Copy and then cut the current line of code. Oftentimes, you want to move the current line of code you are working on a couple of lines down. Hit Ctrl+C, C. That copies the current line. Hit Ctrl+L to delete the current line of code. Move your cursor down and hit Ctrl+V. That should paste your original line of code.
  • After a build failure hit F8.  F8 takes you through your errors one by one, and highlights them in the code and puts the message in the status bar at the bottom of VS.
  • Comment and uncomment code quickly. Select your code. Hit Ctrl+K, Ctrl+C. Automatically commented. Select again. Hit Ctrl+K, Ctrl+U. Uncommented.
  • Auto formatting. Select your code, or hit Ctrl+A if you are lazy like me. Hit Ctrl+K, Ctrl+F. Code is formatted.
  • Incremental search. I live by this. Hit Ctrl+I and start typing out the word you want to find in the current file. The IDE then matches the word that you've typed. Hit Ctrl+I repeatedly to find the next occurence of that file. Hit Ctrl+Shift+I to go back.
  • Get Intellisense. Hit Ctrl+Space in your class etc, and you should get an intellisense dropdown that you can complete on.

Got a cool shortcut that you use frequently? Let me know. Spread the love.

Comments

  • Anonymous
    March 04, 2004
    The comment has been removed
  • Anonymous
    March 04, 2004
    The comment has been removed
  • Anonymous
    March 04, 2004
    The comment has been removed
  • Anonymous
    March 04, 2004
    That Ctrl-I tip has just made my day. Only a pity that Windows conventions prevent it from being on Ctrl-S, where it should be.
  • Anonymous
    March 04, 2004
    Neils comment sums up my answer exactly Michael :-)
  • Anonymous
    March 04, 2004
    The comment has been removed
  • Anonymous
    March 04, 2004
    BTW, if you want to extend keyboard friendliness to making better use of the Windows key, check out Winkey at www.winkey.com. I use this a lot. I've got shortcuts for VS, the VS cmd prompt, emacs, and a load of other apps I use regularly.

  • Anonymous
    March 04, 2004
    The comment has been removed
  • Anonymous
    March 04, 2004
    Two more that I thought were obvious, but people may not know:

    CTRL-Z => undo
    CTRL-Y => redo
  • Anonymous
    March 04, 2004
    Michael...wow, that does work! Thats pretty cool...
  • Anonymous
    March 04, 2004
    Here is a list of the shortcuts I most commonly use in VS (I know some have already been said)

    CTRL-Shift-B : Build
    F5 : Debug
    CTRL-F5 : Run without debugging
    CTRL-M, CTRL-O : Collapse to definitions
    F1 : Dynamic help (put the cursor in the middle of a function name or type, and hit F1 and it brings up the help index for that item, if it exists)
    CTRL-K, CTRL-F : Format selection
    CTRL-K, CTRL-C : Comment out selection
    CTRL-K, CTRL-U : Uncomment selection
    And of course the normal copy,cut,paste,undo,redo, find shortcuts.

  • Anonymous
    March 04, 2004
    I set Ctrl+K, Ctrl+B to build the selected file's solution.
    It's a shortcut that doesn't exist in the keyboard layout and it rules if I have one project I want to build out of a hundred.
  • Anonymous
    March 04, 2004
    Sorry, I meant the selected file's project.
  • Anonymous
    March 07, 2004
    after build failure, i use ctrl+shift+f12 to go through the errors.
    when there's a split in the code window, f6 to jump between windows.
    f4 to view properties window (f4 f4 to highlight the last property you selected).
    f7 to bring the code behind from a web page.
  • Anonymous
    March 08, 2004
    F12 for "Go To Definition" is a common one when walking through code.

    I often forget a "using" at the top of some code:

    CTRL+K, CTRL+K - set a bookmark where you are
    CTRL+HOME - go to the top of the file and add your 'using'
    CTRL+K, CTRL+N - jump back down to the bookmark you just created
  • Anonymous
    March 13, 2004
    I usually redefine Ctrl-B to build the currently project when in the Text Editor. I find that I hardly add non-default breakpoints, and I have F9 for that. Ctrl-B to build the current project (and Ctrl-R,Ctrl-B for a rebuild) is much more useful. It's good to break out of the habit of Ctrl-Shift-B'ing for everything, which can be a drag when you're working on one project in a large, slow multi-project solution.
  • Anonymous
    March 14, 2004
    Ctrl+PgUp & Ctrl + PgDown Toggle between Aspx Design View and and HTML View
  • Anonymous
    March 15, 2004
    Has anyone mapped the emacs keyboard shortcuts to VS 2003? I could do it too but just feeling lazy :)

    Thanks
  • Anonymous
    March 16, 2004
    Is there a shortcut to switch between tabs? I can't find one and but want it sooooo bad!
  • Anonymous
    March 16, 2004
    To switch between tabs hit Ctrl+Tab.
  • Anonymous
    March 19, 2004
    The comment has been removed
  • Anonymous
    March 30, 2004
    Ctrl+K, Ctrl+D to save a file.

    Oops, no, that's in WordStar. :-)

    Esc: puts the focus back in the source code when focus was in any tool window (Output, Solution Explorer, etc.)

    Does anyone else find it odd that the default keystroke to build the solution requires two modifier keys? (Ctrl+Shift+B.) Seems like such a common operation should have an easier default keystroke, like the old F7. (Sure sure I can customize it.)
  • Anonymous
    April 05, 2004
    The ones I use all the time are already covered except for maybe:

    F12 - if you have a function you want to see the source for just move the caret onto it and F12. The editor jumps to the source for the function (if it can find it). If you use it on a variable then you jump to the declaration of it.

    Ctrl+- (Ctrl+minus) - moves backwards through your cursor movements. So if you F12 onto another function, page down a couple of times and then decide you want to get back to where you were before you did the F12 you just Ctrl+- three times.

    F8 and Shift+F8 also cycle through the results of a find-in-all-files (Ctrl+Shift+F), which can be handy.
  • Anonymous
    July 12, 2004
    does anyone knows how can I add a key to a macro ?
  • Anonymous
    May 17, 2008
    PingBack from http://deandre.clearviewway.info/ctrlv2003.html