Automatically insert closing tags in HTML / XML / XSL


I’ve been writing quite a bit of HTML / XML / XSL recently, and I’m finding that it’s a chore having to close all my tags (such as <xsl:template></xsl:template> and <html></html>) manually.

Is there a package that will do this for me?



People have been reporting good things about the less-than-slash package.


I feel personally like the most hygienic way to write tree-structured languages is to insert both tags at once, and snippets work great for that.


less-than-slash looks good, but as @DamnedScholar says inserting both tags at once would be preferable. Sadly that’s not possible when writing XML, as you can’t predict the tag name that you’ll be using ahead of time.


It most certainly is possible. When you’re writing an XML document for a pre-defined schema, you can just make snippets for each of the tags you’ll be using most often. For everything else, try out this gem:

  'Blank Tag':
    prefix: '<?>'
    body: '<$1>$2</$1>'

Having $1 inside each tag creates two cursors that mirror everything you type. Then just type the tag name, press tab, and you’re in the middle.


I hadn’t thought of that! I’m adding that to my snippets right now.

#7 or

The latter is unmaintained and does not support multiple cursors



The former looks like just what I was after.