CanOz Blog

Neil Knobbe's Blog at vbCity

vbCity Blogs moved to:
http://cs.vbcity.com/blogs
  Home :: Syndication  :: Login

OctNovember 2009Dec
SMTWTFS
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Archives

Image Galleries

vbCity Blogs

There are times when I have to wonder if I am the only person who does not know some things.

I ran into this self doubt again the other day when I was watching one of Ron Cundiff's VB.NET Soup To Nuts WebCasts.

During the WebCast one of the participants asked if there was a way to comment multiple lines of code.  When I heard this my ears perked up and I got very interested.

In the, almost, ten years that I have been writing code, I always have commented out any lines of code I didn't want to run one line at a time.  What a time consuming effort that can be depending on the number of lines you are working with.  I also ended up with unformatted (not indented) code,

and usually put the comment apostrophe in the wrong place when an indented line of code moved once the one above had been commented out.

Well this is all changed now.  Low and behold there are buttons in the Visual Studio IDE that let you comment out, or uncomment, any lines of code that you have selected.  All this time I had a simple way literally staring me in the face.

Right in the main Toolbar there is the Comment Button

and the Uncomment Button.

Now all I need to do to comment, or uncomment, multiple lines is highlight the code I want and click a button.

One other great thing about this feature is that the code stays formatted (indented) even after commenting which, I believe, makes it much easier to read.

*sigh*  Now I only have to wonder what other time saving “wonders” I will have to wait ten years to discover.

posted on Saturday, June 07, 2008 2:00 AM

Feedback

# re: Multi-Line commenting 6/10/2008 7:07 AM Drydo
Neil,

Its even easier than that.

Press 'Ctrl'+'K' and then whilst holding the 'Ctrl' press 'C'. This will comment out the selected lines. To reverse, 'Ctrl'+'K' and then 'U'.

Drydo

# re: Multi-Line commenting 6/10/2008 12:15 PM Neil
Cool!

Thanks for the extra tip Mark.

# re: Multi-Line commenting 11/9/2008 9:01 PM mandar patil
thanks for your help!!! :)

Post Feedback

Title:
Name:
Url:
Comments: 
Protected by Clearscreen.SharpHIPEnter the code you see: