Mac Visual Code Studio Shortcut For Commenting Out

Ctrl+K Ctrl+S Keyboard Shortcuts Basic editing. Ctrl+K Ctrl+C Add line comment Ctrl+K Ctrl+U Remove line comment Ctrl+/ Toggle line comment Shift+Alt+A Toggle block comment. F11 / Shift+F11 Step into/out F10 Step over Ctrl+K Ctrl+I Show hover Integrated terminal.

Keyboard: CTRL + K, CTRL + C (comment); CTRL + K, CTRL + U (uncomment)
Menu: Edit -> Advanced -> Comment Selection; Edit -> Advanced -> Uncomment Selection
Command: Edit.CommentSelection; Edit.UncommentSelection
Versions: 2008,2010
Published: 4/13/2010
Code: vstipEdit0047

Download the seriously cool Tip of the Day Extension to get the daily tips delivered to your Start Page!

Sometimes it's the simple stuff we forget about. So I present to you the classic Comment and Uncomment Selection. Naturally, you have the Comment and Uncomment buttons:

And, of course, we have the Menu items:

Mac Visual Code Studio Shortcut For Commenting Out

But it's the keyboard shortcuts that really rock! These will, predictably, comment or uncomment lines of code for you. So, let's say you have some code you want commented out. Just select it:

Then press CTRL + K, CTRL + C (in this example):

Visual Studio Shortcut For Copy Line

Voila! It's commented out. Okay, great, but what if you don't want to use the mouse? No problem! Just hold ALT + SHIFT + [UP or DOWN ARROW] to do a vertical selection (NOTE: In VS2008 you have to go right or left one character before you can go up or down for vertical selection):

Then press CTRL + K, CTRL + U (in this example):

Visual Studio Shortcut Keys

And there you go! Comment and Uncomment actions anytime you want!