How to comment out multiple lines in Visual Studio Code

Do you want to know how to comment out multiple lines in Visual Studio Code?

Visual Studio Code is undeniably the most popular free code editor. Microsoft must have put so much hard work on it to win a healthy 14 million active developers, after only been released publicly for six years.

VSCode is free, nimble, modern and offers numerous useful features. Sure, the Electron core of it can take up a significant amount of system resources working with complex projects, but overall, VSCode has became the home to different kinds of developer personas.

This article is going to show you how to use a nifty little feature that will speed up your coding speed significantly : comment out multiple lines.

Comment out a block of code

  1. Suppose the file is already opened in Visual Studio Code. Select a block of code using your mouse.image-20210521105623012
  2. You can quickly select a long block by first collapsing it using the little arrow button next to the line number, then select from the beginning to the end of block.image-20210521105816864
  3. Press Ctrl + / (backslash) to comment out the block you've selected.image-20210521105851864

Comment out multiple lines in different positions

  1. Suppose the file is already opened in Visual Studio Code. Select the lines that you want to comment by holding Alt and click anywhere inside that line. To me personally, clicking the blank space right next to where the line ends seems to be easier than clicking in the middle of the line.
  2. Check again whether you've selected them all. Tips: in each line, there will be a blinking cursor/insertion cursor.image-20210521110107304
  3. Press Ctrl + / (backslash) to comment out the lines you've selected.image-20210521110243730

Conclusion

We hope that you've learned how to comment out multiple lines in Visual Studio Code. This code editor can do so much more than that. We've covered How to automatically indent your code in Visual Studio Code as well as Editing files remotely through SFTP in VSCode. These are a few of many useful features in VSCode that may help you speeding up your coding experience and have better productivity in working hours.

Click to rate this post!
[Total: 1 Average: 5]

Leave a Comment