How to uncomment multiple lines of code in Visual Studio

Visual Studio

Visual Studio Problem Overview


I did a ctrl K + ctrl C (adds // to a line) on a lot of lines of code that I need uncommented. What is the quick key method to uncomment code in Visual studio?

Visual Studio Solutions


Solution 1 - Visual Studio

Ctrl+K, Ctrl+U removes the // comments

Solution 2 - Visual Studio

I believe it is Ctrl + K, Ctrl + U.

Solution 3 - Visual Studio

Ctrl + K, Ctrl + U.

There is also a button for it on the Standard toolbar.

Solution 4 - Visual Studio

If you're using Resharper, there is a much nicer alternative:

> just right Alt + / for both

By using this single shortcut, you can simply toggle between commenting/uncommenting code, without having to remember/switch between two shortcuts for each.

Solution 5 - Visual Studio

ctrl + / can be used for adding and removing comments.

Solution 6 - Visual Studio

Try + U or click the little icon on the toolbar.

Solution 7 - Visual Studio

Qwerty: Ctrl + /

Azerty: Ctrl + :

Solution 8 - Visual Studio

Ctrl + K + C (to comment) and Ctrl + k + U (to uncomment the code)

Or

or use Ctrl + / (for the same)

Solution 9 - Visual Studio

Just wanted to add, that in the latest version of VS, ctrl + u makes it caps. They instead made it a toggle command, so it is actually just ctrl + k again to make it uncommented.

Solution 10 - Visual Studio

I have the german keyboardlayout. VSCode-x64-1.52.1 To leave a comment: You have to highlight the code, then push Ctrl + # or Ctrl+K, stay at Ctrl and push C

to commen out: Ctrl + #, it toggles on/off the comment or Ctrl + K, stay at Ctrl and push U

Solution 11 - Visual Studio

Mine was a bit different. It is ctrl-shift-C to comment and ctrl-shift-alt-C to uncomment.

I am using Visual Studio Community 2017.

Solution 12 - Visual Studio

Ctrl + Q alternates between comment and uncomment. Unfortunately Ctrl K Ctrl U does not work in few environments, rather it adds instead of removing. My case on windows, using composer file I faced Ctrl K Ctrl U not working. I m using VS Code, ver 1.36.1

links to all keys short cuts: https://code.visualstudio.com/docs/getstarted/keybindings

Solution 13 - Visual Studio

In Visual C++ 2019 Ctrl + Shift + / both comments and uncomments.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSoatlView Question on Stackoverflow
Solution 1 - Visual StudioChristiaanVView Answer on Stackoverflow
Solution 2 - Visual StudioOdedView Answer on Stackoverflow
Solution 3 - Visual StudioTKTSView Answer on Stackoverflow
Solution 4 - Visual StudioTeodor TiteView Answer on Stackoverflow
Solution 5 - Visual Studioshaik salman ahmedView Answer on Stackoverflow
Solution 6 - Visual StudioJonnyBoatsView Answer on Stackoverflow
Solution 7 - Visual StudiousertestView Answer on Stackoverflow
Solution 8 - Visual StudioAman SinghView Answer on Stackoverflow
Solution 9 - Visual StudioRoscoe MoedlView Answer on Stackoverflow
Solution 10 - Visual StudioHerrand VollerView Answer on Stackoverflow
Solution 11 - Visual StudioickydimeView Answer on Stackoverflow
Solution 12 - Visual StudioH L View Answer on Stackoverflow
Solution 13 - Visual StudiogrigyView Answer on Stackoverflow