Alex Rivera | Logout

How to comment/uncomment multiple lines of HTML code

Asked 2010-09-21T03:14:27.800
34

Often while coding view templates in html, my habit of adding some helpful comments causes lots of time-consuming effort while testing.

Consider this code...

<!-- Here starts the sidebar -->
<div id="sidebar">
....
</div>

<!-- Here starts the main contents pane -->
<div id="main-contents">
...
</div>

<!-- Here starts the footer -->
<div id="footer">
...
</div>

Now, if I have to hide out some portion of the view template, in case of php I would just select the desired code and put single-line comments (using a shortcut key most of the times).

However, in html code, where only the block comments work, I end-up removing all the closing comment tags (-->) till the position I want the commenting to occur - something like this...

<!-- Here starts the sidebar
<div id="sidebar">
....
</div>

<!-- Here starts the main contents pane
<div id="main-contents">
...
</div>

<!-- Here starts the footer
<div id="footer">
...
</div>-->

Then when I'm done testing I have to go through the agony of putting back those closing tags.

Is there a better and time saving way of block commenting in HTML?

Edit
Report

3 Answers

2

you can try to replace --> with a different string say, #END# and do search and replace with your editor when you wish to return the closing tags.

answered 2010-09-21T03:29:17.007
0

I find this to be the bane of XML style document commenting too. There are XML editors like eclipse that can perform block commenting. Basically automatically add extra per line and remove them. May be they made it purposefully hard to comment that style of document it was supposed to be self explanatory with the tags after all.

answered 2010-09-21T03:27:54.750
-1

Eclipse Juno has a good way for it. You just do the cmd+/

answered 2013-04-02T19:04:12.587

Your Answer