Add a better shortcut for commenting and uncommenting - "CTR+/"
“CTR+K,C” for commenting “CTR+K,U” for uncommenting shortcuts are NOT useful, easier to click a button on a toolbar instead.
Every developer comment / uncomment pieces of code quite often. Please add "CTR+/" shortcut for toggling comments.
This tiny addition could save tones of working hours for developers. ReSharper has it; but it would be much better to have it as a build-in feature.
Zhengzhong Zhang commented
That's great, some ide and editor use this shortcut. It would help people switch between vs and others freely.(And it would be better if it only consider //, the "/**/" is hard to uncomment and easy to make mistake)
Toggle comment with CTR+/ is exactly what I do (I think I made custom mapping to that)
I'd also love this feature. Sublime Text Editor has it and I seems to use it a lot.
There must be a short key of an icon to comment code. Its too much difficult to select from menu.
Michael Ganesan commented
Great idea, but I can live with the current feature. Not a problem.
Fine Nguyen commented
Horrible design. Please bring back 2008
To me it's not that the original shortcuts are difficult, I just prefer all of my shortcuts to be one modifier and one non-modifier key. My setup in vs2010 had alt + q and alt + e unbound, so I use alt + q and alt + e. This may not be for everyone but being used to playing games like WoW and others with tons of keybinds I love simple left hand ones.
Jeremy Schwartz commented
Good idea/bad idea - in probably most situations it would work fine, but as Adam points out the "on-off-on" scenario breaks expectations.
As long as this is an *additional* command, not replacing the others, I think it'd be great, because then you have 3 options to rebind to your liking. Then everyone is happy.
Dave Schinkel commented
Until VS gets it right some day and improves on some shortcuts like this...get ReSharper (Ctrl + Shift + /). While it has an extra Shift key, it's MUCH quicker still and easier than the default VS shortcuts you mentioned above. You'd be surprised how such a minor difference can be so much easier on your fingers. I agree that this Ctr + K + C and the variant with the U is way too much to do a simple comment/uncomment.
I completely agree! However it could be simplified even further....
In the case of AutoIt and the scite editor, you simply press the minus (-) key from the numerical keypad to denote lines as comments.
Yes, it is mentioned, several times: "Please add "CTR+/" shortcut for toggling comments." It's also in the title - "a... shortcut for commenting *and* uncommenting" (emphasis mine.) See also Konstantin's followup comments where this was made very clear.
I addressed Adam's scenario in my earlier comment. As I said, this functionality already exists in Xcode, a competing IDE. It works fine and would be nice to see in VS. I don't think anyone's asking for the existing commands to be removed! Just a new one added as well, with distinct functionality. If you didn't want to use it, you wouldn't have to.
Ali Kouhzadi commented
Well Andrew, *toggle* is not mentioned in the suggestion, not even once. From "easier to click a button on the toolbar" I infer that the op believes that ctrl+k+c is too much for a keyboard shortcut, and an alternative in form of "a button on the toolbar" already exists.
btw, what would happen in the case that Adam mentioned? I might want to comment the whole block, or I might want to uncomment a few commented lines in a block: I can simply select the whole thing and use ctrl+k+u, comments will be uncommented and other lines will stay untouched; with ctrl + / which one would happen? it can't be both.
As I said in my first comment, if it is -added- to VS it surely won't hurt anyone. If it's really useful to others and it really saves "tons of working hours", I hope it gets enough vote so it gets Microsoft's attention. Personally at the moment I don't see any use to it.
I just commented under this suggestion to point out the exaggerations in the suggestion:
1) It won't save/waste tons of working hours
2) pressing one more key on your keyboard (especially in case of ctrl + k + c) is not hard at all.
And one suggestion, if this is really about *toggle* comments, you should mention it in the title. I'm sure with *toggle* in the title you can get more votes since it won't be about simply changing a shortcut anymore.
You've missed the point of the suggestion Ali - this isn't about simply changing the shortcuts, which users can already do through the options.
This suggestion is for adding a *toggle* comment command, so that the same shortcut could both comment and uncomment lines. It works well enough in Xcode so it'd be nice to see in VS. I also don't think it would be *that* big a deal, just a nice little feature that would make coding slightly more pleasant.
Ali Kouhzadi commented
Before anything I must say it doesn't hurt if it is changed to ctrl+/ I don't really care if it is changed! but I must say that I've been a VS user since VS 2008, and I have never -ever, ever- had any problems with ctrl+k+c and ctrl+k+u ! I've never even thought about "what if the shortcut was something else" for one second!!
"This tiny addition could save tones of working hours for developers"...! honestly?! with pressing one more key you waste tones of working hours?! this is called -overexaggerating- my friend!
IMHO if someone writes code for a living, he should be most comfortable with his keyboard, personally I don't find it easier to use mouse instead of the current shortcut! again I think you are exaggerating.
Having started using Xcode for iOS development I've come to appreciate Cmd+/ for toggling the commented status of code lines. It's nice to have a single shortcut that does both, and their implementation seems intuitive.
FWIW the way it works there: if there's at least one uncommented line in the selection, all lines gain a //. Otherwise all lines lose a //. It only considers // and completely ignores /**/.
Hard to say but I suppose people use ctrl+shift+/ when caught in situations like this. But what is clear is that 3 people saw the thing in 3 different ways. Which is the right one?
ctrl+k+u and ctrl+k+c are clear on their task and absolutely predictable and when used to them, it take maybe 5/100th of a second longer than a single key shortcut.
Could you repro the sample provided by Adam but this time really using ReSharper?
Konstantin Tarkus commented
@BK, how would you explain the fact that this feature in ReSharper has lots of funs and many other code editors have it as well for the same reason - usability?
Sorry but the way you describe the behaviour seems most unintuitive. In fact, simply reading your two implementation propositions make me say it is a bad idea...