Use Ctrl-K Ctrl-C to comment selection and Ctrl-K Ctrl-U to uncomment selection
This tip will work for both Visual Studio .NET 2003 and Visual Studio 2005.
I use this feature all the time. These commands will comment / uncomment the current line if there is no selection.
Based on the feedback and comments, it seems that people like tips about keyboard shortcuts, so I’ll keep the keyboard shortcut tips coming.
Happy Editing!
Comments
- Anonymous
March 28, 2005
The comment has been removed - Anonymous
March 28, 2005
I prefer single key shortcuts for things I do all the time, like this. So, I've customized the "Comment" and "Uncomment" buttons in my toolbar. Give them a title of "&Comment" and "&Uncomment", and make sure to specify "Show Image And Text" for each of these buttons.
Once you've done that, you can use "Alt-C" to comment out a code chunk, and use "Alt-U" to uncomment a code chunk.
The problem that you run into, though, is when you have a plugin like CodeSmart loaded, which will override the Alt-C to show CodeSmart's menu. - Anonymous
March 28, 2005
Derick: how is Alt + C a "single-key shortcut"? There's not a whole lot of difference between Alt + C and Ctrl + K. - Anonymous
March 28, 2005
I agree with derick. While having a shortcut to commenting and uncommenting is great, i don't like the defaults at all.
The first things I do when setting up a new VS instance is map commenting to F4 and uncommenting to shift-F4 - Anonymous
March 28, 2005
The comment has been removed - Anonymous
March 28, 2005
Why isn't there a shortcut for Build Current Project? I use it all the time to syntax check and when I don't want to recompile the whole solution because of a simple fix. I usually end up assigning ctrl+b, ctrl+b to it.. - Anonymous
December 22, 2005
Yea, yea I'm coming in a little late but I prefer Ctrl+Shift+C and Ctrl+Shift+R to match the shortcuts in Query Analyzer - Anonymous
June 28, 2006
I'm not able to use the AOL Money&Finance site for stock quotes. I would like AOL to remove the advertisement crossing the section of the AOL Money&finance stock quote area so I am able to use that area for stock quotes. - Anonymous
July 16, 2006
i didn't have the build current project either so i went to tools -> options -> environment -> keyboard i think selected visual c# as the mapping scheme and the boom shift f6 builds the current project, i love the fact that these short cuts are extremely hard to find - Anonymous
August 03, 2006
Double Ctrl-key sequences seem like a fine idea - wait a minute though, this is not a Microsoft idea, this was the way WordStar worked, where, for example, Ctrl-K introduced a load of blocK (note the K) commands. - Anonymous
August 04, 2006
OK-I AM MORE CONFUSSED THEN I WAS BEFORE----THANKS FOR NO HELP WHAT SO EVER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!