How to quickly comment multiple lines of code in VS?

To quickly comment multiple lines of code in Visual Studio, you can use the following shortcut keys:

  1. Select the multiple lines of code that you want to comment.
  2. Pressing Ctrl + K, Ctrl + C (Ctrl + K, Ctrl + / or Ctrl + / will also work)
  3. These selected lines of code will be commented out.

You can use the following shortcut keys to uncomment multiple lines of code that have already been commented.

  1. Select the lines of code that have already been commented.
  2. Press Ctrl + K, Ctrl + U (Ctrl + K, Ctrl + / or Ctrl + / can also be used).
  3. The selected lines of code that have been commented will be uncommented.

These keyboard shortcuts are all default settings in Visual Studio and can be found and modified in the “Tools” -> “Options” -> “Environment” -> “Keyboard” section of the menu bar.

广告
Closing in 10 seconds
bannerAds