sublime text - plugin for creating automatic start end html comments - sublimetext2

Is there any plugin out there that creates begin, end HTML comments automatically? Like the following.
<!-- begin #page -->
<div id="page">
<!-- begin #header -->
<div id="header">
</div>
<!-- end #header -->
</div>
<!-- end #page -->
I am tired of commenting these out.

You may use this little snippet that I wrote:
<snippet>
<content><![CDATA[
<!-- .${1:className} -->
<div class="${1:className}">
${2}
</div>
<!-- /.${1:className} -->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>divc</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
and save it in Sublime Text #\Packages\User\divc.sublime-snippet
When you are done, you can use divc+tab to generate the required snippet

Not that i know of but you can create a custom snippet and use it when you like. This will allow you to insert that text without typing it out each time.
For directions check this link:
http://sublimetext.info/docs/en/extensibility/snippets.html

If you just want to comment something out, you can just select the content you want to comment and type ctrl + / and it will do the trick.

Related

How to comment out knockout code in HTML

Is there any to comment out a knock out code in HTML, since the ko code is already in default html comment block.
<!-- ko if : isEditable() -->
<!-- Edit Mode -->
<div class="edit">Edit mode</div>
<!-- /ko -->
Can I comment the above section in my html
In our project we tend to use <!-- kocomment if : isEditable() --><!-- /kocomment --> syntax which effectively turns ko statement into a simple html comment (knockout does not care for such comments).
Or you may use shorter additions to ko word. Just make sure to comment out both opening and closing statement, there is also risk that this commented comment will not stand out, unless you have some knockout syntax highlighting.
Just change the ko to anything else!
<!-- koc if : isEditable() --> or <!-- kcomment if : isEditable() --> anything other that ko makes it as a comment.
As knockout looks only for html comments that start with ko, anything other than ko on an html comment will simply be a comment.

HTML comment each line separately, not block comments

Noob question but I want to be able to quickly comment HTML code using keyboard shortcuts in VS code. Problem is I get this:-
<!-- <div class="whatever">
<h1>Hellow World!</h1>
<p>this is code I wrote in HTML</p>
</div> -->
instead of this:-
<!-- <div class="whatever"> -->
<!-- <h1>Hellow World!</h1> -->
<!-- <p>this is code I wrote in HTML</p> -->
<!-- </div> -->
Anyone know a good extension for this in VS Code? Thanks
Julien
See this extension written by me, Toggle Line Comments, that will do what you want.
-- or older answer --
Select through your text - i.e., from some part of the first line to some part of the last line you want separately commented. I.e., highlight your block of html to comment.
Shift-Alt-I will put a cursor at the end of each line.
Ctrl-/ will comment each line separately.
This only seems necessary for html, not js or scss for example.
I suppose if you wanted to reduce keystrokes you could make a macro for steps 2 and 3 combined.

How to comment out a HTML block which contains comments

I try to comment out a block of HTML which contains comments, when the time I do so, the commenting terminated at the first comment tag ending. Is there any way to do so? I didn't find it anywhere.
Let see this HTML
<!-- START overview-section -->
<div class="overview gray">
<!-- Title section -->
<div class="row">
</div>
</div>
How to comment it as a whole.
Short of breaking up the pairs of -- inside the comment, you cannot achieve this in HTML.
If you were generating your HTML from some kind of template language, you could use the template language's comment syntax instead.
You can wrap it up in a script tag and use JavaScript's block comments
<script> /***
<!-- START overview-section -->
<div class="overview gray">
<!-- Title section -->
<div class="row">
</div>
</div>
***/ </script>
this can't be done with HTML. It can however be done if it were php
<?php
//<!-- START overview-section -->
//<div class="overview gray">
// <!-- Title section -->
// <div class="row">
// </div>
//</div>
?>

Sublime Text HTML Block Comment Containing Comments

Is there a plugin to help with HTML commenting a block of code that may already contain other comments?
<div class="wrapper">
<div class="container"></div>
<!-- /.container -->
</div>
<!-- /.wrapper -->
BBEdit has a built in feature where if you select all of this code and apply a block comment, it will change the existing comments temporarily so that the main block comment can be applied. The output in the editor would look like:
<!--
<div class="wrapper">
<div class="container"></div>
<!~~ /.container ~~>
</div>
<!~~ /.wrapper ~~>
-->
Uncommenting the block would set the ~ characters back to dashes - so the individual comments would still be in place.
I am not looking for this specific functionality, but something that allows for block commenting content that already contains HTML comments without having to manually remove/edit the existing comments.
I could not find a plugin that does this, so I wrote one.
Installation instructions are available at https://github.com/philsinatra/HTMLNestedComments

How to use wrap comment in HTML

Sample structure:
<div>1111111111</div> <!-- First line -->
<div>2222222222</div> <!-- Second line -->
<div>3333333333</div> <!-- Third line -->
It's OK. However, I want to wrap comment for this divs.
Sure, not working like this:
<!--
<div>1111111111</div> <!-- First line -->
<div>2222222222</div> <!-- Second line -->
<div>3333333333</div> <!-- Third line -->
-->
How can I do this?
If you really can't change any comments within the original source, but you can (or so it seems) wrap some lines in the source with something. You could turn the lines into a JavaScript multi line comment like I have done in this jsFiddle.
<script type="text/javascript">
/*
<div>1111111111</div> <!-- First line -->
<div>2222222222</div> <!-- Second line -->
<div>3333333333</div> <!-- Third line -->
*/
</script>