次の方法で共有


Comment and Uncomment in Web Pages

Keyboard:  CTRL + K, CTRL + C; CTRL + K, CTRL + U
Menu:  Edit -> Advanced -> Comment Selection; Edit -> Advanced -> Uncomment Selection
Command:  Edit.CommentSelection; Edit.UncommentSelection
Versions:  2008,2010
Published:  12/7/2010
Code:  vstipEdit0083

 

Comment

By now you probably know that you can comment and uncomment your code but did you know you can do the same thing with your source during web development?  It's easy!  Just put your cursor inside any element you want commented:

image

 

Now just press CTRL + K, CTRL + C to comment out the selection:

image

 

 

 

Of course you can also select multiple elements:

image

 

And comment them out, too:

image

 

 

Uncomment

Naturally, you can put your cursor inside any commented area:

image

 

 

And uncomment (CTRL + K, CTRL + U) it:

image

Comments

  • Anonymous
    December 07, 2010
    Unfortunately, if you already have comments in your HTML/XML/XAML, and try to comment out a section that spans existing comments, then it will only comment out the selection up to the first existing comment. It would be nice if VS added a closing comment before the existing comment, and then a new opening comment after the existing comment. Of course, that wouldn't solve the problem of uncommenting the code, since VS wouldn't be able to distinguish between comments that it added and comments that were already there.