Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I make CTRL + / toggle a comment in Visual Studio, as it does with XCode and Eclipse?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

You can't make it toggle without going into either a macro or other VS extension.

However, I always setup VS to comment with Ctrl + / and uncomment to Ctrl + Shift + /

You can customize the keyboard shortcuts by going int the "Tools" menu and selecting "Options". Then select "Keyboard" from the "Environment" branch. From there you can bind the Edit.CommentSelection and Edit.UncommentSelection commands to whichever keyboard shortcuts you'd like.

share|improve this answer

If you have ReSharper installed (and using VS without it is/was tedious), you can assign a single key to the command ReSharper.ReSharper_LineComment.

For instance, I bind the keyboard shortcut Ctrl-K, Ctrl-C to the command, and then if I use it on a line that is uncommented, it comments it, and if the line is commented, it will uncomment it.

enter image description here

share|improve this answer

Ctrl-K and Ctrl-C will comment one or more selected lines.

Ctrl-K and Ctrl-U will uncomment one or more selected lines.

You can get toolbar icons that will do this by adding the "Text Editor" toolbar. In the toolbar area right-click and select "Text Editor" This will add a strip of icon buttons like this:

enter image description here

You can customize this strip by selecting the dropdown at the end of the ribbon:

enter image description here

To edit the keyboard combination go to Tools-Options and select Keyboard under the Environment tree. Here you can change the keys used to trigger the Comment and Uncomment actions:

enter image description here

share|improve this answer
    
In a default install this shortcut will just comment, not uncomment. –  heavyd Feb 14 '13 at 16:28
    
Clarified key combinations –  Brad Patton Feb 14 '13 at 16:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.