Visual Studio Tricks


Visual Studio (2005,2008,2010) Tips and Tricks.


#17 Keyboard Shortcut to Comment and Uncomment Code

Commenting code is great. We all do it, all day long. Commonly I’ll see the following done to comment multiple lines of C# code.

[HOME]+[//],[UP],[HOME],<Repeat />

This just takes too long. It’s too many keystrokes. This Quick 2 minute video shows you all about commenting, and uncommenting, and even has an added little trick to know about ASP.NET (ASPX) Commenting.

Click Screenshot To Play Video

#17 Keyboard Shortcut to Comment and Uncomment Code

Runtime: 2Min 12 Seconds - Resolution: 900X580 - File Size: 2.8Meg

Direct Download: If the video does not work for you,
Click Here to download it.

Snippets / Notes:

[CTRL]+[K],[C] = Comment the current line, or selected lines of code

[CTRL]+[K],[U] = Uncomment the current line, or selected lines of code

Visual Studio Tip / Trick #017 English Transcription:

Today’s Visual Studio trick is Keyboard shortcuts for commenting and uncommenting Code. It's trick nunmber 17 which was originally published by Sara Ford in text in August 2007. To comment and uncomment code you use the keyboard combination [CTRL]+[K],[C] to comment and [CTRL]+[K],[U] to uncomment. NOw if you do not have anything selected then the current line of code will be commented for you. If you have more than one line of code selected [CTRL]+[K],[C] and [CTRL]+[K],[U] will comment and uncomment respectively. Now we're in C# file but watch if we jump over to CSS file and we do a [CTRL]+[K],[C]? It doesn’t work for us but if we move into a javascript file [CTRL]+[K],[C] knows how to comment. So there are certain types of files where comments work and certain files where comment do not work. I know it works in Visual Basic, C#, Javascript and also ASPX files. So lets just quickly navigate to an ASPX file and if we highlight a piece of server side code and do [CTRL]+[K],[C] you'll see that there is a server comment that is wrapped around the HTML. Now a server comment is different in ASP.net than a regular comment. A Server comment is actually nothing rendered to the output where a regular HTML comment does get rendered in the output. Where a server side comment does not. So a little bit of a tip/trick on ASP.net as well as [CTRL]+[K],[C] to comment and [CTRL]+[K],[U] to uncomment. That is also available on the Edit menu, if you jump down to the Advance Tools you can see there is a comment and uncomment selection.
Kick this Trick on DotNetKicks.com

2 comment(s)

  1.  avatar

    Audio plays, but screen doesn't advance (I get one screenshot -- so far, only one like this that I've found).

  2.  avatar

    Check that. Completely closed browser and tried again. "Works very much good!"


Main RSS Feed (All Posts)

Scott Cate Main Blog FedSample topics include personal, work, community, technology, and Video Tricks.

Visual Studio Tricks Feed (New)

Scott Cate Visual Studio Tricks RSS FeedOnly contains Visual Studio Tricks. These are 99% video tricks!

Technology RSS Feed

Scott Cate Technology FeedTechnology Only! Tips, Tricks, Programming, Tech Events, and other geeky subjects.

Want Email Notifications of New VSTricks

What is your email?

Twitter @ScottCate

  • Don't forget - tonight's asp.net user group meeting - 5:30-8, info on AZGroups.org
  • Please don't assume using Twitter to communicate will get you a response. Send Email or Call. No. I didn't get your Tweet last week.
  • Don't Forget the Azure User Group in PHX meets tonight - details here http://goo.gl/MBXT
  • I have it turned on as an option in Labs. maybe it moved from Labs into core?? Check yr Lab settings (@timheuer)http://yfrog.com/1dmqtp
  • Congratulations Canada - Great Hockey Game!

Twitter @VSTricks

  • RT @zainnab: Visual Studio 2010 Tips and Tricks Begins!: Happy to announce that the New Year marks the beginning .. http://bit.ly/8pZh0O
  • Congratulations to all @VSTricks entries. @Kazuk was the winner. Video shows how the random was done http://bit.ly/8EDCwW (if u care)
  • @kazuk Congrats - you are the winner - video being posted shortly - please DM me your email
  • @leemessenger @ericfickes @DarrellHardy Trick 504 has been fixed. No login needed. http://bit.ly/71OGcF
  • OK Everyone! Trick 504 is fixed! No user/pwd needed. Debug ASP.net in any browser with #VisualStudio http://bit.ly/7QaCSi

GetClicky Web Stats

Web Analytics