I suggest you ...

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.

205 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Konstantin TarkusKonstantin Tarkus shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    29 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • AlvisAlvis commented  ·   ·  Flag as inappropriate

        Toggle comment with CTR+/ is exactly what I do (I think I made custom mapping to that)

      • Anonymous commented  ·   ·  Flag as inappropriate

        I'd also love this feature. Sublime Text Editor has it and I seems to use it a lot.

      • rafayrafay commented  ·   ·  Flag as inappropriate

        There must be a short key of an icon to comment code. Its too much difficult to select from menu.

      • JoshJosh commented  ·   ·  Flag as inappropriate

        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 SchwartzJeremy Schwartz commented  ·   ·  Flag as inappropriate

        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 SchinkelDave Schinkel commented  ·   ·  Flag as inappropriate

        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.

      • ColynColyn commented  ·   ·  Flag as inappropriate

        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.

      • Andrew McDonaldAndrew McDonald commented  ·   ·  Flag as inappropriate

        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 KouhzadiAli Kouhzadi commented  ·   ·  Flag as inappropriate

        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.

      • Andrew McDonaldAndrew McDonald commented  ·   ·  Flag as inappropriate

        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 KouhzadiAli Kouhzadi commented  ·   ·  Flag as inappropriate

        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.

      • Andrew McDonaldAndrew McDonald commented  ·   ·  Flag as inappropriate

        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 /**/.

      • BKBK commented  ·   ·  Flag as inappropriate

        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 TarkusKonstantin Tarkus commented  ·   ·  Flag as inappropriate

        @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?

      • BKBK commented  ·   ·  Flag as inappropriate

        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...

      • Konstantin TarkusKonstantin Tarkus commented  ·   ·  Flag as inappropriate

        @Adam, I don't think toggling comments functionality works the way you described, rather it works like this - if there are any comment in a selected block they are removed, if not, the block is commented out.

      ← Previous 1

      Feedback and Knowledge Base