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
- Suppose the file is already opened in Visual Studio Code. Select a block of code using your mouse.
- 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.
- Press Ctrl + / (slash) to comment out the block you’ve selected.
Comment out multiple lines in different positions
- 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.
- Check again whether you’ve selected them all. Tips: in each line, there will be a blinking cursor/insertion cursor.
- Press Ctrl + / (backslash) to comment out the lines you’ve selected.
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.
Ctrl+/ is not a backslash, it’s a regular slash
Thanks for the correction!
Thank you, this is at least something that works. I am actually looking for an analog of the shift-alt-A in windows, that will put a block in between /* and */, and can also be undone, have not found that unfortunately
its Shift+Alt+A