How to Comment out Multiple Lines of Code in Visual Studio Code

preview_player
Показать описание
How to comment out any type of code in Visual Studio Code including HTML, CSS, JavaScript, Python, and more. Here are the keyboard shortcuts for both single-line comments and block comments for both windows and mac users.

Build your next awesome project:

0:07 Windows line comment.
0:12 Mac line comments.
0:16 Remove line comments.
0:24 Block comments.

In this video, I'm going to show you how to comment out multiple lines of code in Visual Studio Code. This is a helpful tip if you need to leave a comment in your code, but you don't want to comment out the entire line of code!

By commenting out multiple lines of code, you can leave a comment without affecting the actual code! This is a useful skill to have if you need to leave a comment in your code, but you don't want to comment out the entire line of code. Watch this video to learn how to comment out multiple lines of code in Visual Studio Code!
Рекомендации по теме
Комментарии
Автор

thank you so much! I've been looking all over the internet for shortcuts and they didn't work

Zoyx-de
Автор

short and to the point, so sweet, thank you sir!

theBATfamiliar
Автор

Your video deserves more likes! New subscriber here!

marcosmecatronikify
Автор

I've discovered a workaround which consists of manually inserting C-Type comment tags "/* */" ... In a PHP file, the opening comment tag ... "/*" ... needs to be inserted right after the question mark symbol as in: "<?/*php" (double quotation marks not to be included) ... one only needs thereafter to insert the closing C-type comment tag at the desired location in the code to create the "comment-sandwich". The "Ctrl+/" sequence can't seem to handle this well. That's what I've experienced so far. Comments welcomed ... no pun intended! 😂

thismoment
Автор

Thank you. I used to revert my code by hand.

ADEPS.
Автор

there needs to be a shortcut for creating /* foo comment */, so:
/*
foo
comment
*/
That's what I'm looking for :-)

atlantic_love
Автор

Ah! Thanks! Reverting back to code after shortcut k+c was pain in the ...

wellumm
Автор

Hello Ademir! Thank you for sharing this useful tip which will work in many cases 🙏, except, when one's block of code contains more than one language type as in the case of a PHP file which contains both HTML and PHP code. When applying the same keyboard sequences you use in your demonstration, the IDE will prefer the <*-- --> type commenting and will leave all the PHP code UN-commented. The forward double-slash "//" commenting style will not be applied ... It would be nice if the VS Code environment could detect these situations and apply the needed commenting style where it is called for. What do you make of this? I've just re-installed a fresh copy of VS Code to make sure my .json settings were not corrupted and I still get the same results.

thismoment
Автор

I'm on VS Code 1.85 on Windows and I have the option to add line comments but not block comments, i can't even find an option for it in my shortcuts list. Any ideas?

closetgeek
Автор

I must be really slow, tried this on my Mac and no response or I'm on the wrong video

bubu
Автор

None of them worked on a fresh installed macbook and visual code... It is driving me crazy.. how the F do I comment stuff

GRANATE
Автор

comment out more than one lines is not working with your comment. Wrong explanation.

bhuller
Автор

why the fck not only one key like in other IDEs?

lordmidi