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.

374 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 →

    Hi Supporters for this suggestion

    I’m pleased to report that there’s a free new extension by my colleague Justin Clareburt that provides what you’re asking for, along with a host of other useful commands:

    https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.HotCommandsforVisualStudio

    Please check it out and review.

    Mark Wilson-Thomas
    Program Manager, Visual Studio IDE Team

    30 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...
      • anonanon commented  ·   ·  Flag as inappropriate

        Why would this help? How much time does it take to press Ctrl-K-C??? Like 200 milliseconds.

      • Zhengzhong ZhangZhengzhong Zhang commented  ·   ·  Flag as inappropriate

        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)

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

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

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

      ← Previous 1

      Feedback and Knowledge Base