Soatl
Soatl

Reputation: 10592

How to uncomment multiple lines of code in Visual Studio

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?

Upvotes: 71

Views: 176694

Answers (17)

Muhamed Ajdinoski
Muhamed Ajdinoski

Reputation: 1

  1. Select multiple lines of code that You want to uncomment
  2. Press and don`t release CTRL
  3. Press and release K
  4. Press and release U

Upvotes: 0

Dev Reborn
Dev Reborn

Reputation: 44

On MacOS you can Command + / to comment and uncomment.

Upvotes: 0

Dave
Dave

Reputation: 103

Windows: Shift+Alt+A is a toggle. Simply choose your lines of code you want to comment out then Shift+Alt+A, then simply choose your lines of code you want uncomment and then Shift+Alt+A.

Upvotes: -1

fisio
fisio

Reputation: 554

italian keyboard uncomment: Ctrl + ù

Upvotes: 0

TKTS
TKTS

Reputation: 1261

Ctrl + K, Ctrl + U.

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

Upvotes: 7

Oded
Oded

Reputation: 498914

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

Upvotes: 26

shaik salman ahmed
shaik salman ahmed

Reputation: 59

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

Upvotes: 5

Herrand Voller
Herrand Voller

Reputation: 21

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

Upvotes: 1

grigy
grigy

Reputation: 6826

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

Upvotes: 0

Aman Singh
Aman Singh

Reputation: 385

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

Or

or use Ctrl + / (for the same)

Upvotes: 4

ChristiaanV
ChristiaanV

Reputation: 5541

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

Upvotes: 120

usertest
usertest

Reputation: 2252

Qwerty: Ctrl + /

Azerty: Ctrl + :

Upvotes: 2

H L
H L

Reputation: 21

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

Upvotes: 0

Roscoe Moedl
Roscoe Moedl

Reputation: 11

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.

Upvotes: 1

ickydime
ickydime

Reputation: 1071

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.

Upvotes: 0

Teodor Tite
Teodor Tite

Reputation: 1955

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.

Upvotes: 3

JonnyBoats
JonnyBoats

Reputation: 5187

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

Upvotes: 3

Related Questions