Visual Studio (2005,2008,2010) Tips and Tricks.
#17 Keyboard Shortcut to Comment and Uncomment Code
Thursday, January 22 2009
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.
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.
2 comment(s)
Audio plays, but screen doesn't advance (I get one screenshot -- so far, only one like this that I've found).
Check that. Completely closed browser and tried again. "Works very much good!"